From a55ce607a1c867667647c812e3d94a94c5493432 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 1 Nov 2017 20:50:40 +1030 Subject: [PATCH] bitcoind: contain ld pointer. This is a subset of a "bitcoind: wrap callbacks in transaction." from the everything-in-transaction branch, but we need the ld pointer now. Signed-off-by: Rusty Russell --- lightningd/bitcoind.c | 5 ++++- lightningd/bitcoind.h | 7 ++++++- lightningd/chaintopology.c | 6 +++--- lightningd/chaintopology.h | 2 +- lightningd/test/run-cryptomsg.c | 2 -- lightningd/test/run-find_my_path.c | 4 +--- 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/lightningd/bitcoind.c b/lightningd/bitcoind.c index fdaff76b7..bab699080 100644 --- a/lightningd/bitcoind.c +++ b/lightningd/bitcoind.c @@ -543,13 +543,16 @@ void wait_for_bitcoind(struct bitcoind *bitcoind) tal_free(cmd); } -struct bitcoind *new_bitcoind(const tal_t *ctx, struct log *log) +struct bitcoind *new_bitcoind(const tal_t *ctx, + struct lightningd *ld, + struct log *log) { struct bitcoind *bitcoind = tal(ctx, struct bitcoind); /* Use testnet by default, change later if we want another network */ bitcoind->chainparams = chainparams_for_network("testnet"); bitcoind->datadir = NULL; + bitcoind->ld = ld; bitcoind->log = log; bitcoind->req_running = false; bitcoind->shutdown = false; diff --git a/lightningd/bitcoind.h b/lightningd/bitcoind.h index 1fb371e94..9157b6aea 100644 --- a/lightningd/bitcoind.h +++ b/lightningd/bitcoind.h @@ -29,6 +29,9 @@ struct bitcoind { /* Where to do logging. */ struct log *log; + /* Main lightningd structure */ + struct lightningd *ld; + /* Are we currently running a bitcoind request (it's ratelimited) */ bool req_running; @@ -46,7 +49,9 @@ struct bitcoind { bool shutdown; }; -struct bitcoind *new_bitcoind(const tal_t *ctx, struct log *log); +struct bitcoind *new_bitcoind(const tal_t *ctx, + struct lightningd *ld, + struct log *log); void wait_for_bitcoind(struct bitcoind *bitcoind); diff --git a/lightningd/chaintopology.c b/lightningd/chaintopology.c index fa5a0b273..b153b8afd 100644 --- a/lightningd/chaintopology.c +++ b/lightningd/chaintopology.c @@ -551,9 +551,9 @@ static void destroy_outgoing_txs(struct chain_topology *topo) tal_free(otx); } -struct chain_topology *new_topology(const tal_t *ctx, struct log *log) +struct chain_topology *new_topology(struct lightningd *ld, struct log *log) { - struct chain_topology *topo = tal(ctx, struct chain_topology); + struct chain_topology *topo = tal(ld, struct chain_topology); block_map_init(&topo->block_map); list_head_init(&topo->outgoing_txs); @@ -562,7 +562,7 @@ struct chain_topology *new_topology(const tal_t *ctx, struct log *log) topo->log = log; topo->default_fee_rate = 40000; topo->override_fee_rate = 0; - topo->bitcoind = new_bitcoind(topo, log); + topo->bitcoind = new_bitcoind(topo, ld, log); #if DEVELOPER topo->dev_no_broadcast = false; #endif diff --git a/lightningd/chaintopology.h b/lightningd/chaintopology.h index 5e69ce734..f3a8c5139 100644 --- a/lightningd/chaintopology.h +++ b/lightningd/chaintopology.h @@ -149,7 +149,7 @@ void broadcast_tx(struct chain_topology *topo, int exitstatus, const char *err)); -struct chain_topology *new_topology(const tal_t *ctx, struct log *log); +struct chain_topology *new_topology(struct lightningd *ld, struct log *log); void setup_topology(struct chain_topology *topology, struct timers *timers, struct timerel poll_time, u32 first_peer_block); diff --git a/lightningd/test/run-cryptomsg.c b/lightningd/test/run-cryptomsg.c index fead63c04..35126ede9 100644 --- a/lightningd/test/run-cryptomsg.c +++ b/lightningd/test/run-cryptomsg.c @@ -47,8 +47,6 @@ void dev_blackhole_fd(int fd UNNEEDED) /* Generated stub for dev_sabotage_fd */ void dev_sabotage_fd(int fd UNNEEDED) { fprintf(stderr, "dev_sabotage_fd called!\n"); abort(); } -/* Could not find declaration for secp256k1_ecdsa_recoverable_signature_parse_compact */ -/* Could not find declaration for secp256k1_ecdsa_recoverable_signature_serialize_compact */ /* AUTOGENERATED MOCKS END */ enum dev_disconnect dev_disconnect(int pkt_type) diff --git a/lightningd/test/run-find_my_path.c b/lightningd/test/run-find_my_path.c index 13b673618..8372232e2 100644 --- a/lightningd/test/run-find_my_path.c +++ b/lightningd/test/run-find_my_path.c @@ -38,7 +38,7 @@ struct log_book *new_log_book(const tal_t *ctx UNNEEDED, enum log_level printlevel UNNEEDED) { fprintf(stderr, "new_log_book called!\n"); abort(); } /* Generated stub for new_topology */ -struct chain_topology *new_topology(const tal_t *ctx UNNEEDED, struct log *log UNNEEDED) +struct chain_topology *new_topology(struct lightningd *ld UNNEEDED, struct log *log UNNEEDED) { fprintf(stderr, "new_topology called!\n"); abort(); } /* Generated stub for populate_peer */ void populate_peer(struct lightningd *ld UNNEEDED, struct peer *peer UNNEEDED) @@ -46,8 +46,6 @@ void populate_peer(struct lightningd *ld UNNEEDED, struct peer *peer UNNEEDED) /* Generated stub for register_opts */ void register_opts(struct lightningd *ld UNNEEDED) { fprintf(stderr, "register_opts called!\n"); abort(); } -/* Could not find declaration for secp256k1_ecdsa_recoverable_signature_parse_compact */ -/* Could not find declaration for secp256k1_ecdsa_recoverable_signature_serialize_compact */ /* Generated stub for setup_color_and_alias */ void setup_color_and_alias(struct lightningd *ld UNNEEDED) { fprintf(stderr, "setup_color_and_alias called!\n"); abort(); }