blockchain: load database blocks strictly

This commit is contained in:
Boris Nagaev 2026-06-23 12:40:20 -05:00
parent f3ec349a60
commit 29cfb6ec9f
No known key found for this signature in database

View file

@ -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))