mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-25 08:11:18 +02:00
btcdnotify: change order of rpc calls.
We have to make sure we register the block notifier before we fetch the best block for block notifications.
This commit is contained in:
parent
06f1ef47fa
commit
cadc8d0fba
@ -223,6 +223,17 @@ func (b *BtcdNotifier) startNotifier() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Before we fetch the best block/block height we need to register the
|
||||||
|
// notifications for connected blocks, otherwise we might think we are
|
||||||
|
// at an earlier block height because during block notification
|
||||||
|
// registration we might have already mined some new blocks. Hence we
|
||||||
|
// will not get notified accordingly.
|
||||||
|
if err := b.chainConn.NotifyBlocks(); err != nil {
|
||||||
|
b.txUpdates.Stop()
|
||||||
|
b.chainUpdates.Stop()
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
currentHash, currentHeight, err := b.chainConn.GetBestBlock()
|
currentHash, currentHeight, err := b.chainConn.GetBestBlock()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.txUpdates.Stop()
|
b.txUpdates.Stop()
|
||||||
@ -248,12 +259,6 @@ func (b *BtcdNotifier) startNotifier() error {
|
|||||||
BlockHeader: &bestBlock.Header,
|
BlockHeader: &bestBlock.Header,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := b.chainConn.NotifyBlocks(); err != nil {
|
|
||||||
b.txUpdates.Stop()
|
|
||||||
b.chainUpdates.Stop()
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
b.wg.Add(1)
|
b.wg.Add(1)
|
||||||
go b.notificationDispatcher()
|
go b.notificationDispatcher()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user