diff --git a/blockmanager.go b/blockmanager.go index 08d7fb40..5e211ad2 100644 --- a/blockmanager.go +++ b/blockmanager.go @@ -545,7 +545,7 @@ func (b *blockManager) Stop() error { // newBlockManager returns a new bitcoin block manager. // Use Start to begin processing asynchronous block and inv updates. -func newBlockManager(s *server) *blockManager { +func newBlockManager(s *server) (*blockManager, error) { chainNotify := make(chan *btcchain.Notification) bm := blockManager{ server: s, @@ -562,7 +562,16 @@ func newBlockManager(s *server) *blockManager { quit: make(chan bool), } bm.blockChain.DisableVerify(cfg.VerifyDisabled) - return &bm + + log.Infof("[BMGR] Generating initial block node index. This may " + + "take a while...") + err := bm.blockChain.GenerateInitialIndex() + if err != nil { + return nil, err + } + log.Infof("[BMGR] Block index generation complete") + + return &bm, nil } // removeRegressionDB removes the existing regression test database if running diff --git a/server.go b/server.go index 95bfab2e..b9e0458d 100644 --- a/server.go +++ b/server.go @@ -608,15 +608,11 @@ func newServer(addr string, db btcdb.Db, btcnet btcwire.BitcoinNet) (*server, er quit: make(chan bool), db: db, } - s.blockManager = newBlockManager(&s) - - log.Infof("[BMGR] Generating initial block node index. This may " + - "take a while...") - err = s.blockManager.blockChain.GenerateInitialIndex() + bm, err := newBlockManager(&s) if err != nil { return nil, err } - log.Infof("[BMGR] Block index generation complete") + s.blockManager = bm if !cfg.DisableRPC { s.rpcServer, err = newRPCServer(&s)