From 1ffc3bb82e0b8186346379c53f1259dfe75f94f0 Mon Sep 17 00:00:00 2001 From: Valentine Wallace Date: Thu, 9 Aug 2018 00:05:27 -0700 Subject: [PATCH] multi: update to latest RegisterBlockEpochNtfn interface --- chainntnfs/interface_test.go | 6 +++--- contractcourt/chain_arbitrator.go | 4 ++-- contractcourt/chain_watcher_test.go | 3 ++- contractcourt/contract_resolvers.go | 4 ++-- discovery/gossiper.go | 2 +- discovery/gossiper_test.go | 3 ++- fundingmanager.go | 2 +- fundingmanager_test.go | 3 ++- htlcswitch/decayedlog.go | 2 +- htlcswitch/mock.go | 3 ++- htlcswitch/switch.go | 2 +- mock.go | 3 ++- utxonursery.go | 2 +- 13 files changed, 22 insertions(+), 17 deletions(-) diff --git a/chainntnfs/interface_test.go b/chainntnfs/interface_test.go index b279195c..d408a66a 100644 --- a/chainntnfs/interface_test.go +++ b/chainntnfs/interface_test.go @@ -526,7 +526,7 @@ func testBlockEpochNotification(miner *rpctest.Harness, // blocks we generate below. So we'll use a WaitGroup to synchronize the // test. for i := 0; i < numClients; i++ { - epochClient, err := notifier.RegisterBlockEpochNtfn() + epochClient, err := notifier.RegisterBlockEpochNtfn(nil) if err != nil { t.Fatalf("unable to register for epoch notification") } @@ -898,7 +898,7 @@ func testSpendBeforeNtfnRegistration(miner *rpctest.Harness, // We create an epoch client we can use to make sure the notifier is // caught up to the mining node's chain. - epochClient, err := notifier.RegisterBlockEpochNtfn() + epochClient, err := notifier.RegisterBlockEpochNtfn(nil) if err != nil { t.Fatalf("unable to register for block epoch: %v", err) } @@ -1082,7 +1082,7 @@ func testCancelEpochNtfn(node *rpctest.Harness, notifier chainntnfs.ChainNotifie epochClients := make([]*chainntnfs.BlockEpochEvent, numClients) for i := 0; i < numClients; i++ { - epochClient, err := notifier.RegisterBlockEpochNtfn() + epochClient, err := notifier.RegisterBlockEpochNtfn(nil) if err != nil { t.Fatalf("unable to register for epoch notification") } diff --git a/contractcourt/chain_arbitrator.go b/contractcourt/chain_arbitrator.go index 97618d3a..1e728d4e 100644 --- a/contractcourt/chain_arbitrator.go +++ b/contractcourt/chain_arbitrator.go @@ -194,7 +194,7 @@ func newActiveChannelArbitrator(channel *channeldb.OpenChannel, // // TODO(roasbeef): instead 1 block epoch that multi-plexes to the rest? // * reduces the number of goroutines - blockEpoch, err := c.cfg.Notifier.RegisterBlockEpochNtfn() + blockEpoch, err := c.cfg.Notifier.RegisterBlockEpochNtfn(nil) if err != nil { return nil, err } @@ -384,7 +384,7 @@ func (c *ChainArbitrator) Start() error { // the chain any longer, only resolve the contracts on the confirmed // commitment. for _, closeChanInfo := range closingChannels { - blockEpoch, err := c.cfg.Notifier.RegisterBlockEpochNtfn() + blockEpoch, err := c.cfg.Notifier.RegisterBlockEpochNtfn(nil) if err != nil { return err } diff --git a/contractcourt/chain_watcher_test.go b/contractcourt/chain_watcher_test.go index ab0b8f39..a8d513f7 100644 --- a/contractcourt/chain_watcher_test.go +++ b/contractcourt/chain_watcher_test.go @@ -21,7 +21,8 @@ func (m *mockNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash, _ []byte, heightHint uint32) (*chainntnfs.ConfirmationEvent, error) { return nil, nil } -func (m *mockNotifier) RegisterBlockEpochNtfn() (*chainntnfs.BlockEpochEvent, error) { +func (m *mockNotifier) RegisterBlockEpochNtfn( + bestBlock *chainntnfs.BlockEpoch) (*chainntnfs.BlockEpochEvent, error) { return &chainntnfs.BlockEpochEvent{ Epochs: make(chan *chainntnfs.BlockEpoch), Cancel: func() {}, diff --git a/contractcourt/contract_resolvers.go b/contractcourt/contract_resolvers.go index b525b5df..661ee9d0 100644 --- a/contractcourt/contract_resolvers.go +++ b/contractcourt/contract_resolvers.go @@ -855,7 +855,7 @@ func (h *htlcOutgoingContestResolver) Resolve() (ContractResolver, error) { // If we reach this point, then we can't fully act yet, so we'll await // either of our signals triggering: the HTLC expires, or we learn of // the preimage. - blockEpochs, err := h.Notifier.RegisterBlockEpochNtfn() + blockEpochs, err := h.Notifier.RegisterBlockEpochNtfn(nil) if err != nil { return nil, err } @@ -1043,7 +1043,7 @@ func (h *htlcIncomingContestResolver) Resolve() (ContractResolver, error) { // ensure the preimage can't be delivered between querying and // registering for the preimage subscription. preimageSubscription := h.PreimageDB.SubscribeUpdates() - blockEpochs, err := h.Notifier.RegisterBlockEpochNtfn() + blockEpochs, err := h.Notifier.RegisterBlockEpochNtfn(nil) if err != nil { return nil, err } diff --git a/discovery/gossiper.go b/discovery/gossiper.go index f9166683..28e09f25 100644 --- a/discovery/gossiper.go +++ b/discovery/gossiper.go @@ -408,7 +408,7 @@ func (d *AuthenticatedGossiper) Start() error { // First we register for new notifications of newly discovered blocks. // We do this immediately so we'll later be able to consume any/all // blocks which were discovered. - blockEpochs, err := d.cfg.Notifier.RegisterBlockEpochNtfn() + blockEpochs, err := d.cfg.Notifier.RegisterBlockEpochNtfn(nil) if err != nil { return err } diff --git a/discovery/gossiper_test.go b/discovery/gossiper_test.go index 44edf187..dc0ad4f7 100644 --- a/discovery/gossiper_test.go +++ b/discovery/gossiper_test.go @@ -280,7 +280,8 @@ func (m *mockNotifier) notifyBlock(hash chainhash.Hash, height uint32) { } } -func (m *mockNotifier) RegisterBlockEpochNtfn() (*chainntnfs.BlockEpochEvent, error) { +func (m *mockNotifier) RegisterBlockEpochNtfn( + bestBlock *chainntnfs.BlockEpoch) (*chainntnfs.BlockEpochEvent, error) { m.RLock() defer m.RUnlock() diff --git a/fundingmanager.go b/fundingmanager.go index a1180750..3fcce0a3 100644 --- a/fundingmanager.go +++ b/fundingmanager.go @@ -1705,7 +1705,7 @@ func (f *fundingManager) handleFundingSigned(fmsg *fundingSignedMsg) { func (f *fundingManager) waitForFundingWithTimeout(completeChan *channeldb.OpenChannel, confChan chan<- *lnwire.ShortChannelID, timeoutChan chan<- struct{}) { - epochClient, err := f.cfg.Notifier.RegisterBlockEpochNtfn() + epochClient, err := f.cfg.Notifier.RegisterBlockEpochNtfn(nil) if err != nil { fndgLog.Errorf("unable to register for epoch notification: %v", err) diff --git a/fundingmanager_test.go b/fundingmanager_test.go index 6038aaff..224e1e6e 100644 --- a/fundingmanager_test.go +++ b/fundingmanager_test.go @@ -112,7 +112,8 @@ func (m *mockNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash, }, nil } -func (m *mockNotifier) RegisterBlockEpochNtfn() (*chainntnfs.BlockEpochEvent, error) { +func (m *mockNotifier) RegisterBlockEpochNtfn( + bestBlock *chainntnfs.BlockEpoch) (*chainntnfs.BlockEpochEvent, error) { return &chainntnfs.BlockEpochEvent{ Epochs: m.epochChan, Cancel: func() {}, diff --git a/htlcswitch/decayedlog.go b/htlcswitch/decayedlog.go index 93eb0e51..d6845002 100644 --- a/htlcswitch/decayedlog.go +++ b/htlcswitch/decayedlog.go @@ -103,7 +103,7 @@ func (d *DecayedLog) Start() error { // Start garbage collector. if d.notifier != nil { - epochClient, err := d.notifier.RegisterBlockEpochNtfn() + epochClient, err := d.notifier.RegisterBlockEpochNtfn(nil) if err != nil { return fmt.Errorf("Unable to register for epoch "+ "notifications: %v", err) diff --git a/htlcswitch/mock.go b/htlcswitch/mock.go index 00795c51..64f843fc 100644 --- a/htlcswitch/mock.go +++ b/htlcswitch/mock.go @@ -790,7 +790,8 @@ func (m *mockNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash, _ []byte, numConfs uint32, heightHint uint32) (*chainntnfs.ConfirmationEvent, error) { return nil, nil } -func (m *mockNotifier) RegisterBlockEpochNtfn() (*chainntnfs.BlockEpochEvent, error) { +func (m *mockNotifier) RegisterBlockEpochNtfn( + bestBlock *chainntnfs.BlockEpoch) (*chainntnfs.BlockEpochEvent, error) { return &chainntnfs.BlockEpochEvent{ Epochs: m.epochChan, Cancel: func() {}, diff --git a/htlcswitch/switch.go b/htlcswitch/switch.go index e2ee14b0..8f19cfb3 100644 --- a/htlcswitch/switch.go +++ b/htlcswitch/switch.go @@ -1596,7 +1596,7 @@ func (s *Switch) Start() error { log.Infof("Starting HTLC Switch") - blockEpochStream, err := s.cfg.Notifier.RegisterBlockEpochNtfn() + blockEpochStream, err := s.cfg.Notifier.RegisterBlockEpochNtfn(nil) if err != nil { return err } diff --git a/mock.go b/mock.go index f41bf532..b2d4d89a 100644 --- a/mock.go +++ b/mock.go @@ -92,7 +92,8 @@ func (m *mockNotfier) RegisterConfirmationsNtfn(txid *chainhash.Hash, Confirmed: m.confChannel, }, nil } -func (m *mockNotfier) RegisterBlockEpochNtfn() (*chainntnfs.BlockEpochEvent, error) { +func (m *mockNotfier) RegisterBlockEpochNtfn( + bestBlock *chainntnfs.BlockEpoch) (*chainntnfs.BlockEpochEvent, error) { return &chainntnfs.BlockEpochEvent{ Epochs: make(chan *chainntnfs.BlockEpoch), Cancel: func() {}, diff --git a/utxonursery.go b/utxonursery.go index eba9de75..f3bf362e 100644 --- a/utxonursery.go +++ b/utxonursery.go @@ -257,7 +257,7 @@ func (u *utxoNursery) Start() error { // connected block. We register immediately on startup to ensure that // no blocks are missed while we are handling blocks that were missed // during the time the UTXO nursery was unavailable. - newBlockChan, err := u.cfg.Notifier.RegisterBlockEpochNtfn() + newBlockChan, err := u.cfg.Notifier.RegisterBlockEpochNtfn(nil) if err != nil { return err }