From f65401b439edd62727600ef0ad58e4e842a40489 Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Fri, 5 Oct 2018 02:07:55 -0700 Subject: [PATCH] chainntnfs/txnotifier: rename Register -> RegisterConf --- chainntnfs/bitcoindnotify/bitcoind.go | 2 +- chainntnfs/btcdnotify/btcd.go | 2 +- chainntnfs/neutrinonotify/neutrino.go | 2 +- chainntnfs/txnotifier.go | 15 +++++++-------- chainntnfs/txnotifier_test.go | 24 ++++++++++++------------ 5 files changed, 22 insertions(+), 23 deletions(-) diff --git a/chainntnfs/bitcoindnotify/bitcoind.go b/chainntnfs/bitcoindnotify/bitcoind.go index 4263f477..fa6812d4 100644 --- a/chainntnfs/bitcoindnotify/bitcoind.go +++ b/chainntnfs/bitcoindnotify/bitcoind.go @@ -963,7 +963,7 @@ func (b *BitcoindNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash, // for `dispatch` will be returned if we are required to perform a // manual scan for the confirmation. Otherwise the notifier will begin // watching at tip for the transaction to confirm. - dispatch, err := b.txNotifier.Register(ntfn) + dispatch, err := b.txNotifier.RegisterConf(ntfn) if err != nil { return nil, err } diff --git a/chainntnfs/btcdnotify/btcd.go b/chainntnfs/btcdnotify/btcd.go index 1c357a5e..3fe740a7 100644 --- a/chainntnfs/btcdnotify/btcd.go +++ b/chainntnfs/btcdnotify/btcd.go @@ -1023,7 +1023,7 @@ func (b *BtcdNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash, _ []byte, // for `dispatch` will be returned if we are required to perform a // manual scan for the confirmation. Otherwise the notifier will begin // watching at tip for the transaction to confirm. - dispatch, err := b.txNotifier.Register(ntfn) + dispatch, err := b.txNotifier.RegisterConf(ntfn) if err != nil { return nil, err } diff --git a/chainntnfs/neutrinonotify/neutrino.go b/chainntnfs/neutrinonotify/neutrino.go index 4c43b328..8e854442 100644 --- a/chainntnfs/neutrinonotify/neutrino.go +++ b/chainntnfs/neutrinonotify/neutrino.go @@ -932,7 +932,7 @@ func (n *NeutrinoNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash, // for `dispatch` will be returned if we are required to perform a // manual scan for the confirmation. Otherwise the notifier will begin // watching at tip for the transaction to confirm. - dispatch, err := n.txNotifier.Register(ntfn) + dispatch, err := n.txNotifier.RegisterConf(ntfn) if err != nil { return nil, err } diff --git a/chainntnfs/txnotifier.go b/chainntnfs/txnotifier.go index 2db2d7e5..f9743264 100644 --- a/chainntnfs/txnotifier.go +++ b/chainntnfs/txnotifier.go @@ -192,19 +192,18 @@ func NewTxNotifier(startHeight uint32, reorgSafetyLimit uint32, } } -// Register handles a new notification request. The client will be notified when -// the transaction gets a sufficient number of confirmations on the blockchain. -// The registration succeeds if no error is returned. If the returned -// HistoricalConfDispatch is non-nil, the caller is responsible for attempting -// to manually rescan blocks for the txid between the start and end heights. +// RegisterConf handles a new notification request. The client will be notified +// when the transaction gets a sufficient number of confirmations on the +// blockchain. The registration succeeds if no error is returned. If the +// returned HistoricalConfDispatch is non-nil, the caller is responsible for +// attempting to manually rescan blocks for the txid between the start and end +// heights. // // NOTE: If the transaction has already been included in a block on the chain, // the confirmation details must be provided with the UpdateConfDetails method, // otherwise we will wait for the transaction to confirm even though it already // has. -func (n *TxNotifier) Register( - ntfn *ConfNtfn) (*HistoricalConfDispatch, error) { - +func (n *TxNotifier) RegisterConf(ntfn *ConfNtfn) (*HistoricalConfDispatch, error) { select { case <-n.quit: return nil, ErrTxNotifierExiting diff --git a/chainntnfs/txnotifier_test.go b/chainntnfs/txnotifier_test.go index ded8f9ee..6675709b 100644 --- a/chainntnfs/txnotifier_test.go +++ b/chainntnfs/txnotifier_test.go @@ -124,7 +124,7 @@ func TestTxConfFutureDispatch(t *testing.T) { NumConfirmations: tx1NumConfs, Event: chainntnfs.NewConfirmationEvent(tx1NumConfs), } - if _, err := n.Register(&ntfn1); err != nil { + if _, err := n.RegisterConf(&ntfn1); err != nil { t.Fatalf("unable to register ntfn: %v", err) } @@ -134,7 +134,7 @@ func TestTxConfFutureDispatch(t *testing.T) { NumConfirmations: tx2NumConfs, Event: chainntnfs.NewConfirmationEvent(tx2NumConfs), } - if _, err := n.Register(&ntfn2); err != nil { + if _, err := n.RegisterConf(&ntfn2); err != nil { t.Fatalf("unable to register ntfn: %v", err) } @@ -297,7 +297,7 @@ func TestTxConfHistoricalDispatch(t *testing.T) { NumConfirmations: tx1NumConfs, Event: chainntnfs.NewConfirmationEvent(tx1NumConfs), } - if _, err := n.Register(&ntfn1); err != nil { + if _, err := n.RegisterConf(&ntfn1); err != nil { t.Fatalf("unable to register ntfn: %v", err) } @@ -308,7 +308,7 @@ func TestTxConfHistoricalDispatch(t *testing.T) { NumConfirmations: tx2NumConfs, Event: chainntnfs.NewConfirmationEvent(tx2NumConfs), } - if _, err := n.Register(&ntfn2); err != nil { + if _, err := n.RegisterConf(&ntfn2); err != nil { t.Fatalf("unable to register ntfn: %v", err) } @@ -447,7 +447,7 @@ func TestTxConfChainReorg(t *testing.T) { NumConfirmations: tx1NumConfs, Event: chainntnfs.NewConfirmationEvent(tx1NumConfs), } - if _, err := n.Register(&ntfn1); err != nil { + if _, err := n.RegisterConf(&ntfn1); err != nil { t.Fatalf("unable to register ntfn: %v", err) } @@ -462,7 +462,7 @@ func TestTxConfChainReorg(t *testing.T) { NumConfirmations: tx2NumConfs, Event: chainntnfs.NewConfirmationEvent(tx2NumConfs), } - if _, err := n.Register(&ntfn2); err != nil { + if _, err := n.RegisterConf(&ntfn2); err != nil { t.Fatalf("unable to register ntfn: %v", err) } @@ -477,7 +477,7 @@ func TestTxConfChainReorg(t *testing.T) { NumConfirmations: tx3NumConfs, Event: chainntnfs.NewConfirmationEvent(tx3NumConfs), } - if _, err := n.Register(&ntfn3); err != nil { + if _, err := n.RegisterConf(&ntfn3); err != nil { t.Fatalf("unable to register ntfn: %v", err) } @@ -723,14 +723,14 @@ func TestTxConfHeightHintCache(t *testing.T) { Event: chainntnfs.NewConfirmationEvent(2), } - if _, err := n.Register(ntfn1); err != nil { + if _, err := n.RegisterConf(ntfn1); err != nil { t.Fatalf("unable to register tx1: %v", err) } - if _, err := n.Register(ntfn2); err != nil { + if _, err := n.RegisterConf(ntfn2); err != nil { t.Fatalf("unable to register tx2: %v", err) } - // Both transactions should not have a height hint set, as Register + // Both transactions should not have a height hint set, as RegisterConf // should not alter the cache state. _, err := hintCache.QueryConfirmHint(tx1Hash) if err != chainntnfs.ErrConfirmHintNotFound { @@ -903,7 +903,7 @@ func TestTxConfTearDown(t *testing.T) { NumConfirmations: 1, Event: chainntnfs.NewConfirmationEvent(1), } - if _, err := n.Register(&ntfn1); err != nil { + if _, err := n.RegisterConf(&ntfn1); err != nil { t.Fatalf("unable to register ntfn: %v", err) } if err := n.UpdateConfDetails(*ntfn1.TxID, nil); err != nil { @@ -916,7 +916,7 @@ func TestTxConfTearDown(t *testing.T) { NumConfirmations: 2, Event: chainntnfs.NewConfirmationEvent(2), } - if _, err := n.Register(&ntfn2); err != nil { + if _, err := n.RegisterConf(&ntfn2); err != nil { t.Fatalf("unable to register ntfn: %v", err) } if err := n.UpdateConfDetails(*ntfn2.TxID, nil); err != nil {