chainntnfs/btcdnotify: add additional logic when dispatching ntfns

This commit is contained in:
Olaoluwa Osuntokun 2017-12-07 19:09:45 -08:00
parent 36c299c1d8
commit 839ce0689e
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21

@ -445,6 +445,8 @@ func (b *BtcdNotifier) attemptHistoricalDispatch(
// dispatch it immediately after obtaining for information w.r.t // dispatch it immediately after obtaining for information w.r.t
// exactly *when* if got all its confirmations. // exactly *when* if got all its confirmations.
if uint32(tx.Confirmations) >= msg.numConfirmations { if uint32(tx.Confirmations) >= msg.numConfirmations {
chainntnfs.Log.Infof("Dispatching %v conf notification",
msg.numConfirmations)
msg.finConf <- confDetails msg.finConf <- confDetails
return true return true
} }
@ -513,8 +515,8 @@ func (b *BtcdNotifier) notifyConfs(newBlockHeight int32) {
// is eligible until there are no more eligible entries. // is eligible until there are no more eligible entries.
nextConf := heap.Pop(b.confHeap).(*confEntry) nextConf := heap.Pop(b.confHeap).(*confEntry)
for nextConf.triggerHeight <= uint32(newBlockHeight) { for nextConf.triggerHeight <= uint32(newBlockHeight) {
// TODO(roasbeef): shake out possible of by one in height calc chainntnfs.Log.Infof("Dispatching %v conf notification, "+
// for historical dispatches "height=%v", nextConf.numConfirmations, newBlockHeight)
nextConf.finConf <- nextConf.initialConfDetails nextConf.finConf <- nextConf.initialConfDetails
if b.confHeap.Len() == 0 { if b.confHeap.Len() == 0 {