mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-10-06 18:33:57 +02:00
multi: query circuit map inside contractcourt
This commit adds a new config method `QueryIncomingCircuit` that can be used to query the payment's incoming circuit for giving its outgoing circuit key.
This commit is contained in:
21
server.go
21
server.go
@@ -1134,6 +1134,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
},
|
||||
)
|
||||
|
||||
//nolint:lll
|
||||
s.chainArb = contractcourt.NewChainArbitrator(contractcourt.ChainArbitratorConfig{
|
||||
ChainHash: *s.cfg.ActiveNetParams.GenesisHash,
|
||||
IncomingBroadcastDelta: lncfg.DefaultIncomingBroadcastDelta,
|
||||
@@ -1224,10 +1225,26 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
PaymentsExpirationGracePeriod: cfg.PaymentsExpirationGracePeriod,
|
||||
IsForwardedHTLC: s.htlcSwitch.IsForwardedHTLC,
|
||||
Clock: clock.NewDefaultClock(),
|
||||
SubscribeBreachComplete: s.breachArbitrator.SubscribeBreachComplete, //nolint:lll
|
||||
PutFinalHtlcOutcome: s.chanStateDB.PutOnchainFinalHtlcOutcome, //nolint: lll
|
||||
SubscribeBreachComplete: s.breachArbitrator.SubscribeBreachComplete,
|
||||
PutFinalHtlcOutcome: s.chanStateDB.PutOnchainFinalHtlcOutcome,
|
||||
HtlcNotifier: s.htlcNotifier,
|
||||
Budget: *s.cfg.Sweeper.Budget,
|
||||
|
||||
// TODO(yy): remove this hack once PaymentCircuit is interfaced.
|
||||
QueryIncomingCircuit: func(
|
||||
circuit models.CircuitKey) *models.CircuitKey {
|
||||
|
||||
// Get the circuit map.
|
||||
circuits := s.htlcSwitch.CircuitLookup()
|
||||
|
||||
// Lookup the outgoing circuit.
|
||||
pc := circuits.LookupOpenCircuit(circuit)
|
||||
if pc == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return &pc.Incoming
|
||||
},
|
||||
}, dbs.ChanStateDB)
|
||||
|
||||
// Select the configuration and funding parameters for Bitcoin.
|
||||
|
Reference in New Issue
Block a user