forked from Qortal/qortal
Faster shutdown for Peers doing PROOF part of handshake
This commit is contained in:
parent
2f2d9a664d
commit
7eb5cd55ff
@ -127,6 +127,10 @@ public class Peer extends Thread {
|
|||||||
|
|
||||||
// Getters / setters
|
// Getters / setters
|
||||||
|
|
||||||
|
public boolean isStopping() {
|
||||||
|
return this.isStopping;
|
||||||
|
}
|
||||||
|
|
||||||
public PeerData getPeerData() {
|
public PeerData getPeerData() {
|
||||||
return this.peerData;
|
return this.peerData;
|
||||||
}
|
}
|
||||||
@ -500,7 +504,7 @@ public class Peer extends Thread {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
LOGGER.debug(String.format("Shutting down peer %s", this));
|
LOGGER.debug(() -> String.format("Shutting down peer %s", this));
|
||||||
this.isStopping = true;
|
this.isStopping = true;
|
||||||
|
|
||||||
// Shut down pinger
|
// Shut down pinger
|
||||||
@ -525,6 +529,7 @@ public class Peer extends Thread {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOGGER.debug(() -> String.format("Interrupting peer %s", this));
|
||||||
this.interrupt();
|
this.interrupt();
|
||||||
|
|
||||||
// Close socket, which should trigger run() to exit
|
// Close socket, which should trigger run() to exit
|
||||||
|
@ -64,7 +64,7 @@ public class Proof extends Thread {
|
|||||||
long nonce;
|
long nonce;
|
||||||
for (nonce = 0; nonce < Long.MAX_VALUE; ++nonce) {
|
for (nonce = 0; nonce < Long.MAX_VALUE; ++nonce) {
|
||||||
// Check whether we're shutting down every so often
|
// 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");
|
// throw new InterruptedException("Interrupted during peer proof calculation");
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user