From 2dcb86bced5f3826134eba5ba83d3bc67d9b5ce3 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Sat, 29 Sep 2018 13:53:24 -0700 Subject: [PATCH] chainntnfs/txconfnotifier: set confset details at tip This commit ensures that a confSet's details are assigned in the confNotifications index after discovering the transaction at tip. The recent changes allow a later notification to be dispatched on registration if an earlier one has already discovered the confirmation details. Before this change, it was observed that a later registration would attempt an immediate delivery, but fail to do so because the confset's details were nil. This commit remedies that dispatch path, allowing the integration tests to pass again. --- chainntnfs/txconfnotifier.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/chainntnfs/txconfnotifier.go b/chainntnfs/txconfnotifier.go index e2446a45a..11f096502 100644 --- a/chainntnfs/txconfnotifier.go +++ b/chainntnfs/txconfnotifier.go @@ -455,17 +455,26 @@ func (tcn *TxConfNotifier) ConnectTip(blockHash *chainhash.Hash, // handled correctly. for _, tx := range txns { txHash := tx.Hash() + + // Check if we have any pending notifications for this txid. If + // none are found, we can proceed to the next transaction. confSet, ok := tcn.confNotifications[*txHash] if !ok { continue } + Log.Debugf("Block contains txid=%v, constructing details", + txHash) + + details := &TxConfirmation{ + BlockHash: blockHash, + BlockHeight: blockHeight, + TxIndex: uint32(tx.Index()), + } + + confSet.details = details for _, ntfn := range confSet.ntfns { - ntfn.details = &TxConfirmation{ - BlockHash: blockHash, - BlockHeight: blockHeight, - TxIndex: uint32(tx.Index()), - } + ntfn.details = details confHeight := blockHeight + ntfn.NumConfirmations - 1 ntfnSet, exists := tcn.ntfnsByConfirmHeight[confHeight]