mirror of
https://github.com/btcsuite/btcd.git
synced 2026-08-13 12:32:51 +02:00
blockchain: load database blocks strictly
This commit is contained in:
parent
f3ec349a60
commit
29cfb6ec9f
1 changed files with 3 additions and 4 deletions
|
|
@ -1277,8 +1277,7 @@ func (b *BlockChain) initChainState() error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var block wire.MsgBlock
|
||||
err = block.Deserialize(bytes.NewReader(blockBytes))
|
||||
block, err := btcutil.NewBlockFromBytes(blockBytes)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -1304,8 +1303,8 @@ func (b *BlockChain) initChainState() error {
|
|||
|
||||
// Initialize the state related to the best block.
|
||||
blockSize := uint64(len(blockBytes))
|
||||
blockWeight := uint64(GetBlockWeight(btcutil.NewBlock(&block)))
|
||||
numTxns := uint64(len(block.Transactions))
|
||||
blockWeight := uint64(GetBlockWeight(block))
|
||||
numTxns := uint64(len(block.MsgBlock().Transactions))
|
||||
b.stateSnapshot = newBestState(tip, blockSize, blockWeight,
|
||||
numTxns, state.totalTxns, CalcPastMedianTime(tip))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue