Skip to content

Commit 6fb81b2

Browse files
committed
chainntnfs: patch debug logs and fix StartHeight
Make sure we patch the `StartHeight` for btcd notifier.
1 parent 35102e7 commit 6fb81b2

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

chainntnfs/bitcoindnotify/bitcoind.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -833,8 +833,12 @@ func (b *BitcoindNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint,
833833
return nil, err
834834
}
835835

836-
if uint32(blockHeight) > ntfn.HistoricalDispatch.StartHeight {
837-
ntfn.HistoricalDispatch.StartHeight = uint32(blockHeight)
836+
spentHeight := uint32(blockHeight)
837+
chainntnfs.Log.Debugf("Outpoint(%v) has spent at height %v",
838+
outpoint, spentHeight)
839+
840+
if spentHeight > ntfn.HistoricalDispatch.StartHeight {
841+
ntfn.HistoricalDispatch.StartHeight = spentHeight
838842
}
839843
}
840844

chainntnfs/btcdnotify/btcd.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -933,15 +933,21 @@ func (b *BtcdNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint,
933933
"block %v: %v", blockHash, err)
934934
}
935935

936-
if uint32(blockHeader.Height) > ntfn.HistoricalDispatch.StartHeight {
936+
spentHeight := uint32(blockHeader.Height)
937+
chainntnfs.Log.Debugf("Outpoint(%v) has spent at height %v",
938+
outpoint, spentHeight)
939+
940+
if spentHeight > ntfn.HistoricalDispatch.StartHeight {
937941
startHash, err = b.chainConn.GetBlockHash(
938-
int64(blockHeader.Height),
942+
int64(spentHeight),
939943
)
940944
if err != nil {
941945
return nil, fmt.Errorf("unable to get block "+
942946
"hash for height %d: %v",
943947
blockHeader.Height, err)
944948
}
949+
950+
ntfn.HistoricalDispatch.StartHeight = spentHeight
945951
}
946952
}
947953

0 commit comments

Comments
 (0)