chainentry.fromBlock.
This commit is contained in:
parent
1aa70f8ff0
commit
4a8ef06154
@ -421,8 +421,10 @@ Chain.prototype._preload = function _preload(callback) {
|
|||||||
return callback(new Error('Bad headers.'));
|
return callback(new Error('Bad headers.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
block.setHeight(height);
|
||||||
|
|
||||||
// Create a chain entry.
|
// Create a chain entry.
|
||||||
entry = new bcoin.chainentry(self, data, lastEntry);
|
entry = bcoin.chainentry.fromBlock(self, block, lastEntry);
|
||||||
|
|
||||||
if (entry.height > chainHeight)
|
if (entry.height > chainHeight)
|
||||||
save(entry, block);
|
save(entry, block);
|
||||||
@ -1563,16 +1565,7 @@ Chain.prototype.add = function add(block, callback, force) {
|
|||||||
block.setHeight(height);
|
block.setHeight(height);
|
||||||
|
|
||||||
// Create a new chain entry.
|
// Create a new chain entry.
|
||||||
entry = new bcoin.chainentry(self, {
|
entry = bcoin.chainentry.fromBlock(self, block, prev);
|
||||||
hash: hash,
|
|
||||||
version: block.version,
|
|
||||||
prevBlock: block.prevBlock,
|
|
||||||
merkleRoot: block.merkleRoot,
|
|
||||||
ts: block.ts,
|
|
||||||
bits: block.bits,
|
|
||||||
nonce: block.nonce,
|
|
||||||
height: height
|
|
||||||
}, prev);
|
|
||||||
|
|
||||||
// The block is on a alternate chain if the
|
// The block is on a alternate chain if the
|
||||||
// chainwork is less than or equal to
|
// chainwork is less than or equal to
|
||||||
|
|||||||
@ -253,21 +253,11 @@ ChainDB.prototype._init = function _init() {
|
|||||||
if (exists)
|
if (exists)
|
||||||
return finish();
|
return finish();
|
||||||
|
|
||||||
genesis = new bcoin.chainentry(self.chain, {
|
|
||||||
hash: self.network.genesis.hash,
|
|
||||||
version: self.network.genesis.version,
|
|
||||||
prevBlock: self.network.genesis.prevBlock,
|
|
||||||
merkleRoot: self.network.genesis.merkleRoot,
|
|
||||||
ts: self.network.genesis.ts,
|
|
||||||
bits: self.network.genesis.bits,
|
|
||||||
nonce: self.network.genesis.nonce,
|
|
||||||
height: 0,
|
|
||||||
chainwork: null
|
|
||||||
}, null);
|
|
||||||
|
|
||||||
block = bcoin.block.fromRaw(self.network.genesisBlock, 'hex');
|
block = bcoin.block.fromRaw(self.network.genesisBlock, 'hex');
|
||||||
block.setHeight(0);
|
block.setHeight(0);
|
||||||
|
|
||||||
|
genesis = bcoin.chainentry.fromBlock(self.chain, block);
|
||||||
|
|
||||||
self.save(genesis, block, null, true, finish);
|
self.save(genesis, block, null, true, finish);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user