Merge pull request #9722 from ziggie1984/fix-notifier-itest-flake

Change RPC call order for the btcd notifier
This commit is contained in:
Oliver Gugger
2025-04-17 22:50:07 +02:00
committed by GitHub

View File

@@ -223,6 +223,17 @@ func (b *BtcdNotifier) startNotifier() error {
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()
if err != nil {
b.txUpdates.Stop()
@@ -248,12 +259,6 @@ func (b *BtcdNotifier) startNotifier() error {
BlockHeader: &bestBlock.Header,
}
if err := b.chainConn.NotifyBlocks(); err != nil {
b.txUpdates.Stop()
b.chainUpdates.Stop()
return err
}
b.wg.Add(1)
go b.notificationDispatcher()