From: Matt Corallo Date: Wed, 31 May 2023 23:06:02 +0000 (+0000) Subject: [Java] Fix P2P graph sync when enabled in ChannelManagerConstructor X-Git-Tag: v0.0.115.1^2~10 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=0e1f0fbe3972a97b304ab19fdc7a644bf2aa5f44;p=ldk-java [Java] Fix P2P graph sync when enabled in ChannelManagerConstructor It turns out we were always using the `IgnoringMessageHandler` when initializing our `PeerManager`, ignoring all P2P graph sync messages even if `use_p2p_graph_sync` was set. --- diff --git a/src/main/java/org/ldk/batteries/ChannelManagerConstructor.java b/src/main/java/org/ldk/batteries/ChannelManagerConstructor.java index 8e4d35a6..b05bd7e0 100644 --- a/src/main/java/org/ldk/batteries/ChannelManagerConstructor.java +++ b/src/main/java/org/ldk/batteries/ChannelManagerConstructor.java @@ -279,8 +279,13 @@ public class ChannelManagerConstructor { 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(); this.peer_manager = PeerManager.of(channel_manager.as_ChannelMessageHandler(), - ignoring_handler.as_RoutingMessageHandler(), ignoring_handler.as_OnionMessageHandler(), + routing_msg_handler, ignoring_handler.as_OnionMessageHandler(), (int)(System.currentTimeMillis() / 1000), this.entropy_source.get_secure_random_bytes(), logger, ignoring_handler.as_CustomMessageHandler(), this.node_signer);