wtclient+server: introduce tower client Manager
Introduce a wtclient `Manager` which handles tower clients. It indexes clients by the policy used. The policy field is thus removed from the `Config` struct which configures the Manager and is instead added to a new `towerClientCfg` which configures a specific client managed by the manager. For now, only the `NewClient` method is added to the Manager. It can be used to construct a new `TowerClient`. The Manager currently does notthing with the clients added to it.
This commit is contained in:
4 files changed
+204
-153
No files matched your search
@@ -282,6 +282,8 @@ type server struct {
|
||||
|
||||
sphinx *hop.OnionProcessor
|
||||
|
||||
towerClientMgr *wtclient.Manager
|
||||
|
||||
towerClient wtclient.Client
|
||||
|
||||
anchorTowerClient wtclient.Client
|
||||
@@ -1548,7 +1550,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
|
||||
fetchClosedChannel := s.chanStateDB.FetchClosedChannelForID
|
||||
|
||||
s.towerClient, err = wtclient.New(&wtclient.Config{
|
||||
s.towerClientMgr, err = wtclient.NewManager(&wtclient.Config{
|
||||
FetchClosedChannel: fetchClosedChannel,
|
||||
BuildBreachRetribution: buildBreachRetribution,
|
||||
SessionCloseRange: cfg.WtClient.SessionCloseRange,
|
||||
@@ -1565,7 +1567,6 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
Dial: cfg.net.Dial,
|
||||
AuthDial: authDial,
|
||||
DB: dbs.TowerClientDB,
|
||||
Policy: policy,
|
||||
ChainHash: *s.cfg.ActiveNetParams.GenesisHash,
|
||||
MinBackoff: 10 * time.Second,
|
||||
MaxBackoff: 5 * time.Minute,
|
||||
@@ -1575,35 +1576,22 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Register a legacy tower client.
|
||||
s.towerClient, err = s.towerClientMgr.NewClient(policy)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Copy the policy for legacy channels and set the blob flag
|
||||
// signalling support for anchor channels.
|
||||
anchorPolicy := policy
|
||||
anchorPolicy.TxPolicy.BlobType |=
|
||||
blob.Type(blob.FlagAnchorChannel)
|
||||
|
||||
s.anchorTowerClient, err = wtclient.New(&wtclient.Config{
|
||||
FetchClosedChannel: fetchClosedChannel,
|
||||
BuildBreachRetribution: buildBreachRetribution,
|
||||
SessionCloseRange: cfg.WtClient.SessionCloseRange,
|
||||
ChainNotifier: s.cc.ChainNotifier,
|
||||
SubscribeChannelEvents: func() (subscribe.Subscription,
|
||||
error) {
|
||||
|
||||
return s.channelNotifier.
|
||||
SubscribeChannelEvents()
|
||||
},
|
||||
Signer: cc.Wallet.Cfg.Signer,
|
||||
NewAddress: newSweepPkScriptGen(cc.Wallet),
|
||||
SecretKeyRing: s.cc.KeyRing,
|
||||
Dial: cfg.net.Dial,
|
||||
AuthDial: authDial,
|
||||
DB: dbs.TowerClientDB,
|
||||
Policy: anchorPolicy,
|
||||
ChainHash: *s.cfg.ActiveNetParams.GenesisHash,
|
||||
MinBackoff: 10 * time.Second,
|
||||
MaxBackoff: 5 * time.Minute,
|
||||
MaxTasksInMemQueue: cfg.WtClient.MaxTasksInMemQueue,
|
||||
})
|
||||
// Register an anchors tower client.
|
||||
s.anchorTowerClient, err = s.towerClientMgr.NewClient(
|
||||
anchorPolicy,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user