Drop dup PeerManager tiemr_tick_occurred calls from NioPeerHandler
[ldk-java] / src / main / java / org / ldk / batteries / NioPeerHandler.java
index eac4d8058a898fd7a8af0a61ddb8e2be68627f92..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");
@@ -236,6 +230,15 @@ public class NioPeerHandler {
         }
     }
 
+    /**
+     * Disconnects any connections currently open with the peer with the given node id.
+     *
+     * @param their_node_id must be a valid 33-byte public key
+     */
+    public void disconnect(byte[] their_node_id) {
+        this.peer_manager.disconnect_by_node_id(their_node_id, false);
+    }
+
     /**
      * Binds a listening socket to the given address, accepting incoming connections and handling them on the background
      * thread.