]> git.bitcoin.ninja Git - ldk-java/commitdiff
Drop dup PeerManager tiemr_tick_occurred calls from NioPeerHandler
authorMatt Corallo <git@bluematt.me>
Sat, 4 Sep 2021 19:46:46 +0000 (19:46 +0000)
committerMatt Corallo <git@bluematt.me>
Sat, 4 Sep 2021 20:41:37 +0000 (20:41 +0000)
We call PeerManager's timer_tick_occurred in the
lightning-background-processor crate, initialized from the
ChannelManagerConstructor. Prior to the use of the
lightning-background-processor we'd needed to call PeerManager's
timer_tick_occurred from NioPeerHandler, but we never dropped it
after the switch. Thus, every ~30 seconds we'll call
PeerManager::timer_tick_occurred twice in a row, disconnecting all
of our peers.

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

index 991a6b135fda62468aa3878b1864cf4b1f512fe9..faca477f599d284539385af23c0d09bde2987b0f 100644 (file)
@@ -98,7 +98,6 @@ public class NioPeerHandler {
 
     /**
      * Constructs a new peer handler, spawning a thread to monitor for socket events.
-     * The background thread will call the PeerManager's timer_tick_occured() function for you on an appropriate schedule.
      *
      * @param manager The LDK PeerManager which connection data will be provided to.
      * @throws IOException If an internal java.nio error occurs.
@@ -108,7 +107,6 @@ public class NioPeerHandler {
         this.selector = Selector.open();
         io_thread = new Thread(() -> {
             ByteBuffer buf = ByteBuffer.allocate(8192);
-            long lastTimerTick = System.currentTimeMillis();
             while (true) {
                 try {
                     if (IS_ANDROID) {
@@ -192,10 +190,6 @@ public class NioPeerHandler {
                         // no need to do anything here with the PeerManager.
                     }
                 }
-                if (lastTimerTick < System.currentTimeMillis() - 30 * 1000) {
-                    peer_manager.timer_tick_occurred();
-                    lastTimerTick = System.currentTimeMillis();
-                }
                 peer_manager.process_events();
             }
         }, "NioPeerHandler NIO Thread");