diff --git a/plugins/bcli.c b/plugins/bcli.c index e04159b44..4fc899ad7 100644 --- a/plugins/bcli.c +++ b/plugins/bcli.c @@ -562,7 +562,7 @@ struct getrawblock_stash { const char *block_hex; }; -static struct command_result *process_getrawblock(struct bitcoin_cli *bcli) +static struct command_result *process_rawblock(struct bitcoin_cli *bcli) { struct json_stream *response; struct getrawblock_stash *stash = bcli->stash; @@ -577,6 +577,17 @@ static struct command_result *process_getrawblock(struct bitcoin_cli *bcli) return command_finished(bcli->cmd, response); } +static struct command_result *process_getrawblock(struct bitcoin_cli *bcli) +{ + /* We failed to get the raw block. */ + if (bcli->exitstatus && *bcli->exitstatus != 0) { + /* retry */ + return NULL; + } + + return process_rawblock(bcli); +} + static struct command_result * getrawblockbyheight_notfound(struct bitcoin_cli *bcli) { @@ -607,7 +618,7 @@ static struct command_result *process_getblockhash(struct bitcoin_cli *bcli) return command_err_bcli_badjson(bcli, "bad blockhash"); } - start_bitcoin_cli(NULL, bcli->cmd, process_getrawblock, false, + start_bitcoin_cli(NULL, bcli->cmd, process_getrawblock, true, BITCOIND_HIGH_PRIO, stash, "getblock", stash->block_hash,