Browse Source

Faster shutdown for Peers doing PROOF part of handshake

pull/67/head
catbref 5 years ago
parent
commit
7eb5cd55ff
  1. 7
      src/main/java/org/qora/network/Peer.java
  2. 2
      src/main/java/org/qora/network/Proof.java

7
src/main/java/org/qora/network/Peer.java

@ -127,6 +127,10 @@ public class Peer extends Thread {
// Getters / setters
public boolean isStopping() {
return this.isStopping;
}
public PeerData getPeerData() {
return this.peerData;
}
@ -500,7 +504,7 @@ public class Peer extends Thread {
}
public void shutdown() {
LOGGER.debug(String.format("Shutting down peer %s", this));
LOGGER.debug(() -> String.format("Shutting down peer %s", this));
this.isStopping = true;
// Shut down pinger
@ -525,6 +529,7 @@ public class Peer extends Thread {
}
}
LOGGER.debug(() -> String.format("Interrupting peer %s", this));
this.interrupt();
// Close socket, which should trigger run() to exit

2
src/main/java/org/qora/network/Proof.java

@ -64,7 +64,7 @@ public class Proof extends Thread {
long nonce;
for (nonce = 0; nonce < Long.MAX_VALUE; ++nonce) {
// Check whether we're shutting down every so often
if ((nonce & 0xff) == 0 && Thread.currentThread().isInterrupted())
if ((nonce & 0xff) == 0 && (peer.isStopping() || Thread.currentThread().isInterrupted()))
// throw new InterruptedException("Interrupted during peer proof calculation");
return;

Loading…
Cancel
Save