Skip to content

Commit c3b7c15

Browse files
committed
Allow to specify retry strategy for InvoicePayer
1 parent 0c24fb0 commit c3b7c15

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

ci/LDKSwift/Sources/LDKSwift/batteries/ChannelManagerConstructor.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public class ChannelManagerConstructor: NativeTypeWrapper {
4040
fileprivate var scorer: MultiThreadedLockableScore?
4141
fileprivate let keysInterface: KeysInterface!
4242
public private(set) var payer: InvoicePayer?
43+
fileprivate var payerRetries: Retry!
4344
public let peerManager: PeerManager
4445
private var tcpPeerHandler: TCPPeerHandler?
4546

@@ -54,7 +55,7 @@ public class ChannelManagerConstructor: NativeTypeWrapper {
5455
private let chain_monitor: ChainMonitor
5556

5657

57-
public init(channelManagerSerialized: [UInt8], channelMonitorsSerialized: [[UInt8]], keysInterface: KeysInterface, feeEstimator: FeeEstimator, chainMonitor: ChainMonitor, filter: Filter?, netGraphSerialized: [UInt8]?, txBroadcaster: BroadcasterInterface, logger: Logger, enableP2PGossip: Bool = false, userConfig: UserConfig = UserConfig.initWithDefault()) throws {
58+
public init(channelManagerSerialized: [UInt8], channelMonitorsSerialized: [[UInt8]], keysInterface: KeysInterface, feeEstimator: FeeEstimator, chainMonitor: ChainMonitor, filter: Filter?, netGraphSerialized: [UInt8]?, txBroadcaster: BroadcasterInterface, logger: Logger, enableP2PGossip: Bool = false, userConfig: UserConfig = UserConfig.initWithDefault(), payerRetries: Retry = Retry.initWithAttempts(a: UInt(3))) throws {
5859

5960
var monitors: [ChannelMonitor] = []
6061
self.channel_monitors = []
@@ -98,6 +99,7 @@ public class ChannelManagerConstructor: NativeTypeWrapper {
9899
self.channel_manager_latest_block_hash = latestBlockHash
99100
self.chain_monitor = chainMonitor
100101
self.keysInterface = keysInterface
102+
self.payerRetries = payerRetries
101103
self.logger = logger
102104

103105
let random_data = keysInterface.getSecureRandomBytes();
@@ -142,14 +144,15 @@ public class ChannelManagerConstructor: NativeTypeWrapper {
142144
/**
143145
* Constructs a channel manager from the given interface implementations
144146
*/
145-
public init(network: Network, userConfig: UserConfig, currentBlockchainTipHash: [UInt8], currentBlockchainTipHeight: UInt32, keysInterface: KeysInterface, feeEstimator: FeeEstimator, chainMonitor: ChainMonitor, netGraph: NetworkGraph?, txBroadcaster: BroadcasterInterface, logger: Logger, enableP2PGossip: Bool = false) {
147+
public init(network: Network, userConfig: UserConfig, currentBlockchainTipHash: [UInt8], currentBlockchainTipHeight: UInt32, keysInterface: KeysInterface, feeEstimator: FeeEstimator, chainMonitor: ChainMonitor, netGraph: NetworkGraph?, txBroadcaster: BroadcasterInterface, logger: Logger, enableP2PGossip: Bool = false, payerRetries: Retry = Retry.initWithAttempts(a: UInt(3))) {
146148

147149
self.channel_monitors = []
148150
self.channel_manager_latest_block_hash = nil
149151
self.chain_monitor = chainMonitor
150152
let block = BestBlock(blockHash: currentBlockchainTipHash, height: currentBlockchainTipHeight)
151153
let chainParameters = ChainParameters(networkArg: network, bestBlockArg: block)
152154
self.channelManager = ChannelManager(feeEst: feeEstimator, chainMonitor: chainMonitor.asWatch(), txBroadcaster: txBroadcaster, logger: logger, keysManager: keysInterface, config: userConfig, params: chainParameters)
155+
self.payerRetries = payerRetries
153156
self.logger = logger
154157

155158
self.keysInterface = keysInterface
@@ -214,7 +217,7 @@ public class ChannelManagerConstructor: NativeTypeWrapper {
214217
// either dangle router, or set is_owned to false
215218
// scorer.cType!.is_owned = false
216219
// router.cType!.is_owned = false
217-
self.payer = InvoicePayer(payer: self.channelManager.asPayer(), router: router.asRouter(), logger: self.logger, eventHandler: self.customEventHandler!, retry: Retry.initWithAttempts(a: UInt(3)))
220+
self.payer = InvoicePayer(payer: self.channelManager.asPayer(), router: router.asRouter(), logger: self.logger, eventHandler: self.customEventHandler!, retry: self.payerRetries)
218221
// router.cType!.is_owned = true
219222
self.customEventHandler = self.payer!.asEventHandler()
220223
}

0 commit comments

Comments
 (0)