- 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);
+
+ final IgnoringMessageHandler ignoring_handler = IgnoringMessageHandler.of();
+ P2PGossipSync graph_msg_handler = P2PGossipSync.of(net_graph, Option_UtxoLookupZ.none(), logger);
+ RoutingMessageHandler routing_msg_handler;
+ if (use_p2p_graph_sync)
+ routing_msg_handler = graph_msg_handler.as_RoutingMessageHandler();
+ else
+ routing_msg_handler = ignoring_handler.as_RoutingMessageHandler();
+ OnionMessenger messenger = OnionMessenger.of(this.entropy_source, this.node_signer, this.logger, DefaultMessageRouter.of().as_MessageRouter(), channel_manager.as_OffersMessageHandler(), IgnoringMessageHandler.of().as_CustomOnionMessageHandler());
+ this.peer_manager = PeerManager.of(channel_manager.as_ChannelMessageHandler(),
+ routing_msg_handler, messenger.as_OnionMessageHandler(),
+ ignoring_handler.as_CustomMessageHandler(), (int)(System.currentTimeMillis() / 1000),
+ this.entropy_source.get_secure_random_bytes(), logger, this.node_signer);
+
+ try {
+ this.nio_peer_handler = new NioPeerHandler(peer_manager);
+ } catch (IOException e) {
+ throw new IllegalStateException("We should never fail to construct nio objects unless we're on a platform that cannot run LDK.");
+ }
+
+ GossipSync gossip_sync;
+ if (use_p2p_graph_sync)
+ gossip_sync = GossipSync.p2_p(graph_msg_handler);
+ else
+ gossip_sync = GossipSync.none();
+
+ Option_WriteableScoreZ writeable_score = Option_WriteableScoreZ.some(scorer.as_WriteableScore());
+
+ background_processor = BackgroundProcessor.start(Persister.new_impl(new Persister.PersisterInterface() {
+ @Override
+ public Result_NoneIOErrorZ persist_manager(ChannelManager channel_manager) {
+ event_handler.persist_manager(channel_manager.write());
+ return Result_NoneIOErrorZ.ok();
+ }
+
+ @Override
+ public Result_NoneIOErrorZ persist_graph(NetworkGraph network_graph) {
+ event_handler.persist_network_graph(network_graph.write());
+ return Result_NoneIOErrorZ.ok();
+ }
+
+ @Override
+ public Result_NoneIOErrorZ persist_scorer(WriteableScore scorer) {
+ event_handler.persist_scorer(scorer.write());
+ return Result_NoneIOErrorZ.ok();
+ }
+ }), ldk_handler, this.chain_monitor, this.channel_manager, gossip_sync, peer_manager, this.logger, writeable_score);