Skip to content

Commit

Permalink
bugfix: modified headersWithoutState array to work on copies of headers
Browse files Browse the repository at this point in the history
  • Loading branch information
kiltsonfire authored and gameofpointers committed Oct 7, 2023
1 parent e0035db commit 81c9cc5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
8 changes: 0 additions & 8 deletions core/bodydb.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ func (bc *BodyDb) Append(block *types.Block, newInboundEtxs types.Transactions)
rawdb.WriteTxLookupEntriesByBlock(batch, block)
}
log.Debug("Time taken to", "apply state:", common.PrettyDuration(time.Since(stateApply)))

rawdb.WriteBlock(batch, block)
if err = batch.Write(); err != nil {
return nil, err
}
Expand Down Expand Up @@ -170,16 +168,10 @@ func (bc *BodyDb) GetBlock(hash common.Hash, number uint64) *types.Block {
// GetBlockOrCandidate retrieves any known block from the database by hash and number,
// caching it if found.
func (bc *BodyDb) GetBlockOrCandidate(hash common.Hash, number uint64) *types.Block {
// Short circuit if the block's already in the cache, retrieve otherwise
if block, ok := bc.blockCache.Get(hash); ok {
return block.(*types.Block)
}
block := rawdb.ReadBlock(bc.db, hash, number)
if block == nil {
return nil
}
// Cache the found block for next time and return
bc.blockCache.Add(block.Hash(), block)
return block
}

Expand Down
2 changes: 1 addition & 1 deletion core/headerchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ func (hc *HeaderChain) SetCurrentState(head *types.Header) error {
if etxSet != nil {
break
}
current = header
current = types.CopyHeader(header)
}

// Run through the hash stack to update canonicalHash and forward state processor
Expand Down

0 comments on commit 81c9cc5

Please sign in to comment.