diff --git a/lib/http/rpc.js b/lib/http/rpc.js index d056de72..af03cdcd 100644 --- a/lib/http/rpc.js +++ b/lib/http/rpc.js @@ -1051,11 +1051,13 @@ RPC.prototype.submitBlock = co(function* submitBlock(args, help) { }); RPC.prototype._submitBlock = co(function* _submitBlock(block) { - var unlock = yield this.locker.lock(); + var unlock1 = yield this.locker.lock(); + var unlock2 = yield this.chain.locker.lock(); try { return yield this.__submitBlock(block); } finally { - unlock(); + unlock2(); + unlock1(); } }); @@ -1066,29 +1068,28 @@ RPC.prototype.__submitBlock = co(function* __submitBlock(block) { prev = yield this.chain.db.getEntry(block.prevBlock); - if (!prev) - return 'rejected: bad-prevblk'; + if (prev) { + state = yield this.chain.getDeployments(block.ts, prev); - state = yield this.chain.getDeployments(block.ts, prev); + // Fix eloipool bug (witness nonce is not present). + if (state.hasWitness() && block.getCommitmentHash()) { + tx = block.txs[0]; + if (!tx.hasWitness()) { + this.logger.warning('Submitted block had no witness nonce.'); + this.logger.debug(tx); - // Fix eloipool bug (witness nonce is not present). - if (state.hasWitness() && block.getCommitmentHash()) { - tx = block.txs[0]; - if (!tx.hasWitness()) { - this.logger.warning('Submitted block had no witness nonce.'); - this.logger.debug(tx); + // Recreate witness nonce (all zeroes). + tx.inputs[0].witness.set(0, encoding.ZERO_HASH); + tx.inputs[0].witness.compile(); - // Recreate witness nonce (all zeroes). - tx.inputs[0].witness.set(0, encoding.ZERO_HASH); - tx.inputs[0].witness.compile(); - - tx.refresh(); - block.refresh(); + tx.refresh(); + block.refresh(); + } } } try { - entry = yield this.chain.add(block); + entry = yield this.chain._add(block); } catch (err) { if (err.type === 'VerifyError') { this.logger.warning('RPC block rejected: %s (%s).',