Browse Source

bitcoind: delete chaintips code.

We don't need it any more, with the simpler topology approach.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
committed by Christian Decker
parent
commit
0650653658
  1. 71
      lightningd/bitcoind.c
  2. 14
      lightningd/bitcoind.h

71
lightningd/bitcoind.c

@ -355,77 +355,6 @@ void bitcoind_sendrawtx_(struct bitcoind *bitcoind,
"sendrawtransaction", hextx, NULL); "sendrawtransaction", hextx, NULL);
} }
static void process_chaintips(struct bitcoin_cli *bcli)
{
const jsmntok_t *tokens, *t, *end;
bool valid;
size_t i;
struct bitcoin_blkid tip;
void (*cb)(struct bitcoind *bitcoind,
struct bitcoin_blkid *tipid,
void *arg) = bcli->cb;
tokens = json_parse_input(bcli->output, bcli->output_bytes, &valid);
if (!tokens)
fatal("%s: %s response",
bcli_args(bcli),
valid ? "partial" : "invalid");
if (tokens[0].type != JSMN_ARRAY)
fatal("%s: gave non-array (%.*s)?",
bcli_args(bcli),
(int)bcli->output_bytes, bcli->output);
valid = false;
end = json_next(tokens);
for (i = 0, t = tokens + 1; t < end; t = json_next(t), i++) {
const jsmntok_t *status = json_get_member(bcli->output, t, "status");
const jsmntok_t *hash = json_get_member(bcli->output, t, "hash");
if (!status || !hash) {
log_broken(bcli->bitcoind->log,
"%s: No status & hash: %.*s",
bcli_args(bcli),
(int)bcli->output_bytes, bcli->output);
continue;
}
if (!json_tok_streq(bcli->output, status, "active")) {
/* Ignoring this chaintip since it's not active */
continue;
}
if (valid) {
log_unusual(bcli->bitcoind->log,
"%s: Two active chaintips? %.*s",
bcli_args(bcli),
(int)bcli->output_bytes, bcli->output);
continue;
}
if (!bitcoin_blkid_from_hex(bcli->output + hash->start,
hash->end - hash->start,
&tip))
fatal("%s: gave bad hash for %zu'th tip (%.*s)?",
bcli_args(bcli), i,
(int)bcli->output_bytes, bcli->output);
valid = true;
}
if (!valid)
fatal("%s: gave no active chaintips (%.*s)?",
bcli_args(bcli), (int)bcli->output_bytes, bcli->output);
cb(bcli->bitcoind, &tip, bcli->cb_arg);
}
void bitcoind_get_chaintip_(struct bitcoind *bitcoind,
void (*cb)(struct bitcoind *bitcoind,
const struct bitcoin_blkid *tipid,
void *arg),
void *arg)
{
start_bitcoin_cli(bitcoind, NULL, process_chaintips, false, cb, arg,
"getchaintips", NULL);
}
static void process_rawblock(struct bitcoin_cli *bcli) static void process_rawblock(struct bitcoin_cli *bcli)
{ {
struct bitcoin_block *blk; struct bitcoin_block *blk;

14
lightningd/bitcoind.h

@ -84,20 +84,6 @@ void bitcoind_sendrawtx_(struct bitcoind *bitcoind,
int, const char *), \ int, const char *), \
(arg)) (arg))
void bitcoind_get_chaintip_(struct bitcoind *bitcoind,
void (*cb)(struct bitcoind *bitcoind,
const struct bitcoin_blkid *tipid,
void *arg),
void *arg);
#define bitcoind_get_chaintip(bitcoind_, cb, arg) \
bitcoind_get_chaintip_((bitcoind_), \
typesafe_cb_preargs(void, void *, \
(cb), (arg), \
struct bitcoind *, \
const struct bitcoin_blkid *), \
(arg))
void bitcoind_getblockcount_(struct bitcoind *bitcoind, void bitcoind_getblockcount_(struct bitcoind *bitcoind,
void (*cb)(struct bitcoind *bitcoind, void (*cb)(struct bitcoind *bitcoind,
u32 blockcount, u32 blockcount,

Loading…
Cancel
Save