chainntnfs+chainreg: add interface MempoolWatcher

This commit adds the interface `MempoolWatcher` and uses it in the chain
registry.
This commit is contained in:
yyforyongyu
2023-04-03 21:21:07 +08:00
parent ad5e798392
commit e81d62fc70
4 changed files with 34 additions and 2 deletions

View File

@@ -182,6 +182,10 @@ type PartialChainControl struct {
// interested in.
ChainNotifier chainntnfs.ChainNotifier
// MempoolNotifier is used to watch for spending events happened in
// mempool.
MempoolNotifier chainntnfs.MempoolWatcher
// ChainView is used in the router for maintaining an up-to-date graph.
ChainView chainview.FilteredChainView
@@ -433,10 +437,14 @@ func NewPartialChainControl(cfg *Config) (*PartialChainControl, func(), error) {
"bitcoind: %v", err)
}
cc.ChainNotifier = bitcoindnotify.New(
chainNotifier := bitcoindnotify.New(
bitcoindConn, cfg.ActiveNetParams.Params, hintCache,
hintCache, cfg.BlockCache,
)
cc.ChainNotifier = chainNotifier
cc.MempoolNotifier = chainNotifier
cc.ChainView = chainview.NewBitcoindFilteredChainView(
bitcoindConn, cfg.BlockCache,
)
@@ -655,7 +663,8 @@ func NewPartialChainControl(cfg *Config) (*PartialChainControl, func(), error) {
DisableConnectOnNew: true,
DisableAutoReconnect: false,
}
cc.ChainNotifier, err = btcdnotify.New(
chainNotifier, err := btcdnotify.New(
rpcConfig, cfg.ActiveNetParams.Params, hintCache,
hintCache, cfg.BlockCache,
)
@@ -663,6 +672,9 @@ func NewPartialChainControl(cfg *Config) (*PartialChainControl, func(), error) {
return nil, nil, err
}
cc.ChainNotifier = chainNotifier
cc.MempoolNotifier = chainNotifier
// Finally, we'll create an instance of the default chain view
// to be used within the routing layer.
cc.ChainView, err = chainview.NewBtcdFilteredChainView(