From fc1b2e54d38a3803e835e67d254a2f79d788ba27 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Wed, 28 Aug 2013 10:42:38 -0500 Subject: [PATCH] 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. --- chain.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/chain.go b/chain.go index 6758e6d2..123b9aef 100644 --- a/chain.go +++ b/chain.go @@ -379,10 +379,13 @@ func (b *BlockChain) GenerateInitialIndex() error { return err } - _, err = b.loadBlockNode(hash) + node, err := b.loadBlockNode(hash) if err != nil { return err } + + // This node is now the end of the best chain. + b.bestChain = node } return nil