jaapenstaart / stellar-name-key

Use this script to generate a Stellar keypair, with a public key ending with a name you provide.
MIT License
13 stars 4 forks source link

suggestion for speed up #1

Open sgehrman opened 6 years ago

sgehrman commented 6 years ago

Wouldn't it be a bit faster if you made some variables outside the loop? Let me know if you try it and see if it's faster.

let length = name.length let upperCaseName = name.toUpperCase()

while (keypair.publicKey().slice(-length ) !== upperCaseName ) {

}

jaapenstaart commented 6 years ago

Thanks for the suggestion. Good point to save those variables in a const, however i don't expect that much of a performance win. .length and .toUpperCase() are both very cheap compared to the StellarSdk.Keypair.random(); function.

I'll update it and push when i'm home.

sgehrman commented 6 years ago

Hey, I sent in a pull request, see if it's much faster. CPUs will max out for sure with these changes.