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.'));
|
||||
}
|
||||
|
||||
block.setHeight(height);
|
||||
|
||||
// Create a chain entry.
|
||||
entry = new bcoin.chainentry(self, data, lastEntry);
|
||||
entry = bcoin.chainentry.fromBlock(self, block, lastEntry);
|
||||
|
||||
if (entry.height > chainHeight)
|
||||
save(entry, block);
|
||||
@ -1563,16 +1565,7 @@ Chain.prototype.add = function add(block, callback, force) {
|
||||
block.setHeight(height);
|
||||
|
||||
// Create a new chain entry.
|
||||
entry = new bcoin.chainentry(self, {
|
||||
hash: hash,
|
||||
version: block.version,
|
||||
prevBlock: block.prevBlock,
|
||||
merkleRoot: block.merkleRoot,
|
||||
ts: block.ts,
|
||||
bits: block.bits,
|
||||
nonce: block.nonce,
|
||||
height: height
|
||||
}, prev);
|
||||
entry = bcoin.chainentry.fromBlock(self, block, prev);
|
||||
|
||||
// The block is on a alternate chain if the
|
||||
// chainwork is less than or equal to
|
||||
|
||||
@ -253,21 +253,11 @@ ChainDB.prototype._init = function _init() {
|
||||
if (exists)
|
||||
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.setHeight(0);
|
||||
|
||||
genesis = bcoin.chainentry.fromBlock(self.chain, block);
|
||||
|
||||
self.save(genesis, block, null, true, finish);
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user