}
constructor (fn: string) {
- console.log(`cores: ${this.#cores}`)
const url = URL.createObjectURL(new Blob([fn], { type: 'text/javascript' }))
for (let i = this.#cores; i > 0; i--) {
const thread = {
worker: new Worker(url, { type: 'module', eval: true })
}
thread.worker.addEventListener('message', (message) => {
+ console.log(`received worker response (${performance.now()})`)
let result = JSON.parse(new TextDecoder().decode(message.data ?? message))
if (!Array.isArray(result)) result = [result]
this.#report(thread, result)
if (next.length > 0) {
thread.isBusy = true
const buf = new TextEncoder().encode(JSON.stringify(next)).buffer
- console.log(`posting to ${thread} (${performance.now()})`)
+ console.log(`posting to thread (${performance.now()})`)
thread.worker.postMessage(buf, [buf])
}
}
}
async work (data: object[]): Promise<any> {
+ console.log(`pool.work (${performance.now()})`)
if (!Array.isArray(data)) data = [data]
return new Promise(resolve => {
this.#queue = data
let results = await this.ckd(indexes)\r
const data: any = []\r
results.forEach(r => data.push({ privateKey: r.privateKey, index: r.index }))\r
- console.log(`accounts data`)\r
- console.dir(data)\r
let now = performance.now()\r
const keypairs: KeyPair[] = await this.#pool.work(data)\r
console.log(`keypairs: ${-now + (now = performance.now())} ms`)\r
* Listens for messages from a calling function.
*/
addEventListener('message', (message) => {
+ console.log(`bip44ckd work received (${performance.now()})`)
const data = JSON.parse(new TextDecoder().decode(message.data ?? message))
process(data).then(results => {
const buf = new TextEncoder().encode(JSON.stringify(results)).buffer
* Listens for messages from a calling function.\r
*/\r
addEventListener('message', (message) => {\r
+ console.log(`nacl work received (${performance.now()})`)\r
const data = JSON.parse(new TextDecoder().decode(message.data ?? message))\r
- for (const d of data) {\r
- d.publicKey = hexify(keyPair(d.privateKey).publicKey)\r
+ // for (const d of data) {\r
+ for (let i = 0; i < data.length; i++) {\r
+ if (i % 100 === 0) console.log(`${i} keys`)\r
+ data[i].publicKey = hexify(keyPair(data[i].privateKey).publicKey)\r
}\r
const buf = new TextEncoder().encode(JSON.stringify(data)).buffer\r
//@ts-expect-error\r
+ console.log(`nacl work done (${performance.now()})`)\r
postMessage(buf, [buf])\r
})\r
\r