From c5ea60c2feff6be1d0e4e2827f126051855375b1 Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Mon, 28 Dec 2015 00:44:26 +0100 Subject: [PATCH] Fix issue with dangling msg --- .../io/bitsquare/payment/PaymentMethod.java | 2 +- .../p2p/peers/AuthenticationHandshake.java | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/io/bitsquare/payment/PaymentMethod.java b/core/src/main/java/io/bitsquare/payment/PaymentMethod.java index 8376715b18..72e5022adf 100644 --- a/core/src/main/java/io/bitsquare/payment/PaymentMethod.java +++ b/core/src/main/java/io/bitsquare/payment/PaymentMethod.java @@ -59,7 +59,7 @@ public class PaymentMethod implements Serializable, Comparable { public static PaymentMethod BLOCK_CHAINS; public static final List ALL_VALUES = new ArrayList<>(Arrays.asList( - OK_PAY = new PaymentMethod(OK_PAY_ID, 0, HOUR), // tx instant so min. wait time + OK_PAY = new PaymentMethod(OK_PAY_ID, 0, DAY), // tx instant so min. wait time PERFECT_MONEY = new PaymentMethod(PERFECT_MONEY_ID, 0, DAY), SEPA = new PaymentMethod(SEPA_ID, 0, 8 * DAY), // sepa takes 1-3 business days. We use 8 days to include safety for holidays SWISH = new PaymentMethod(SWISH_ID, 0, DAY), diff --git a/network/src/main/java/io/bitsquare/p2p/peers/AuthenticationHandshake.java b/network/src/main/java/io/bitsquare/p2p/peers/AuthenticationHandshake.java index e803bc5abd..3877ba2064 100644 --- a/network/src/main/java/io/bitsquare/p2p/peers/AuthenticationHandshake.java +++ b/network/src/main/java/io/bitsquare/p2p/peers/AuthenticationHandshake.java @@ -122,8 +122,14 @@ public class AuthenticationHandshake implements MessageListener { // now we add the reported peers to our list addReportedPeersConsumer.accept(authenticationChallenge.reportedPeers, connection); } else { - log.warn("Verification of nonce failed. nonce={} / peerAddress={} / authenticationChallenge={}", nonce, peerAddress, authenticationChallenge); - failed(new Exception("Verification of nonce failed. AuthenticationChallenge=" + authenticationChallenge + " / nonceMap=" + nonce)); + // We don't call failed as it might be that we get an old authenticationChallenge from a + // previously timed out request + // We simply ignore the authenticationChallenge if the nonce is not matching to avoid that + // the current authentication turn gets terminated as well + log.warn("Verification of nonce failed. Maybe we got an old authenticationChallenge " + + "from a timed out request" + + "\nnonce={} / peerAddress={} / authenticationChallenge={}", nonce, peerAddress, authenticationChallenge); + //failed(new AuthenticationException("Verification of nonce failed. AuthenticationChallenge=" + authenticationChallenge + " / nonceMap=" + nonce)); } } else if (message instanceof AuthenticationFinalResponse) { // Responding peer @@ -137,8 +143,15 @@ public class AuthenticationHandshake implements MessageListener { + (System.currentTimeMillis() - startAuthTs) + " ms."); completed(connection); } else { + // We don't call failed as it might be that we get an old authenticationFinalResponse from a + // previously timed out request + // We simply ignore the authenticationFinalResponse if the nonce is not matching to avoid that + // the current authentication turn gets terminated as well + log.warn("Verification of nonce failed. Maybe we got an old authenticationFinalResponse " + + "from a timed out request" + + "\nnonce={} / peerAddress={} / authenticationChallenge={}", nonce, peerAddress, authenticationFinalResponse); log.warn("Verification of nonce failed. nonce={} / peerAddress={} / authenticationFinalResponse={}", nonce, peerAddress, authenticationFinalResponse); - failed(new Exception("Verification of nonce failed. getPeersMessage=" + authenticationFinalResponse + " / nonce=" + nonce)); + //failed(new AuthenticationException("Verification of nonce failed. getPeersMessage=" + authenticationFinalResponse + " / nonce=" + nonce)); } } else if (message instanceof AuthenticationRejection) { // Any peer