chainntnfs/txconfnotifier: query conf hint in Register

This commit is contained in:
Conner Fromknecht 2018-08-24 20:09:11 -07:00
parent a1756b0b1b
commit 8b8007bb5a
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7

@ -35,6 +35,11 @@ type ConfNtfn struct {
// be sent over.
Event *ConfirmationEvent
// HeightHint is the minimum height in the chain that we expect to find
// this txid. This value will be overridden by the height hint cache if
// a more recent value is available.
HeightHint uint32
// details describes the transaction's position is the blockchain. May be
// nil for unconfirmed transactions.
details *TxConfirmation
@ -172,6 +177,17 @@ func (tcn *TxConfNotifier) Register(ntfn *ConfNtfn) (bool, uint32, error) {
default:
}
// Before proceeding to register the notification, we'll query our
// height hint cache to determine whether a better one exists.
hint, err := tcn.hintCache.QueryConfirmHint(*ntfn.TxID)
if err == nil {
if hint > ntfn.HeightHint {
Log.Debugf("Using height hint %d retrieved "+
"from cache for %v", hint, *ntfn.TxID)
ntfn.HeightHint = hint
}
}
tcn.Lock()
defer tcn.Unlock()