chainntnfs/txconfnotifier: query conf hint in Register
This commit is contained in:
parent
a1756b0b1b
commit
8b8007bb5a
@ -35,6 +35,11 @@ type ConfNtfn struct {
|
|||||||
// be sent over.
|
// be sent over.
|
||||||
Event *ConfirmationEvent
|
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
|
// details describes the transaction's position is the blockchain. May be
|
||||||
// nil for unconfirmed transactions.
|
// nil for unconfirmed transactions.
|
||||||
details *TxConfirmation
|
details *TxConfirmation
|
||||||
@ -172,6 +177,17 @@ func (tcn *TxConfNotifier) Register(ntfn *ConfNtfn) (bool, uint32, error) {
|
|||||||
default:
|
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()
|
tcn.Lock()
|
||||||
defer tcn.Unlock()
|
defer tcn.Unlock()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user