From dd453ca67793b6ad7fb172211b09b5a5db96d375 Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Tue, 21 Apr 2015 13:50:32 +0200 Subject: [PATCH] PeerGroup: stall handling tweak: specify default bandwidth requirement in terms of block headers per second and make much lower, to avoid having false stalls when the Bloom FP rate is lowered (and thus bandwidth required is much lower). It's unclear how useful stall handling will be after this change, but we'll experiment with it a bit and find out. --- core/src/main/java/org/bitcoinj/core/PeerGroup.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/org/bitcoinj/core/PeerGroup.java b/core/src/main/java/org/bitcoinj/core/PeerGroup.java index e63f08b9..de70614c 100644 --- a/core/src/main/java/org/bitcoinj/core/PeerGroup.java +++ b/core/src/main/java/org/bitcoinj/core/PeerGroup.java @@ -1474,7 +1474,7 @@ public class PeerGroup implements TransactionBroadcaster { } @GuardedBy("lock") private int stallPeriodSeconds = 10; - @GuardedBy("lock") private int stallMinSpeed = 30; + @GuardedBy("lock") private int stallMinSpeedBytesSec = Block.HEADER_SIZE * 20; /** * Configures the stall speed: the speed at which a peer is considered to be serving us the block chain @@ -1485,13 +1485,13 @@ public class PeerGroup implements TransactionBroadcaster { * avoid false stalls. * * @param periodSecs How many seconds the download speed must be below blocksPerSec, defaults to 10. - * @param kilobytesPerSecond Download speed (only blocks/txns count) must be consistently below this for a stall, defaults to 30. + * @param bytesPerSecond Download speed (only blocks/txns count) must be consistently below this for a stall, defaults to the bandwidth required for 20 block headers per second. */ - public void setStallThreshold(int periodSecs, int kilobytesPerSecond) { + public void setStallThreshold(int periodSecs, int bytesPerSecond) { lock.lock(); try { stallPeriodSeconds = periodSecs; - stallMinSpeed = kilobytesPerSecond; + stallMinSpeedBytesSec = bytesPerSecond; } finally { lock.unlock(); } @@ -1546,7 +1546,7 @@ public class PeerGroup implements TransactionBroadcaster { lock.lock(); try { - minSpeedBytesPerSec = stallMinSpeed * 1024; + minSpeedBytesPerSec = stallMinSpeedBytesSec; period = stallPeriodSeconds; } finally { lock.unlock();