File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -223,6 +223,17 @@ func (b *BtcdNotifier) startNotifier() error {
223
223
return err
224
224
}
225
225
226
+ // Before we fetch the best block/block height we need to register the
227
+ // notifications for connected blocks, otherwise we might think we are
228
+ // at an earlier block height because during block notification
229
+ // registration we might have already mined some new blocks. Hence we
230
+ // will not get notified accordingly.
231
+ if err := b .chainConn .NotifyBlocks (); err != nil {
232
+ b .txUpdates .Stop ()
233
+ b .chainUpdates .Stop ()
234
+ return err
235
+ }
236
+
226
237
currentHash , currentHeight , err := b .chainConn .GetBestBlock ()
227
238
if err != nil {
228
239
b .txUpdates .Stop ()
@@ -248,12 +259,6 @@ func (b *BtcdNotifier) startNotifier() error {
248
259
BlockHeader : & bestBlock .Header ,
249
260
}
250
261
251
- if err := b .chainConn .NotifyBlocks (); err != nil {
252
- b .txUpdates .Stop ()
253
- b .chainUpdates .Stop ()
254
- return err
255
- }
256
-
257
262
b .wg .Add (1 )
258
263
go b .notificationDispatcher ()
259
264
You can’t perform that action at this time.
0 commit comments