Skip to content

Commit

Permalink
bitcoind: delete chaintips code.
Browse files Browse the repository at this point in the history
We don't need it any more, with the simpler topology approach.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell authored and cdecker committed Dec 21, 2017
1 parent 1d9a8e5 commit 0650653
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 85 deletions.
71 changes: 0 additions & 71 deletions lightningd/bitcoind.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,77 +355,6 @@ void bitcoind_sendrawtx_(struct bitcoind *bitcoind,
"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)
{
struct bitcoin_block *blk;
Expand Down
14 changes: 0 additions & 14 deletions lightningd/bitcoind.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,6 @@ void bitcoind_sendrawtx_(struct bitcoind *bitcoind,
int, const char *), \
(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 (*cb)(struct bitcoind *bitcoind,
u32 blockcount,
Expand Down

0 comments on commit 0650653

Please sign in to comment.