mempool: extra sanity checking for mining.
This commit is contained in:
parent
027470e8cb
commit
8977e99906
@ -88,6 +88,7 @@ function Mempool(options) {
|
||||
this.freeCount = 0;
|
||||
this.lastTime = 0;
|
||||
this.lastFlush = 0;
|
||||
this.tip = this.network.genesis.hash;
|
||||
|
||||
this.waiting = {};
|
||||
this.orphans = {};
|
||||
@ -150,6 +151,8 @@ Mempool.prototype._open = co(function* open() {
|
||||
}
|
||||
}
|
||||
|
||||
this.tip = this.chain.tip.hash;
|
||||
|
||||
this.logger.info('Mempool loaded (maxsize=%dkb).', size);
|
||||
});
|
||||
|
||||
@ -227,6 +230,8 @@ Mempool.prototype._addBlock = co(function* addBlock(block, txs) {
|
||||
|
||||
yield this.cache.flush();
|
||||
|
||||
this.tip = block.hash;
|
||||
|
||||
if (entries.length === 0)
|
||||
return;
|
||||
|
||||
@ -291,6 +296,8 @@ Mempool.prototype._removeBlock = co(function* removeBlock(block, txs) {
|
||||
|
||||
yield this.cache.flush();
|
||||
|
||||
this.tip = block.prevBlock;
|
||||
|
||||
if (total === 0)
|
||||
return;
|
||||
|
||||
@ -345,6 +352,8 @@ Mempool.prototype._reset = co(function* reset() {
|
||||
yield this.cache.wipe();
|
||||
this.cache.clear();
|
||||
}
|
||||
|
||||
this.tip = this.chain.tip.hash;
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
@ -389,6 +389,9 @@ Miner.prototype.build = function build(attempt) {
|
||||
if (!this.mempool)
|
||||
return [];
|
||||
|
||||
assert(this.mempool.tip === this.chain.tip.hash,
|
||||
'Mempool/chain tip mismatch! Unsafe to create block.');
|
||||
|
||||
hashes = this.mempool.getSnapshot();
|
||||
|
||||
for (i = 0; i < hashes.length; i++) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user