}
/**
- * 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<void> {
- // 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<void> {
const data = {
"hash": this.previous
}
- // const { work } = await rpc.call('work_generate', data)
const [{ work }] = await this.#pool.work('converge', [data])
this.work = work
}
)
const blockRequest: Promise<void> = 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 })