bcli: move getblock call to a separate function

We move the `geblock` call into a separate function. This allows us to
call if from various places in the future.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
This commit is contained in:
Peter Neuroth 2024-04-19 14:40:08 +02:00 committed by Rusty Russell
parent e06c3245f5
commit 9baa65a738

View file

@ -600,6 +600,19 @@ getrawblockbyheight_notfound(struct bitcoin_cli *bcli)
return command_finished(bcli->cmd, response);
}
static struct command_result *getrawblock(struct bitcoin_cli *bcli)
{
struct getrawblock_stash *stash = bcli->stash;
start_bitcoin_cli(NULL, bcli->cmd, process_getrawblock, true,
BITCOIND_HIGH_PRIO, stash, "getblock",
stash->block_hash,
/* Non-verbose: raw block. */
"0", NULL);
return command_still_pending(bcli->cmd);
}
static struct command_result *process_getblockhash(struct bitcoin_cli *bcli)
{
struct getrawblock_stash *stash = bcli->stash;
@ -618,15 +631,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, true,
BITCOIND_HIGH_PRIO, stash,
"getblock",
stash->block_hash,
/* Non-verbose: raw block. */
"0",
NULL);
return command_still_pending(bcli->cmd);
return getrawblock(bcli);
}
/* Get a raw block given its height.