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:
Peter Neuroth
2024-04-23 10:18:09 +02:00
committed by Rusty Russell
parent 8894455c02
commit 9ae5c04583
2 changed files with 6 additions and 8 deletions

View File

@@ -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