]> git.bitcoin.ninja Git - ldk-java/commitdiff
[Java] Fix P2P graph sync when enabled in ChannelManagerConstructor
authorMatt Corallo <git@bluematt.me>
Wed, 31 May 2023 23:06:02 +0000 (23:06 +0000)
committerMatt Corallo <git@bluematt.me>
Thu, 1 Jun 2023 20:23:10 +0000 (20:23 +0000)
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.

src/main/java/org/ldk/batteries/ChannelManagerConstructor.java

index 8e4d35a621af26f69fa600337808a8188edc4393..b05bd7e050298e290007f39812b0107072a94bd1 100644 (file)
@@ -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);