- background_processor = BackgroundProcessor.start(org.ldk.structs.ChannelManagerPersister.new_impl(channel_manager -> {
- event_handler.persist_manager(channel_manager.write());
- return Result_NoneErrorZ.ok();
- }), org.ldk.structs.EventHandler.new_impl(event_handler::handle_event),
- this.chain_monitor, this.channel_manager, this.router, this.peer_manager, this.logger);
+ org.ldk.structs.EventHandler ldk_handler = org.ldk.structs.EventHandler.new_impl(event_handler::handle_event);
+ if (this.net_graph != null && scorer != null) {
+ Router router = DefaultRouter.of(net_graph, logger, router_rand_bytes, scorer.as_LockableScore()).as_Router();
+ this.payer = InvoicePayer.of(this.channel_manager.as_Payer(), router, this.logger, ldk_handler, Retry.attempts(3));
+ ldk_handler = this.payer.as_EventHandler();
+ }
+
+ GossipSync gossip_sync;
+ if (this.graph_msg_handler == null)
+ gossip_sync = GossipSync.none();
+ else
+ gossip_sync = GossipSync.p2_p(this.graph_msg_handler);
+
+ Option_WriteableScoreZ writeable_score;
+ if (scorer != null)
+ writeable_score = Option_WriteableScoreZ.some(scorer.as_WriteableScore());
+ else
+ writeable_score = Option_WriteableScoreZ.none();
+
+ background_processor = BackgroundProcessor.start(Persister.new_impl(new Persister.PersisterInterface() {
+ @Override
+ public Result_NoneErrorZ persist_manager(ChannelManager channel_manager) {
+ event_handler.persist_manager(channel_manager.write());
+ return Result_NoneErrorZ.ok();
+ }
+
+ @Override
+ public Result_NoneErrorZ persist_graph(NetworkGraph network_graph) {
+ event_handler.persist_network_graph(network_graph.write());
+ return Result_NoneErrorZ.ok();
+ }
+
+ @Override
+ public Result_NoneErrorZ persist_scorer(WriteableScore scorer) {
+ event_handler.persist_scorer(scorer.write());
+ return Result_NoneErrorZ.ok();
+ }
+ }), ldk_handler, this.chain_monitor, this.channel_manager, gossip_sync, this.peer_manager, this.logger, writeable_score);