Skip to content

Commit e3dda30

Browse files
committed
Change scorer argument to BackgroundProcessor to be nullable instead of the GossipSync argument
1 parent 1c32788 commit e3dda30

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ public class ChannelManagerConstructor: NativeTypeWrapper {
237237
// if there is a graph msg handler, set its is_owned to false
238238
// self.graph_msg_handler?.cOpaqueStruct?.is_owned = false
239239

240-
self.backgroundProcessor = BackgroundProcessor(persister: self.customPersister!, event_handler: self.customEventHandler!, chain_monitor: self.chain_monitor, channel_manager: self.channelManager, gossip_sync: self.graph_msg_handler, peer_manager: self.peerManager, logger: self.logger, scorer: Option_WriteableScoreZ.none())
240+
self.backgroundProcessor = BackgroundProcessor(persister: self.customPersister!, event_handler: self.customEventHandler!, chain_monitor: self.chain_monitor, channel_manager: self.channelManager, gossip_sync: self.graph_msg_handler ?? GossipSync.none(), peer_manager: self.peerManager, logger: self.logger, scorer: self.scorer)
241241

242242
// restore it back to true
243243
// self.graph_msg_handler?.cOpaqueStruct?.is_owned = true

src/generators/opaque_struct_generator.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,24 +58,25 @@ def generate_opaque_struct(self, struct_name, struct_details, all_type_details={
5858
print(f'(opaque_struct_generator.py#constructor, warned, deprecated) {cloneability_warning}: {constructor_native_name} [{cloneability_type_message}]')
5959

6060
if constructor_native_name == 'BackgroundProcessor_start':
61-
previous_swift_argument = constructor_swift_arguments[4]
62-
previous_native_argument = constructor_native_arguments[4]
63-
new_swift_argument = 'gossip_sync: GossipSync?'
64-
new_native_argument = 'graphMessageHandler'
61+
replaced_argument_index = 7
62+
previous_swift_argument = constructor_swift_arguments[replaced_argument_index]
63+
previous_native_argument = constructor_native_arguments[replaced_argument_index]
64+
new_swift_argument = 'scorer: MultiThreadedLockableScore?'
65+
new_native_argument = 'nativeScorer'
6566
print(f'''
6667
Replacing {constructor_native_name}:
6768
Swift argument `{previous_swift_argument}` -> `{new_swift_argument}`
6869
Native argument `{previous_native_argument}` -> `{new_native_argument}`
6970
''')
7071

71-
constructor_swift_arguments[4] = new_swift_argument
72-
constructor_native_call_prep += '\nlet graphMessageHandler = gossip_sync?.cOpaqueStruct! ?? GossipSync_none()\n'
73-
constructor_post_init_anchoring = constructor_post_init_anchoring.replace('try? self.addAnchor(anchor: gossip_sync)', '''
74-
if let handler = gossip_sync {
75-
try? self.addAnchor(anchor: handler)
72+
constructor_swift_arguments[replaced_argument_index] = new_swift_argument
73+
constructor_native_call_prep += '\nlet nativeScorer = scorer?.cOpaqueStruct! ?? LDKMultiThreadedLockableScore(inner: nil, is_owned: true)\n'
74+
constructor_post_init_anchoring = constructor_post_init_anchoring.replace('try? self.addAnchor(anchor: scorer)', '''
75+
if let certainScorer = scorer {
76+
try? self.addAnchor(anchor: certainScorer)
7677
}
7778
''')
78-
constructor_native_arguments[4] = new_native_argument
79+
constructor_native_arguments[replaced_argument_index] = new_native_argument
7980

8081

8182
mutating_output_file_contents = mutating_output_file_contents.replace('public init', f'{deprecation_prefix}public init')

0 commit comments

Comments
 (0)