multi: move breach arbiter and utxo nursery into contractcourt package

In this commit, we take an initial step towards converting the existing
breach arbiter and utxo nursery logic into contract resolvers by moving
the files as is, into the `contractcourt` pacakge.

This commit is primarily move only, though we had to massage some
interfaces and config names along the way to make things compile and the
tests run properly.
This commit is contained in:
Olaoluwa Osuntokun
2021-09-13 19:00:36 -07:00
parent be2566cf26
commit 7bde1662e2
15 changed files with 388 additions and 348 deletions

View File

@ -238,7 +238,7 @@ type server struct {
witnessBeacon contractcourt.WitnessBeacon
breachArbiter *breachArbiter
breachArbiter *contractcourt.BreachArbiter
missionControl *routing.MissionControl
@ -250,7 +250,7 @@ type server struct {
localChanMgr *localchans.Manager
utxoNursery *utxoNursery
utxoNursery *contractcourt.UtxoNursery
sweeper *sweep.UtxoSweeper
@ -848,7 +848,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
FetchChannel: s.chanStateDB.FetchChannel,
}
utxnStore, err := newNurseryStore(
utxnStore, err := contractcourt.NewNurseryStore(
s.cfg.ActiveNetParams.GenesisHash, dbs.chanStateDB,
)
if err != nil {
@ -884,7 +884,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
FeeRateBucketSize: sweep.DefaultFeeRateBucketSize,
})
s.utxoNursery = newUtxoNursery(&NurseryConfig{
s.utxoNursery = contractcourt.NewUtxoNursery(&contractcourt.NurseryConfig{
ChainIO: cc.ChainIO,
ConfDepth: 1,
FetchClosedChannels: dbs.chanStateDB.FetchClosedChannels,
@ -897,7 +897,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
// Construct a closure that wraps the htlcswitch's CloseLink method.
closeLink := func(chanPoint *wire.OutPoint,
closureType htlcswitch.ChannelCloseType) {
closureType contractcourt.ChannelCloseType) {
// TODO(conner): Properly respect the update and error channels
// returned by CloseLink.
@ -909,7 +909,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
// We will use the following channel to reliably hand off contract
// breach events from the ChannelArbitrator to the breachArbiter,
contractBreaches := make(chan *ContractBreachEvent, 1)
contractBreaches := make(chan *contractcourt.ContractBreachEvent, 1)
s.chainArb = contractcourt.NewChainArbitrator(contractcourt.ChainArbitratorConfig{
ChainHash: *s.cfg.ActiveNetParams.GenesisHash,
@ -976,7 +976,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
finalErr <- markClosed()
}
event := &ContractBreachEvent{
event := &contractcourt.ContractBreachEvent{
ChanPoint: chanPoint,
ProcessACK: processACK,
BreachRetribution: breachRet,
@ -1012,7 +1012,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
Clock: clock.NewDefaultClock(),
}, dbs.chanStateDB)
s.breachArbiter = newBreachArbiter(&BreachConfig{
s.breachArbiter = contractcourt.NewBreachArbiter(&contractcourt.BreachConfig{
CloseLink: closeLink,
DB: dbs.chanStateDB,
Estimator: s.cc.FeeEstimator,
@ -1021,7 +1021,9 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
PublishTransaction: cc.Wallet.PublishTransaction,
ContractBreaches: contractBreaches,
Signer: cc.Wallet.Cfg.Signer,
Store: newRetributionStore(dbs.chanStateDB),
Store: contractcourt.NewRetributionStore(
dbs.chanStateDB,
),
})
// Select the configuration and furnding parameters for Bitcoin or