chainntnfs: add height hint caches to chain notifiers
This commit is contained in:
10 files changed
+138
-30
No files matched your search
@@ -83,6 +83,16 @@ type BtcdNotifier struct {
|
||||
chainUpdates *chainntnfs.ConcurrentQueue
|
||||
txUpdates *chainntnfs.ConcurrentQueue
|
||||
|
||||
// spendHintCache is a cache used to query and update the latest height
|
||||
// hints for an outpoint. Each height hint represents the earliest
|
||||
// height at which the outpoint could have been spent within the chain.
|
||||
spendHintCache chainntnfs.SpendHintCache
|
||||
|
||||
// confirmHintCache is a cache used to query the latest height hints for
|
||||
// a transaction. Each height hint represents the earliest height at
|
||||
// which the transaction could have confirmed within the chain.
|
||||
confirmHintCache chainntnfs.ConfirmHintCache
|
||||
|
||||
wg sync.WaitGroup
|
||||
quit chan struct{}
|
||||
}
|
||||
@@ -93,7 +103,9 @@ var _ chainntnfs.ChainNotifier = (*BtcdNotifier)(nil)
|
||||
// New returns a new BtcdNotifier instance. This function assumes the btcd node
|
||||
// detailed in the passed configuration is already running, and willing to
|
||||
// accept new websockets clients.
|
||||
func New(config *rpcclient.ConnConfig) (*BtcdNotifier, error) {
|
||||
func New(config *rpcclient.ConnConfig, spendHintCache chainntnfs.SpendHintCache,
|
||||
confirmHintCache chainntnfs.ConfirmHintCache) (*BtcdNotifier, error) {
|
||||
|
||||
notifier := &BtcdNotifier{
|
||||
notificationCancels: make(chan interface{}),
|
||||
notificationRegistry: make(chan interface{}),
|
||||
@@ -105,6 +117,9 @@ func New(config *rpcclient.ConnConfig) (*BtcdNotifier, error) {
|
||||
chainUpdates: chainntnfs.NewConcurrentQueue(10),
|
||||
txUpdates: chainntnfs.NewConcurrentQueue(10),
|
||||
|
||||
spendHintCache: spendHintCache,
|
||||
confirmHintCache: confirmHintCache,
|
||||
|
||||
quit: make(chan struct{}),
|
||||
}
|
||||
|
||||
@@ -150,7 +165,8 @@ func (b *BtcdNotifier) Start() error {
|
||||
}
|
||||
|
||||
b.txConfNotifier = chainntnfs.NewTxConfNotifier(
|
||||
uint32(currentHeight), reorgSafetyLimit)
|
||||
uint32(currentHeight), reorgSafetyLimit, b.confirmHintCache,
|
||||
)
|
||||
|
||||
b.bestBlock = chainntnfs.BlockEpoch{
|
||||
Height: currentHeight,
|
||||
|
||||
Reference in new issue
Block a user