-
Notifications
You must be signed in to change notification settings - Fork 2
Description
I tried to get this library working with the latest NPM and react but I couldn't get it to work and ended up completely rebuilding it using react-app-rewired together with worker-loader instead of ejecting the whole project like you did.
It all works great with web workers, multithreading and all and the following code does the address creation and matching (it's taken from this codebase). However I have problem with performance. Without the derivePublicKey below I can do 150,000 loops per second. With the derivePublicKey the performance drops to 600/s. Another strange thing is that there is no difference using 2 threads or 12 when doing that. Just using "currentAddressesCount += 1" boost the loop count to 120 million per second so nothing wrong with the multithreading implementation. Using nanoaddr.io on the same machine gives 70,000 addresses per second so I know it should be possible to boost. I just don't understand what's wrong. Do you remember running into that issue? And how did you solve it? Any help you could give is greatly appreciated. You can reach me on discord in the Nano server as Json.
The new tool will be part of a complete set of web tools I'm building for Nano and I will reference this repo as a source.
function search() {
currentAddressesCount += 1
const array = new Uint8Array(32)
// eslint-disable-next-line no-restricted-globals
self.crypto.getRandomValues(array)
const seed = array.reduce((hex, idx) => hex + (`0${idx.toString(16)}`).slice(-2), '')
const secretKey = nano.deriveSecretKey(seed, 0)
const publicKey = nano.derivePublicKey(secretKey)
const address = nano.deriveAddress(publicKey, {useNanoPrefix: true})
if (isMatch(address)) {
postMessage(address)
}
}