From 67134651ee2bda0c8c8e1ae5a1d6b20cf1303174 Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Mon, 10 Jul 2017 16:53:45 +0200 Subject: [PATCH] Improve log --- .../blockchain/p2p/RequestBlocksHandler.java | 44 ++++++++++--------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/core/src/main/java/io/bisq/core/dao/blockchain/p2p/RequestBlocksHandler.java b/core/src/main/java/io/bisq/core/dao/blockchain/p2p/RequestBlocksHandler.java index d3d91a4ba2..3f6fc07b0f 100644 --- a/core/src/main/java/io/bisq/core/dao/blockchain/p2p/RequestBlocksHandler.java +++ b/core/src/main/java/io/bisq/core/dao/blockchain/p2p/RequestBlocksHandler.java @@ -140,31 +140,35 @@ public class RequestBlocksHandler implements MessageListener { @Override public void onMessage(NetworkEnvelope networkEnvelop, Connection connection) { - if (connection.getPeersNodeAddressOptional().isPresent() && connection.getPeersNodeAddressOptional().get().equals(peersNodeAddress)) { - if (networkEnvelop instanceof GetBsqBlocksResponse) { - Log.traceCall(networkEnvelop.toString() + "\n\tconnection=" + connection); - if (!stopped) { - GetBsqBlocksResponse getBsqBlocksResponse = (GetBsqBlocksResponse) networkEnvelop; - if (getBsqBlocksResponse.getRequestNonce() == nonce) { - stopTimeoutTimer(); - checkArgument(connection.getPeersNodeAddressOptional().isPresent(), - "RequestDataHandler.onMessage: connection.getPeersNodeAddressOptional() must be present " + - "at that moment"); - cleanup(); - listener.onComplete(getBsqBlocksResponse); + if (connection.getPeersNodeAddressOptional().isPresent()) { + if (connection.getPeersNodeAddressOptional().get().equals(peersNodeAddress)) { + if (networkEnvelop instanceof GetBsqBlocksResponse) { + Log.traceCall(networkEnvelop.toString() + "\n\tconnection=" + connection); + if (!stopped) { + GetBsqBlocksResponse getBsqBlocksResponse = (GetBsqBlocksResponse) networkEnvelop; + if (getBsqBlocksResponse.getRequestNonce() == nonce) { + stopTimeoutTimer(); + checkArgument(connection.getPeersNodeAddressOptional().isPresent(), + "RequestDataHandler.onMessage: connection.getPeersNodeAddressOptional() must be present " + + "at that moment"); + cleanup(); + listener.onComplete(getBsqBlocksResponse); + } else { + log.warn("Nonce not matching. That can happen rarely if we get a response after a canceled " + + "handshake (timeout causes connection close but peer might have sent a msg before " + + "connection was closed).\n\t" + + "We drop that message. nonce={} / requestNonce={}", + nonce, getBsqBlocksResponse.getRequestNonce()); + } } else { - log.warn("Nonce not matching. That can happen rarely if we get a response after a canceled " + - "handshake (timeout causes connection close but peer might have sent a msg before " + - "connection was closed).\n\t" + - "We drop that message. nonce={} / requestNonce={}", - nonce, getBsqBlocksResponse.getRequestNonce()); + log.warn("We have stopped already. We ignore that onDataRequest call."); } - } else { - log.warn("We have stopped already. We ignore that onDataRequest call."); } + } else { + log.warn("We got a message from another connection and ignore it. That should never happen."); } } else { - log.warn("We got a message from another connection and ignore it. That should never happen."); + log.debug("Peers node address is not set yet."); } }