mirror of
				https://github.com/Qortal/altcoinj.git
				synced 2025-11-03 05:57:21 +00:00 
			
		
		
		
	Adjust stall period to 15 seconds and min speed to 5 kB/s. The previous 6 seconds caused otherwise quick peers to be disconnected too often. Also, fixed a compare bug and a comment.
This commit is contained in:
		@@ -1464,9 +1464,8 @@ public class PeerGroup implements TransactionBroadcaster {
 | 
			
		||||
    private class ChainDownloadSpeedCalculator extends AbstractPeerEventListener implements Runnable {
 | 
			
		||||
        private int blocksInLastSecond, txnsInLastSecond, origTxnsInLastSecond, stallWarning;
 | 
			
		||||
 | 
			
		||||
        private static final int STALL_PERIOD_SECONDS = 6;
 | 
			
		||||
        private static final int STALL_MIN_SPEED = 10;
 | 
			
		||||
 | 
			
		||||
        private static final int STALL_PERIOD_SECONDS = 15;
 | 
			
		||||
        private static final int STALL_MIN_SPEED = 5;
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
        public synchronized void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) {
 | 
			
		||||
@@ -1482,9 +1481,9 @@ public class PeerGroup implements TransactionBroadcaster {
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
        public synchronized void run() {
 | 
			
		||||
            if (blocksInLastSecond > 1) {
 | 
			
		||||
            if (blocksInLastSecond > 0) {
 | 
			
		||||
                log.info("{} blocks/sec, {} tx/sec, {} pre-filtered tx/sec", blocksInLastSecond, txnsInLastSecond, origTxnsInLastSecond);
 | 
			
		||||
                if (blocksInLastSecond > STALL_MIN_SPEED)
 | 
			
		||||
                if (blocksInLastSecond >= STALL_MIN_SPEED)
 | 
			
		||||
                    stallWarning = 0;
 | 
			
		||||
            }
 | 
			
		||||
            if (chain != null && chain.getBestChainHeight() < getMostCommonChainHeight() && blocksInLastSecond < STALL_MIN_SPEED && stallWarning > -1) {
 | 
			
		||||
@@ -1492,7 +1491,7 @@ public class PeerGroup implements TransactionBroadcaster {
 | 
			
		||||
                if (stallWarning == STALL_PERIOD_SECONDS) {
 | 
			
		||||
                    stallWarning = -1;
 | 
			
		||||
                    Peer peer = getDownloadPeer();
 | 
			
		||||
                    log.warn("Chain download stalled: no progress for {} seconds, disconnecting {}", STALL_PERIOD_SECONDS, peer);
 | 
			
		||||
                    log.warn("Chain download stalled: slow progress for {} seconds, disconnecting {}", STALL_PERIOD_SECONDS, peer);
 | 
			
		||||
                    peer.close();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user