chainntnfs/bitcoind: commit spend hints before notifying
This commit is contained in:
parent
7fe095c541
commit
fb7b12a7db
@ -632,13 +632,6 @@ func (b *BitcoindNotifier) handleBlockConnected(block chainntnfs.BlockEpoch) err
|
|||||||
chainntnfs.Log.Infof("New block: height=%v, sha=%v", block.Height,
|
chainntnfs.Log.Infof("New block: height=%v, sha=%v", block.Height,
|
||||||
block.Hash)
|
block.Hash)
|
||||||
|
|
||||||
// We want to set the best block before dispatching notifications so
|
|
||||||
// if any subscribers make queries based on their received block epoch,
|
|
||||||
// our state is fully updated in time.
|
|
||||||
b.bestBlock = block
|
|
||||||
|
|
||||||
b.notifyBlockEpochs(block.Height, block.Hash)
|
|
||||||
|
|
||||||
// Finally, we'll update the spend height hint for all of our watched
|
// Finally, we'll update the spend height hint for all of our watched
|
||||||
// outpoints that have not been spent yet. This is safe to do as we do
|
// outpoints that have not been spent yet. This is safe to do as we do
|
||||||
// not watch already spent outpoints for spend notifications.
|
// not watch already spent outpoints for spend notifications.
|
||||||
@ -652,13 +645,22 @@ func (b *BitcoindNotifier) handleBlockConnected(block chainntnfs.BlockEpoch) err
|
|||||||
uint32(block.Height), ops...,
|
uint32(block.Height), ops...,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// The error is not fatal, so we should not return an
|
// The error is not fatal since we are connecting a
|
||||||
// error to the caller.
|
// block, and advancing the spend hint is an optimistic
|
||||||
|
// optimization.
|
||||||
chainntnfs.Log.Errorf("Unable to update spend hint to "+
|
chainntnfs.Log.Errorf("Unable to update spend hint to "+
|
||||||
"%d for %v: %v", block.Height, ops, err)
|
"%d for %v: %v", block.Height, ops, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We want to set the best block before dispatching notifications so
|
||||||
|
// if any subscribers make queries based on their received block epoch,
|
||||||
|
// our state is fully updated in time.
|
||||||
|
b.bestBlock = block
|
||||||
|
|
||||||
|
// Lastly we'll notify any subscribed clients of the block.
|
||||||
|
b.notifyBlockEpochs(block.Height, block.Hash)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user