multi: move BackupState and RegisterChannel to Manager

This commit moves over the last two methods, `RegisterChannel` and
`BackupState` from the `Client` to the `Manager` interface. With this
change, we no longer need to pass around the individual clients around
and now only need to pass the manager around.

To do this change, all the goroutines that handle channel closes,
closable sessions needed to be moved to the Manager and so a large part
of this commit is just moving this code from the TowerClient to the
Manager.
This commit is contained in:
Elle Mouton
2023-05-16 15:22:45 +02:00
parent ab2f781b4a
commit fcfdf699e3
10 changed files with 551 additions and 471 deletions

View File

@@ -268,12 +268,8 @@ type Config struct {
// HtlcNotifier is used when creating a ChannelLink.
HtlcNotifier *htlcswitch.HtlcNotifier
// TowerClient is used by legacy channels to backup revoked states.
TowerClient wtclient.Client
// AnchorTowerClient is used by anchor channels to backup revoked
// states.
AnchorTowerClient wtclient.Client
// TowerClient is used to backup revoked states.
TowerClient wtclient.TowerClientManager
// DisconnectPeer is used to disconnect this peer if the cooperative close
// process fails.
@@ -1040,14 +1036,8 @@ func (p *Brontide) addLink(chanPoint *wire.OutPoint,
return p.cfg.ChainArb.NotifyContractUpdate(*chanPoint, update)
}
chanType := lnChan.State().ChanType
// Select the appropriate tower client based on the channel type. It's
// okay if the clients are disabled altogether and these values are nil,
// as the link will check for nilness before using either.
var towerClient htlcswitch.TowerClient
switch {
case chanType.IsTaproot():
var towerClient wtclient.TowerClientManager
if lnChan.ChanType().IsTaproot() {
// Leave the tower client as nil for now until the tower client
// has support for taproot channels.
//
@@ -1060,9 +1050,7 @@ func (p *Brontide) addLink(chanPoint *wire.OutPoint,
"are not yet taproot channel compatible",
chanPoint)
}
case chanType.HasAnchors():
towerClient = p.cfg.AnchorTowerClient
default:
} else {
towerClient = p.cfg.TowerClient
}