From 0e1f0fbe3972a97b304ab19fdc7a644bf2aa5f44 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Wed, 31 May 2023 23:06:02 +0000 Subject: [PATCH] [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. --- .../java/org/ldk/batteries/ChannelManagerConstructor.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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); -- 2.39.5