From: Chris Duncan Date: Mon, 13 Apr 2026 06:09:55 +0000 (-0700) Subject: Generate PoW automatically during networking processing if work value is not present... X-Git-Tag: v0.12.0~4^2~15 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=c7d87d35d2b2ba661a7c33c25162ad44853ca3b1;p=libnemo.git Generate PoW automatically during networking processing if work value is not present at broadcast. --- diff --git a/src/lib/block.ts b/src/lib/block.ts index 17f5bc3..5402446 100644 --- a/src/lib/block.ts +++ b/src/lib/block.ts @@ -251,7 +251,8 @@ export class Block { * Sends the block to a node for processing on the network. * * The block must already be signed (see `sign()` for more information). - * The block must also have a `work` value. + * + * If the block has no `work` value, `pow()` will be called automatically. * * @param {Rpc} rpc - RPC node information required to call `process` * @returns {Promise} Hash of the processed block @@ -262,9 +263,7 @@ export class Block { if (this.signature == null) { throw new Error('Block is missing signature. Use sign() and try again.') } - if (this.work == null) { - throw new Error('Block is missing proof-of-work. Use pow() and try again.') - } + if (this.work == null) await this.pow() const data = { subtype: this.subtype, json_block: true,