From 5405028948e8ac05d3b4dee1edc5ef1830503e0c Mon Sep 17 00:00:00 2001 From: Valentine Wallace Date: Wed, 16 Jan 2019 14:35:30 -0800 Subject: [PATCH] fundingmanager: inform ChannelNotifier about newly open channels. --- fundingmanager.go | 8 ++++++++ fundingmanager_test.go | 5 +++-- server.go | 7 ++++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/fundingmanager.go b/fundingmanager.go index 2babcaad..1eb45b65 100644 --- a/fundingmanager.go +++ b/fundingmanager.go @@ -333,6 +333,10 @@ type fundingConfig struct { // flood us with very small channels that would never really be usable // due to fees. MinChanSize btcutil.Amount + + // NotifyOpenChannelEvent informs the ChannelNotifier when channels + // transition from pending open to open. + NotifyOpenChannelEvent func(wire.OutPoint) } // fundingManager acts as an orchestrator/bridge between the wallet's @@ -1939,6 +1943,10 @@ func (f *fundingManager) waitForFundingConfirmation(completeChan *channeldb.Open return } + // Inform the ChannelNotifier that the channel has transitioned from + // pending open to open. + f.cfg.NotifyOpenChannelEvent(completeChan.FundingOutpoint) + // TODO(roasbeef): ideally persistent state update for chan above // should be abstracted diff --git a/fundingmanager_test.go b/fundingmanager_test.go index 6231ff4d..22d0d710 100644 --- a/fundingmanager_test.go +++ b/fundingmanager_test.go @@ -353,8 +353,9 @@ func createTestFundingManager(t *testing.T, privKey *btcec.PrivateKey, publTxChan <- txn return nil }, - ZombieSweeperInterval: 1 * time.Hour, - ReservationTimeout: 1 * time.Nanosecond, + ZombieSweeperInterval: 1 * time.Hour, + ReservationTimeout: 1 * time.Nanosecond, + NotifyOpenChannelEvent: func(wire.OutPoint) {}, }) if err != nil { t.Fatalf("failed creating fundingManager: %v", err) diff --git a/server.go b/server.go index fa563762..2d32239c 100644 --- a/server.go +++ b/server.go @@ -927,9 +927,10 @@ func newServer(listenAddrs []net.Addr, chanDB *channeldb.DB, cc *chainControl, // channel bandwidth. return uint16(input.MaxHTLCNumber / 2) }, - ZombieSweeperInterval: 1 * time.Minute, - ReservationTimeout: 10 * time.Minute, - MinChanSize: btcutil.Amount(cfg.MinChanSize), + ZombieSweeperInterval: 1 * time.Minute, + ReservationTimeout: 10 * time.Minute, + MinChanSize: btcutil.Amount(cfg.MinChanSize), + NotifyOpenChannelEvent: s.channelNotifier.NotifyOpenChannelEvent, }) if err != nil { return nil, err