MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / sync_blocks

Function sync_blocks

test/functional/test_framework/util.py:378–392  ·  view source on GitHub ↗

Wait until everybody has the same tip. sync_blocks needs to be called with an rpc_connections set that has least one node already synced to the latest, stable tip, otherwise there's a chance it might return before all nodes are stably synced.

(rpc_connections, *, wait=1, timeout=60)

Source from the content-addressed store, hash-verified

376 connect_nodes(nodes[b], a)
377
378def sync_blocks(rpc_connections, *, wait=1, timeout=60):
379 """
380 Wait until everybody has the same tip.
381
382 sync_blocks needs to be called with an rpc_connections set that has least
383 one node already synced to the latest, stable tip, otherwise there's a
384 chance it might return before all nodes are stably synced.
385 """
386 stop_time = time.time() + timeout
387 while time.time() <= stop_time:
388 best_hash = [x.getbestblockhash() for x in rpc_connections]
389 if best_hash.count(best_hash[0]) == len(rpc_connections):
390 return
391 time.sleep(wait)
392 raise AssertionError("Block sync timed out:{}".format("".join("\n {!r}".format(b) for b in best_hash)))
393
394def sync_mempools(rpc_connections, *, wait=1, timeout=60, flush_scheduler=True):
395 """

Callers 15

mine_reorgMethod · 0.90
run_testMethod · 0.90
run_testMethod · 0.90
success_mineMethod · 0.90
skip_mineMethod · 0.90
run_testMethod · 0.90
test_utxo_conversionMethod · 0.90
setup_networkMethod · 0.90
create_big_chainMethod · 0.90

Calls 3

formatMethod · 0.80
joinMethod · 0.80
countMethod · 0.45

Tested by 12

test_utxo_conversionMethod · 0.72
test_standardness_v0Method · 0.72
test_p2sh_witnessMethod · 0.72
test_segwit_versionsMethod · 0.72
test_witness_sigopsMethod · 0.72
sync_allMethod · 0.68
_initialize_chainMethod · 0.68