From: Chris Duncan Date: Tue, 3 Dec 2024 20:48:28 +0000 (-0800) Subject: Remove RPC references from pow now that it's done locally. X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=743731317662dfbb626ce49bf38f79f39dd85f24;p=libnemo.git Remove RPC references from pow now that it's done locally. --- diff --git a/src/lib/block.ts b/src/lib/block.ts index ee3c5a8..3499762 100644 --- a/src/lib/block.ts +++ b/src/lib/block.ts @@ -79,23 +79,14 @@ abstract class Block { } /** - * Sends the block to a node for calculating proof-of-work on the network. + * Calculates proof-of-work using a pool of WebGL workers. * * A successful response sets the `work` property. - * - * @param {Rpc|string|URL} rpc - RPC node information required to call `work_generate` */ - async pow (rpc: Rpc | string | URL): Promise { - // if (typeof rpc === 'string' || rpc.constructor === URL) { - // rpc = new Rpc(rpc) - // } - // if (rpc.constructor !== Rpc) { - // throw new TypeError('RPC must be a valid node') - // } + async pow (): Promise { const data = { "hash": this.previous } - // const { work } = await rpc.call('work_generate', data) const [{ work }] = await this.#pool.work('converge', [data]) this.work = work } diff --git a/src/lib/tools.ts b/src/lib/tools.ts index 8ea4a74..48cd6e6 100644 --- a/src/lib/tools.ts +++ b/src/lib/tools.ts @@ -126,7 +126,7 @@ export async function sweep (rpc: Rpc | string | URL, wallet: Blake2bWallet | Bi ) const blockRequest: Promise = new Promise(async (resolve) => { try { - await block.pow(rpc) + await block.pow() await block.sign(account.index) const hash = await block.process(rpc) results.push({ status: 'success', address: block.account.address, message: hash })