Set best chain during GenerateInitialIndex.
This commit modifies the GenerateInitialIndex function to update the best chain with each node as it is loaded. This allows the best chain to be set immediately upon generating the initial index which is a slight performance optimization.
This commit is contained in:
parent
d0be0ed5ed
commit
fc1b2e54d3
1 changed files with 4 additions and 1 deletions
5
chain.go
5
chain.go
|
@ -379,10 +379,13 @@ func (b *BlockChain) GenerateInitialIndex() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = b.loadBlockNode(hash)
|
node, err := b.loadBlockNode(hash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This node is now the end of the best chain.
|
||||||
|
b.bestChain = node
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Add table
Reference in a new issue