aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorptschip <peter.tschipper@gmail.com>2015-12-05 09:02:02 -0800
committerMarcoFalke <falke.marco@gmail.com>2016-04-27 22:34:47 +0200
commit90955940d5bbe037d512699c1bfca2689018daea (patch)
tree31644840e950f5b933eded3dd2147401abfdf4eb
parent18b3c3ced8126301711c69a971de0210f2eb8790 (diff)
downloadbitcoin-90955940d5bbe037d512699c1bfca2689018daea.tar.xz
Do not download transactions during inital sync
Github-Pull: #7164 Rebased-From: 39a525c21fd1b34df63ab30868423b97b708ee49
-rwxr-xr-xqa/rpc-tests/listtransactions.py5
-rwxr-xr-xqa/rpc-tests/receivedby.py5
-rw-r--r--qa/rpc-tests/test_framework/util.py30
-rw-r--r--src/main.cpp2
4 files changed, 37 insertions, 5 deletions
diff --git a/qa/rpc-tests/listtransactions.py b/qa/rpc-tests/listtransactions.py
index 51a29b48e3..4e5809f4a7 100755
--- a/qa/rpc-tests/listtransactions.py
+++ b/qa/rpc-tests/listtransactions.py
@@ -18,6 +18,11 @@ def txFromHex(hexstring):
class ListTransactionsTest(BitcoinTestFramework):
+ def setup_nodes(self):
+ #This test requires mocktime
+ enable_mocktime()
+ return start_nodes(4, self.options.tmpdir)
+
def run_test(self):
# Simple send, 0 to 1:
txid = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.1)
diff --git a/qa/rpc-tests/receivedby.py b/qa/rpc-tests/receivedby.py
index 15ef71a589..7d8231f5e4 100755
--- a/qa/rpc-tests/receivedby.py
+++ b/qa/rpc-tests/receivedby.py
@@ -27,6 +27,11 @@ def get_sub_array_from_array(object_array, to_match):
class ReceivedByTest(BitcoinTestFramework):
+ def setup_nodes(self):
+ #This test requires mocktime
+ enable_mocktime()
+ return start_nodes(4, self.options.tmpdir)
+
def run_test(self):
'''
listreceivedbyaddress Test
diff --git a/qa/rpc-tests/test_framework/util.py b/qa/rpc-tests/test_framework/util.py
index 3d08fc7d7d..50a649b01f 100644
--- a/qa/rpc-tests/test_framework/util.py
+++ b/qa/rpc-tests/test_framework/util.py
@@ -26,6 +26,26 @@ from .authproxy import AuthServiceProxy, JSONRPCException
COVERAGE_DIR = None
+#Set Mocktime default to OFF.
+#MOCKTIME is only needed for scripts that use the
+#cached version of the blockchain. If the cached
+#version of the blockchain is used without MOCKTIME
+#then the mempools will not sync due to IBD.
+MOCKTIME = 0
+
+def enable_mocktime():
+ #For backwared compatibility of the python scripts
+ #with previous versions of the cache, set MOCKTIME
+ #to Jan 1, 2014 + (201 * 10 * 60)
+ global MOCKTIME
+ MOCKTIME = 1388534400 + (201 * 10 * 60)
+
+def disable_mocktime():
+ global MOCKTIME
+ MOCKTIME = 0
+
+def get_mocktime():
+ return MOCKTIME
def enable_coverage(dirname):
"""Maintain a log of which RPC calls are made during testing."""
@@ -168,9 +188,10 @@ def initialize_chain(test_dir):
# Create a 200-block-long chain; each of the 4 nodes
# gets 25 mature blocks and 25 immature.
- # blocks are created with timestamps 10 minutes apart, starting
- # at 1 Jan 2014
- block_time = 1388534400
+ # blocks are created with timestamps 10 minutes apart
+ # starting from 2010 minutes in the past
+ enable_mocktime()
+ block_time = get_mocktime() - (201 * 10 * 60)
for i in range(2):
for peer in range(4):
for j in range(25):
@@ -183,6 +204,7 @@ def initialize_chain(test_dir):
# Shut them down, and clean up cache directories:
stop_nodes(rpcs)
wait_bitcoinds()
+ disable_mocktime()
for i in range(4):
os.remove(log_filename("cache", i, "debug.log"))
os.remove(log_filename("cache", i, "db.log"))
@@ -232,7 +254,7 @@ def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=
if binary is None:
binary = os.getenv("BITCOIND", "bitcoind")
# RPC tests still depend on free transactions
- args = [ binary, "-datadir="+datadir, "-server", "-keypool=1", "-discover=0", "-rest", "-blockprioritysize=50000" ]
+ args = [ binary, "-datadir="+datadir, "-server", "-keypool=1", "-discover=0", "-rest", "-blockprioritysize=50000", "-mocktime="+str(get_mocktime()) ]
if extra_args is not None: args.extend(extra_args)
bitcoind_processes[i] = subprocess.Popen(args)
devnull = open(os.devnull, "w")
diff --git a/src/main.cpp b/src/main.cpp
index f85ac33177..7d3bb2a3cb 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -4845,7 +4845,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
{
if (fBlocksOnly)
LogPrint("net", "transaction (%s) inv sent in violation of protocol peer=%d\n", inv.hash.ToString(), pfrom->id);
- else if (!fAlreadyHave && !fImporting && !fReindex)
+ else if (!fAlreadyHave && !fImporting && !fReindex && !IsInitialBlockDownload())
pfrom->AskFor(inv);
}