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.
This commit is contained in:
Conner Fromknecht 2018-09-29 13:53:24 -07:00
parent df9bb56068
commit 2dcb86bced
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7

@ -455,18 +455,27 @@ 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
}
for _, ntfn := range confSet.ntfns {
ntfn.details = &TxConfirmation{
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 = details
confHeight := blockHeight + ntfn.NumConfirmations - 1
ntfnSet, exists := tcn.ntfnsByConfirmHeight[confHeight]
if !exists {