From 0650653658c35cab4675ce76b2328306c934ffe0 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 21 Dec 2017 21:40:21 +1030 Subject: [PATCH] bitcoind: delete chaintips code. We don't need it any more, with the simpler topology approach. Signed-off-by: Rusty Russell --- lightningd/bitcoind.c | 71 ------------------------------------------- lightningd/bitcoind.h | 14 --------- 2 files changed, 85 deletions(-) diff --git a/lightningd/bitcoind.c b/lightningd/bitcoind.c index 0bd59127a..9b1881267 100644 --- a/lightningd/bitcoind.c +++ b/lightningd/bitcoind.c @@ -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; diff --git a/lightningd/bitcoind.h b/lightningd/bitcoind.h index fe48ea40c..675d0c995 100644 --- a/lightningd/bitcoind.h +++ b/lightningd/bitcoind.h @@ -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,