Remove cancel,cleanup and stop method. Use terminate instead.

Fix typo
This commit is contained in:
chimp1984 2020-12-04 10:55:26 -05:00
parent 4a05e5bf0d
commit 5363c8d505
No known key found for this signature in database
GPG Key ID: 9801B4EC591F90E3

View File

@ -98,10 +98,6 @@ public class RequestBlocksHandler implements MessageListener {
this.listener = listener;
}
public void cancel() {
cleanup();
}
///////////////////////////////////////////////////////////////////////////////////////////
// API
@ -127,7 +123,7 @@ public class RequestBlocksHandler implements MessageListener {
handleFault(errorMessage, nodeAddress, CloseConnectionReason.SEND_MSG_TIMEOUT);
} else {
log.warn("We have stopped already. We ignore that timeoutTimer.run call. " +
"Might be caused by an previous networkNode.sendMessage.onFailure.");
"Might be caused by a previous networkNode.sendMessage.onFailure.");
}
},
TIMEOUT_MIN, TimeUnit.MINUTES);
@ -193,17 +189,20 @@ public class RequestBlocksHandler implements MessageListener {
return;
}
cleanup();
terminate();
log.info("We received from peer {} a BlocksResponse with {} blocks",
nodeAddress.getFullAddress(), getBlocksResponse.getBlocks().size());
listener.onComplete(getBlocksResponse);
}
}
public void stop() {
cleanup();
public void terminate() {
stopped = true;
networkNode.removeMessageListener(this);
stopTimeoutTimer();
}
///////////////////////////////////////////////////////////////////////////////////////////
// Private
///////////////////////////////////////////////////////////////////////////////////////////
@ -213,17 +212,11 @@ public class RequestBlocksHandler implements MessageListener {
private void handleFault(String errorMessage,
NodeAddress nodeAddress,
CloseConnectionReason closeConnectionReason) {
cleanup();
terminate();
peerManager.handleConnectionFault(nodeAddress);
listener.onFault(errorMessage, null);
}
private void cleanup() {
stopped = true;
networkNode.removeMessageListener(this);
stopTimeoutTimer();
}
private void stopTimeoutTimer() {
if (timeoutTimer != null) {
timeoutTimer.stop();