Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions lib/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -562,8 +562,10 @@ type Blockchain struct {
blockIndexByHeight map[uint64]map[BlockHash]*BlockNode
// An in-memory slice of the blocks on the main chain only. The end of
// this slice is the best known tip that we have at any given time.
bestChain []*BlockNode
bestChainMap map[BlockHash]*BlockNode
bestChain []*BlockNode
bestChainMap map[BlockHash]*BlockNode
bestChainFullyStoredIndex int
bestChainCheckArchivalModeIndex int

bestHeaderChain []*BlockNode
bestHeaderChainMap map[BlockHash]*BlockNode
Expand Down Expand Up @@ -778,10 +780,11 @@ func (bc *Blockchain) CopyBestHeaderChain() ([]*BlockNode, map[BlockHash]*BlockN
// IsFullyStored determines if there are block nodes that haven't been fully stored or processed in the best block chain.
func (bc *Blockchain) IsFullyStored() bool {
if bc.ChainState() == SyncStateFullyCurrent {
for _, blockNode := range bc.bestChain {
for _, blockNode := range bc.bestChain[bc.bestChainFullyStoredIndex:] {
if !blockNode.Status.IsFullyProcessed() {
return false
}
bc.bestChainFullyStoredIndex++
}
return true
}
Expand Down Expand Up @@ -1576,7 +1579,7 @@ func (bc *Blockchain) checkArchivalMode() bool {
}

firstSnapshotHeight := bc.snapshot.CurrentEpochSnapshotMetadata.FirstSnapshotBlockHeight
for _, blockNode := range bc.bestChain {
for _, blockNode := range bc.bestChain[bc.bestChainCheckArchivalModeIndex:] {
if uint64(blockNode.Height) > firstSnapshotHeight {
return false
}
Expand All @@ -1589,6 +1592,7 @@ func (bc *Blockchain) checkArchivalMode() bool {

return true
}
bc.bestChainCheckArchivalModeIndex++
}

// If we get here, it means that all blocks have been processed and stored, so there is nothing to do.
Expand Down