move the intiial chain cache generation into bm.
Blockmanager is otherwise the only current consumer of chain and it is messy to do it outside of it.
This commit is contained in:
parent
850420055f
commit
ca7cb8c875
2 changed files with 13 additions and 8 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue