mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-21 22:31:48 +01:00
bcli: change iteration order on peerlist
It is simpler to just iterate through the peerlist backwards. Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
This commit is contained in:
parent
8894455c02
commit
9ae5c04583
2 changed files with 6 additions and 8 deletions
|
@ -592,14 +592,12 @@ static struct command_result *process_getblockfrompeer(struct bitcoin_cli *bcli)
|
|||
* block from peer */
|
||||
plugin_log(bcli->cmd->plugin, LOG_DBG,
|
||||
"failed to fetch block %s from peer %i, skip.",
|
||||
stash->block_hash, stash->peers[0]);
|
||||
stash->block_hash, stash->peers[tal_count(stash->peers) - 1]);
|
||||
} else {
|
||||
plugin_log(bcli->cmd->plugin, LOG_DBG,
|
||||
"try to fetch block %s from peer %i.",
|
||||
stash->block_hash, stash->peers[0]);
|
||||
stash->block_hash, stash->peers[tal_count(stash->peers) - 1]);
|
||||
}
|
||||
|
||||
stash->peers[0] = stash->peers[tal_count(stash->peers) - 1];
|
||||
tal_resize(&stash->peers, tal_count(stash->peers) - 1);
|
||||
|
||||
/* `getblockfrompeer` is an async call. sleep for a second to allow the
|
||||
|
|
|
@ -208,19 +208,19 @@ def test_bitcoin_pruned(node_factory, bitcoind):
|
|||
l1.daemon.rpcproxy.mock_rpc("getblockfrompeer", mock_getblockfrompeer())
|
||||
l1.start(wait_for_bitcoind_sync=False)
|
||||
|
||||
# check that we fetched a block from a peer (1st peer in this case).
|
||||
# check that we fetched a block from a peer (1st peer (from the back) in this case).
|
||||
pruned_block = bitcoind.rpc.getblockhash(bitcoind.rpc.getblockcount())
|
||||
l1.daemon.wait_for_log(f"failed to fetch block {pruned_block} from the bitcoin backend")
|
||||
l1.daemon.wait_for_log(rf"try to fetch block {pruned_block} from peer 1")
|
||||
l1.daemon.wait_for_log(rf"try to fetch block {pruned_block} from peer 3")
|
||||
l1.daemon.wait_for_log(rf"Adding block (\d+): {pruned_block}")
|
||||
|
||||
# check that we can also fetch from a peer > 1st.
|
||||
# check that we can also fetch from a peer > 1st (from the back).
|
||||
l1.daemon.rpcproxy.mock_rpc("getblockfrompeer", mock_getblockfrompeer(error=True, release_after=2))
|
||||
bitcoind.generate_block(1)
|
||||
|
||||
pruned_block = bitcoind.rpc.getblockhash(bitcoind.rpc.getblockcount())
|
||||
l1.daemon.wait_for_log(f"failed to fetch block {pruned_block} from the bitcoin backend")
|
||||
l1.daemon.wait_for_log(rf"failed to fetch block {pruned_block} from peer 1")
|
||||
l1.daemon.wait_for_log(rf"failed to fetch block {pruned_block} from peer 3")
|
||||
l1.daemon.wait_for_log(rf"try to fetch block {pruned_block} from peer (\d+)")
|
||||
l1.daemon.wait_for_log(rf"Adding block (\d+): {pruned_block}")
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue