mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-23 09:04:22 +01:00
struct topology -> struct chain_topology
Topology also refers to the lightning network, be clear. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -16,9 +16,9 @@
|
|||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
static void start_poll_chaintip(struct topology *topo);
|
static void start_poll_chaintip(struct chain_topology *topo);
|
||||||
|
|
||||||
static void next_topology_timer(struct topology *topo)
|
static void next_topology_timer(struct chain_topology *topo)
|
||||||
{
|
{
|
||||||
if (topo->startup) {
|
if (topo->startup) {
|
||||||
topo->startup = false;
|
topo->startup = false;
|
||||||
@@ -38,7 +38,7 @@ static int cmp_times(const u32 *a, const u32 *b, void *unused)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Mediantime is median of this and previous 10 blocks. */
|
/* Mediantime is median of this and previous 10 blocks. */
|
||||||
static u32 get_mediantime(const struct topology *topo, const struct block *b)
|
static u32 get_mediantime(const struct chain_topology *topo, const struct block *b)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
u32 times[11];
|
u32 times[11];
|
||||||
@@ -64,7 +64,7 @@ static void add_tx_to_block(struct block *b, const struct sha256_double *txid, c
|
|||||||
b->txnums[n] = txnum;
|
b->txnums[n] = txnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool we_broadcast(const struct topology *topo,
|
static bool we_broadcast(const struct chain_topology *topo,
|
||||||
const struct sha256_double *txid)
|
const struct sha256_double *txid)
|
||||||
{
|
{
|
||||||
const struct outgoing_tx *otx;
|
const struct outgoing_tx *otx;
|
||||||
@@ -77,7 +77,7 @@ static bool we_broadcast(const struct topology *topo,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Fills in prev, height, mediantime. */
|
/* Fills in prev, height, mediantime. */
|
||||||
static void connect_block(struct topology *topo,
|
static void connect_block(struct chain_topology *topo,
|
||||||
struct block *prev,
|
struct block *prev,
|
||||||
struct block *b)
|
struct block *b)
|
||||||
{
|
{
|
||||||
@@ -136,7 +136,7 @@ static bool tx_in_block(const struct block *b,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: Use hash table. */
|
/* FIXME: Use hash table. */
|
||||||
static struct block *block_for_tx(const struct topology *topo,
|
static struct block *block_for_tx(const struct chain_topology *topo,
|
||||||
const struct sha256_double *txid)
|
const struct sha256_double *txid)
|
||||||
{
|
{
|
||||||
struct block *b;
|
struct block *b;
|
||||||
@@ -148,7 +148,7 @@ static struct block *block_for_tx(const struct topology *topo,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t get_tx_depth(const struct topology *topo,
|
size_t get_tx_depth(const struct chain_topology *topo,
|
||||||
const struct sha256_double *txid)
|
const struct sha256_double *txid)
|
||||||
{
|
{
|
||||||
const struct block *b;
|
const struct block *b;
|
||||||
@@ -199,7 +199,7 @@ static void broadcast_remainder(struct bitcoind *bitcoind,
|
|||||||
|
|
||||||
/* FIXME: This is dumb. We can group txs and avoid bothering bitcoind
|
/* FIXME: This is dumb. We can group txs and avoid bothering bitcoind
|
||||||
* if any one tx is in the main chain. */
|
* if any one tx is in the main chain. */
|
||||||
static void rebroadcast_txs(struct topology *topo, struct command *cmd)
|
static void rebroadcast_txs(struct chain_topology *topo, struct command *cmd)
|
||||||
{
|
{
|
||||||
/* Copy txs now (peers may go away, and they own txs). */
|
/* Copy txs now (peers may go away, and they own txs). */
|
||||||
size_t num_txs = 0;
|
size_t num_txs = 0;
|
||||||
@@ -247,7 +247,7 @@ static void broadcast_done(struct bitcoind *bitcoind,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void broadcast_tx(struct topology *topo,
|
void broadcast_tx(struct chain_topology *topo,
|
||||||
struct peer *peer, const struct bitcoin_tx *tx,
|
struct peer *peer, const struct bitcoin_tx *tx,
|
||||||
void (*failed)(struct peer *peer,
|
void (*failed)(struct peer *peer,
|
||||||
int exitstatus, const char *err))
|
int exitstatus, const char *err))
|
||||||
@@ -272,7 +272,7 @@ void broadcast_tx(struct topology *topo,
|
|||||||
broadcast_done, otx);
|
broadcast_done, otx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void free_blocks(struct topology *topo, struct block *b)
|
static void free_blocks(struct chain_topology *topo, struct block *b)
|
||||||
{
|
{
|
||||||
struct block *next;
|
struct block *next;
|
||||||
|
|
||||||
@@ -290,7 +290,7 @@ static void free_blocks(struct topology *topo, struct block *b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void update_fee(struct bitcoind *bitcoind, u64 rate,
|
static void update_fee(struct bitcoind *bitcoind, u64 rate,
|
||||||
struct topology *topo)
|
struct chain_topology *topo)
|
||||||
{
|
{
|
||||||
log_debug(topo->log, "Feerate %"PRIu64" (was %"PRIu64")",
|
log_debug(topo->log, "Feerate %"PRIu64" (was %"PRIu64")",
|
||||||
rate, topo->feerate);
|
rate, topo->feerate);
|
||||||
@@ -298,7 +298,7 @@ static void update_fee(struct bitcoind *bitcoind, u64 rate,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* B is the new chain (linked by ->next); update topology */
|
/* B is the new chain (linked by ->next); update topology */
|
||||||
static void topology_changed(struct topology *topo,
|
static void topology_changed(struct chain_topology *topo,
|
||||||
struct block *prev,
|
struct block *prev,
|
||||||
struct block *b)
|
struct block *b)
|
||||||
{
|
{
|
||||||
@@ -323,7 +323,7 @@ static void topology_changed(struct topology *topo,
|
|||||||
bitcoind_estimate_fee(topo->bitcoind, update_fee, topo);
|
bitcoind_estimate_fee(topo->bitcoind, update_fee, topo);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct block *new_block(struct topology *topo,
|
static struct block *new_block(struct chain_topology *topo,
|
||||||
struct bitcoin_block *blk,
|
struct bitcoin_block *blk,
|
||||||
struct block *next)
|
struct block *next)
|
||||||
{
|
{
|
||||||
@@ -351,7 +351,7 @@ static struct block *new_block(struct topology *topo,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void add_block(struct bitcoind *bitcoind,
|
static void add_block(struct bitcoind *bitcoind,
|
||||||
struct topology *topo,
|
struct chain_topology *topo,
|
||||||
struct bitcoin_block *blk,
|
struct bitcoin_block *blk,
|
||||||
struct block *next);
|
struct block *next);
|
||||||
|
|
||||||
@@ -363,7 +363,7 @@ static void gather_previous_blocks(struct bitcoind *bitcoind,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void add_block(struct bitcoind *bitcoind,
|
static void add_block(struct bitcoind *bitcoind,
|
||||||
struct topology *topo,
|
struct chain_topology *topo,
|
||||||
struct bitcoin_block *blk,
|
struct bitcoin_block *blk,
|
||||||
struct block *next)
|
struct block *next)
|
||||||
{
|
{
|
||||||
@@ -386,14 +386,14 @@ static void add_block(struct bitcoind *bitcoind,
|
|||||||
|
|
||||||
static void rawblock_tip(struct bitcoind *bitcoind,
|
static void rawblock_tip(struct bitcoind *bitcoind,
|
||||||
struct bitcoin_block *blk,
|
struct bitcoin_block *blk,
|
||||||
struct topology *topo)
|
struct chain_topology *topo)
|
||||||
{
|
{
|
||||||
add_block(bitcoind, topo, blk, NULL);
|
add_block(bitcoind, topo, blk, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void check_chaintip(struct bitcoind *bitcoind,
|
static void check_chaintip(struct bitcoind *bitcoind,
|
||||||
const struct sha256_double *tipid,
|
const struct sha256_double *tipid,
|
||||||
struct topology *topo)
|
struct chain_topology *topo)
|
||||||
{
|
{
|
||||||
/* 0 is the main tip. */
|
/* 0 is the main tip. */
|
||||||
if (!structeq(tipid, &topo->tip->blkid))
|
if (!structeq(tipid, &topo->tip->blkid))
|
||||||
@@ -403,7 +403,7 @@ static void check_chaintip(struct bitcoind *bitcoind,
|
|||||||
next_topology_timer(topo);
|
next_topology_timer(topo);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void start_poll_chaintip(struct topology *topo)
|
static void start_poll_chaintip(struct chain_topology *topo)
|
||||||
{
|
{
|
||||||
if (!list_empty(&topo->bitcoind->pending)) {
|
if (!list_empty(&topo->bitcoind->pending)) {
|
||||||
log_unusual(topo->log,
|
log_unusual(topo->log,
|
||||||
@@ -415,7 +415,7 @@ static void start_poll_chaintip(struct topology *topo)
|
|||||||
|
|
||||||
static void init_topo(struct bitcoind *bitcoind,
|
static void init_topo(struct bitcoind *bitcoind,
|
||||||
struct bitcoin_block *blk,
|
struct bitcoin_block *blk,
|
||||||
struct topology *topo)
|
struct chain_topology *topo)
|
||||||
{
|
{
|
||||||
topo->root = new_block(topo, blk, NULL);
|
topo->root = new_block(topo, blk, NULL);
|
||||||
topo->root->height = topo->first_blocknum;
|
topo->root->height = topo->first_blocknum;
|
||||||
@@ -428,13 +428,13 @@ static void init_topo(struct bitcoind *bitcoind,
|
|||||||
|
|
||||||
static void get_init_block(struct bitcoind *bitcoind,
|
static void get_init_block(struct bitcoind *bitcoind,
|
||||||
const struct sha256_double *blkid,
|
const struct sha256_double *blkid,
|
||||||
struct topology *topo)
|
struct chain_topology *topo)
|
||||||
{
|
{
|
||||||
bitcoind_getrawblock(bitcoind, blkid, init_topo, topo);
|
bitcoind_getrawblock(bitcoind, blkid, init_topo, topo);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void get_init_blockhash(struct bitcoind *bitcoind, u32 blockcount,
|
static void get_init_blockhash(struct bitcoind *bitcoind, u32 blockcount,
|
||||||
struct topology *topo)
|
struct chain_topology *topo)
|
||||||
{
|
{
|
||||||
/* Start back before any reasonable forks. */
|
/* Start back before any reasonable forks. */
|
||||||
if (blockcount < 100)
|
if (blockcount < 100)
|
||||||
@@ -447,7 +447,7 @@ static void get_init_blockhash(struct bitcoind *bitcoind, u32 blockcount,
|
|||||||
get_init_block, topo);
|
get_init_block, topo);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 get_tx_mediantime(const struct topology *topo,
|
u32 get_tx_mediantime(const struct chain_topology *topo,
|
||||||
const struct sha256_double *txid)
|
const struct sha256_double *txid)
|
||||||
{
|
{
|
||||||
struct block *b;
|
struct block *b;
|
||||||
@@ -460,17 +460,17 @@ u32 get_tx_mediantime(const struct topology *topo,
|
|||||||
tal_hexstr(topo, txid, sizeof(*txid)));
|
tal_hexstr(topo, txid, sizeof(*txid)));
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 get_tip_mediantime(const struct topology *topo)
|
u32 get_tip_mediantime(const struct chain_topology *topo)
|
||||||
{
|
{
|
||||||
return topo->tip->mediantime;
|
return topo->tip->mediantime;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 get_block_height(const struct topology *topo)
|
u32 get_block_height(const struct chain_topology *topo)
|
||||||
{
|
{
|
||||||
return topo->tip->height;
|
return topo->tip->height;
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 get_feerate(const struct topology *topo)
|
u64 get_feerate(const struct chain_topology *topo)
|
||||||
{
|
{
|
||||||
if (topo->override_fee_rate) {
|
if (topo->override_fee_rate) {
|
||||||
log_debug(topo->log, "Forcing fee rate, ignoring estimate");
|
log_debug(topo->log, "Forcing fee rate, ignoring estimate");
|
||||||
@@ -483,7 +483,7 @@ u64 get_feerate(const struct topology *topo)
|
|||||||
return topo->feerate;
|
return topo->feerate;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct txlocator *locate_tx(const void *ctx, const struct topology *topo,
|
struct txlocator *locate_tx(const void *ctx, const struct chain_topology *topo,
|
||||||
const struct sha256_double *txid)
|
const struct sha256_double *txid)
|
||||||
{
|
{
|
||||||
struct block *block = block_for_tx(topo, txid);
|
struct block *block = block_for_tx(topo, txid);
|
||||||
@@ -504,7 +504,7 @@ struct txlocator *locate_tx(const void *ctx, const struct topology *topo,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void json_dev_broadcast(struct command *cmd,
|
void json_dev_broadcast(struct command *cmd,
|
||||||
struct topology *topo,
|
struct chain_topology *topo,
|
||||||
const char *buffer, const jsmntok_t *params)
|
const char *buffer, const jsmntok_t *params)
|
||||||
{
|
{
|
||||||
jsmntok_t *enabletok;
|
jsmntok_t *enabletok;
|
||||||
@@ -535,7 +535,7 @@ void json_dev_broadcast(struct command *cmd,
|
|||||||
|
|
||||||
/* On shutdown, peers get deleted last. That frees from our list, so
|
/* On shutdown, peers get deleted last. That frees from our list, so
|
||||||
* do it now instead. */
|
* do it now instead. */
|
||||||
static void destroy_outgoing_txs(struct topology *topo)
|
static void destroy_outgoing_txs(struct chain_topology *topo)
|
||||||
{
|
{
|
||||||
struct outgoing_tx *otx;
|
struct outgoing_tx *otx;
|
||||||
|
|
||||||
@@ -543,9 +543,9 @@ static void destroy_outgoing_txs(struct topology *topo)
|
|||||||
tal_free(otx);
|
tal_free(otx);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct topology *new_topology(const tal_t *ctx, struct log *log)
|
struct chain_topology *new_topology(const tal_t *ctx, struct log *log)
|
||||||
{
|
{
|
||||||
struct topology *topo = tal(ctx, struct topology);
|
struct chain_topology *topo = tal(ctx, struct chain_topology);
|
||||||
|
|
||||||
block_map_init(&topo->block_map);
|
block_map_init(&topo->block_map);
|
||||||
list_head_init(&topo->outgoing_txs);
|
list_head_init(&topo->outgoing_txs);
|
||||||
@@ -559,7 +559,7 @@ struct topology *new_topology(const tal_t *ctx, struct log *log)
|
|||||||
return topo;
|
return topo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup_topology(struct topology *topo, struct bitcoind *bitcoind,
|
void setup_topology(struct chain_topology *topo, struct bitcoind *bitcoind,
|
||||||
struct timers *timers,
|
struct timers *timers,
|
||||||
struct timerel poll_time, u32 first_peer_block)
|
struct timerel poll_time, u32 first_peer_block)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ struct outgoing_tx {
|
|||||||
struct sha256_double txid;
|
struct sha256_double txid;
|
||||||
void (*failed)(struct peer *peer, int exitstatus, const char *err);
|
void (*failed)(struct peer *peer, int exitstatus, const char *err);
|
||||||
/* FIXME: Remove this. */
|
/* FIXME: Remove this. */
|
||||||
struct topology *topo;
|
struct chain_topology *topo;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct block {
|
struct block {
|
||||||
@@ -58,7 +58,7 @@ struct block {
|
|||||||
struct bitcoin_tx **full_txs;
|
struct bitcoin_tx **full_txs;
|
||||||
|
|
||||||
/* FIXME: Remove this. */
|
/* FIXME: Remove this. */
|
||||||
struct topology *topo;
|
struct chain_topology *topo;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Hash blocks by sha */
|
/* Hash blocks by sha */
|
||||||
@@ -81,7 +81,7 @@ static inline bool block_eq(const struct block *b, const struct sha256_double *k
|
|||||||
}
|
}
|
||||||
HTABLE_DEFINE_TYPE(struct block, keyof_block_map, hash_sha, block_eq, block_map);
|
HTABLE_DEFINE_TYPE(struct block, keyof_block_map, hash_sha, block_eq, block_map);
|
||||||
|
|
||||||
struct topology {
|
struct chain_topology {
|
||||||
struct block *root;
|
struct block *root;
|
||||||
struct block *tip;
|
struct block *tip;
|
||||||
struct block_map block_map;
|
struct block_map block_map;
|
||||||
@@ -132,41 +132,41 @@ struct txlocator {
|
|||||||
|
|
||||||
/* This is the number of blocks which would have to be mined to invalidate
|
/* This is the number of blocks which would have to be mined to invalidate
|
||||||
* the tx. */
|
* the tx. */
|
||||||
size_t get_tx_depth(const struct topology *topo,
|
size_t get_tx_depth(const struct chain_topology *topo,
|
||||||
const struct sha256_double *txid);
|
const struct sha256_double *txid);
|
||||||
|
|
||||||
/* Get the mediantime of the block including this tx (must be one!) */
|
/* Get the mediantime of the block including this tx (must be one!) */
|
||||||
u32 get_tx_mediantime(const struct topology *topo,
|
u32 get_tx_mediantime(const struct chain_topology *topo,
|
||||||
const struct sha256_double *txid);
|
const struct sha256_double *txid);
|
||||||
|
|
||||||
/* Get mediantime of the tip; if more than one, pick greatest time. */
|
/* Get mediantime of the tip; if more than one, pick greatest time. */
|
||||||
u32 get_tip_mediantime(const struct topology *topo);
|
u32 get_tip_mediantime(const struct chain_topology *topo);
|
||||||
|
|
||||||
/* Get highest block number. */
|
/* Get highest block number. */
|
||||||
u32 get_block_height(const struct topology *topo);
|
u32 get_block_height(const struct chain_topology *topo);
|
||||||
|
|
||||||
/* Get fee rate. */
|
/* Get fee rate. */
|
||||||
u64 get_feerate(const struct topology *topo);
|
u64 get_feerate(const struct chain_topology *topo);
|
||||||
|
|
||||||
/* Broadcast a single tx, and rebroadcast as reqd (copies tx).
|
/* Broadcast a single tx, and rebroadcast as reqd (copies tx).
|
||||||
* If failed is non-NULL, call that and don't rebroadcast. */
|
* If failed is non-NULL, call that and don't rebroadcast. */
|
||||||
void broadcast_tx(struct topology *topo,
|
void broadcast_tx(struct chain_topology *topo,
|
||||||
struct peer *peer, const struct bitcoin_tx *tx,
|
struct peer *peer, const struct bitcoin_tx *tx,
|
||||||
void (*failed)(struct peer *peer,
|
void (*failed)(struct peer *peer,
|
||||||
int exitstatus,
|
int exitstatus,
|
||||||
const char *err));
|
const char *err));
|
||||||
|
|
||||||
struct topology *new_topology(const tal_t *ctx, struct log *log);
|
struct chain_topology *new_topology(const tal_t *ctx, struct log *log);
|
||||||
void setup_topology(struct topology *topology, struct bitcoind *bitcoind,
|
void setup_topology(struct chain_topology *topology, struct bitcoind *bitcoind,
|
||||||
struct timers *timers,
|
struct timers *timers,
|
||||||
struct timerel poll_time, u32 first_peer_block);
|
struct timerel poll_time, u32 first_peer_block);
|
||||||
|
|
||||||
struct txlocator *locate_tx(const void *ctx, const struct topology *topo, const struct sha256_double *txid);
|
struct txlocator *locate_tx(const void *ctx, const struct chain_topology *topo, const struct sha256_double *txid);
|
||||||
|
|
||||||
void notify_new_block(struct topology *topo, unsigned int height);
|
void notify_new_block(struct chain_topology *topo, unsigned int height);
|
||||||
|
|
||||||
void json_dev_broadcast(struct command *cmd,
|
void json_dev_broadcast(struct command *cmd,
|
||||||
struct topology *topo,
|
struct chain_topology *topo,
|
||||||
const char *buffer, const jsmntok_t *params);
|
const char *buffer, const jsmntok_t *params);
|
||||||
|
|
||||||
#endif /* LIGHTNING_DAEMON_CRYPTOPKT_H */
|
#endif /* LIGHTNING_DAEMON_CRYPTOPKT_H */
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ struct lightningd_state {
|
|||||||
struct timers timers;
|
struct timers timers;
|
||||||
|
|
||||||
/* Cached block topology. */
|
/* Cached block topology. */
|
||||||
struct topology *topology;
|
struct chain_topology *topology;
|
||||||
|
|
||||||
/* Our peers. */
|
/* Our peers. */
|
||||||
struct list_head peers;
|
struct list_head peers;
|
||||||
|
|||||||
@@ -3403,7 +3403,7 @@ static enum watch_result anchor_depthchange(struct peer *peer,
|
|||||||
return KEEP_WATCHING;
|
return KEEP_WATCHING;
|
||||||
}
|
}
|
||||||
|
|
||||||
void notify_new_block(struct topology *topo, unsigned int height)
|
void notify_new_block(struct chain_topology *topo, unsigned int height)
|
||||||
{
|
{
|
||||||
struct lightningd_state *dstate = tal_parent(topo);
|
struct lightningd_state *dstate = tal_parent(topo);
|
||||||
/* This is where we check for anchor timeouts. */
|
/* This is where we check for anchor timeouts. */
|
||||||
@@ -3880,7 +3880,7 @@ static void resolve_their_htlc(struct peer *peer, unsigned int out_num)
|
|||||||
static void resolve_our_unilateral(struct peer *peer)
|
static void resolve_our_unilateral(struct peer *peer)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
struct topology *topo = peer->dstate->topology;
|
struct chain_topology *topo = peer->dstate->topology;
|
||||||
const struct bitcoin_tx *tx = peer->onchain.tx;
|
const struct bitcoin_tx *tx = peer->onchain.tx;
|
||||||
|
|
||||||
/* This only works because we always watch for a long time before
|
/* This only works because we always watch for a long time before
|
||||||
@@ -4315,7 +4315,7 @@ unknown_spend:
|
|||||||
|
|
||||||
void peer_watch_anchor(struct peer *peer, int depth)
|
void peer_watch_anchor(struct peer *peer, int depth)
|
||||||
{
|
{
|
||||||
struct topology *topo = peer->dstate->topology;
|
struct chain_topology *topo = peer->dstate->topology;
|
||||||
|
|
||||||
log_debug_struct(peer->log, "watching for anchor %s",
|
log_debug_struct(peer->log, "watching for anchor %s",
|
||||||
struct sha256_double, &peer->anchor.txid);
|
struct sha256_double, &peer->anchor.txid);
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ static void destroy_txwatch(struct txwatch *w)
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct txwatch *watch_txid_(const tal_t *ctx,
|
struct txwatch *watch_txid_(const tal_t *ctx,
|
||||||
struct topology *topo,
|
struct chain_topology *topo,
|
||||||
struct peer *peer,
|
struct peer *peer,
|
||||||
const struct sha256_double *txid,
|
const struct sha256_double *txid,
|
||||||
enum watch_result (*cb)(struct peer *peer,
|
enum watch_result (*cb)(struct peer *peer,
|
||||||
@@ -111,14 +111,14 @@ struct txwatch *watch_txid_(const tal_t *ctx,
|
|||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool watching_txid(const struct topology *topo,
|
bool watching_txid(const struct chain_topology *topo,
|
||||||
const struct sha256_double *txid)
|
const struct sha256_double *txid)
|
||||||
{
|
{
|
||||||
return txwatch_hash_get(&topo->txwatches, txid) != NULL;
|
return txwatch_hash_get(&topo->txwatches, txid) != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct txwatch *watch_tx_(const tal_t *ctx,
|
struct txwatch *watch_tx_(const tal_t *ctx,
|
||||||
struct topology *topo,
|
struct chain_topology *topo,
|
||||||
struct peer *peer,
|
struct peer *peer,
|
||||||
const struct bitcoin_tx *tx,
|
const struct bitcoin_tx *tx,
|
||||||
enum watch_result (*cb)(struct peer *peer,
|
enum watch_result (*cb)(struct peer *peer,
|
||||||
@@ -134,7 +134,7 @@ struct txwatch *watch_tx_(const tal_t *ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct txowatch *watch_txo_(const tal_t *ctx,
|
struct txowatch *watch_txo_(const tal_t *ctx,
|
||||||
struct topology *topo,
|
struct chain_topology *topo,
|
||||||
struct peer *peer,
|
struct peer *peer,
|
||||||
const struct sha256_double *txid,
|
const struct sha256_double *txid,
|
||||||
unsigned int output,
|
unsigned int output,
|
||||||
@@ -159,7 +159,7 @@ struct txowatch *watch_txo_(const tal_t *ctx,
|
|||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
void txwatch_fire(struct topology *topo,
|
void txwatch_fire(struct chain_topology *topo,
|
||||||
const struct sha256_double *txid,
|
const struct sha256_double *txid,
|
||||||
unsigned int depth)
|
unsigned int depth)
|
||||||
{
|
{
|
||||||
@@ -186,7 +186,7 @@ void txwatch_fire(struct topology *topo,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void txowatch_fire(struct topology *topo,
|
void txowatch_fire(struct chain_topology *topo,
|
||||||
const struct txowatch *txow,
|
const struct txowatch *txow,
|
||||||
const struct bitcoin_tx *tx,
|
const struct bitcoin_tx *tx,
|
||||||
size_t input_num)
|
size_t input_num)
|
||||||
@@ -216,7 +216,7 @@ void txowatch_fire(struct topology *topo,
|
|||||||
fatal("txowatch callback %p returned %i\n", txow->cb, r);
|
fatal("txowatch callback %p returned %i\n", txow->cb, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
void watch_topology_changed(struct topology *topo)
|
void watch_topology_changed(struct chain_topology *topo)
|
||||||
{
|
{
|
||||||
struct txwatch_hash_iter i;
|
struct txwatch_hash_iter i;
|
||||||
struct txwatch *w;
|
struct txwatch *w;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ struct txwatch_output {
|
|||||||
|
|
||||||
/* Watching an output */
|
/* Watching an output */
|
||||||
struct txowatch {
|
struct txowatch {
|
||||||
struct topology *topo;
|
struct chain_topology *topo;
|
||||||
|
|
||||||
/* Peer who owns us. */
|
/* Peer who owns us. */
|
||||||
struct peer *peer;
|
struct peer *peer;
|
||||||
@@ -48,7 +48,7 @@ HTABLE_DEFINE_TYPE(struct txowatch, txowatch_keyof, txo_hash, txowatch_eq,
|
|||||||
txowatch_hash);
|
txowatch_hash);
|
||||||
|
|
||||||
struct txwatch {
|
struct txwatch {
|
||||||
struct topology *topo;
|
struct chain_topology *topo;
|
||||||
|
|
||||||
/* Peer who owns us. */
|
/* Peer who owns us. */
|
||||||
struct peer *peer;
|
struct peer *peer;
|
||||||
@@ -72,7 +72,7 @@ HTABLE_DEFINE_TYPE(struct txwatch, txwatch_keyof, txid_hash, txwatch_eq,
|
|||||||
|
|
||||||
|
|
||||||
struct txwatch *watch_txid_(const tal_t *ctx,
|
struct txwatch *watch_txid_(const tal_t *ctx,
|
||||||
struct topology *topo,
|
struct chain_topology *topo,
|
||||||
struct peer *peer,
|
struct peer *peer,
|
||||||
const struct sha256_double *txid,
|
const struct sha256_double *txid,
|
||||||
enum watch_result (*cb)(struct peer *peer,
|
enum watch_result (*cb)(struct peer *peer,
|
||||||
@@ -91,7 +91,7 @@ struct txwatch *watch_txid_(const tal_t *ctx,
|
|||||||
(cbdata))
|
(cbdata))
|
||||||
|
|
||||||
struct txwatch *watch_tx_(const tal_t *ctx,
|
struct txwatch *watch_tx_(const tal_t *ctx,
|
||||||
struct topology *topo,
|
struct chain_topology *topo,
|
||||||
struct peer *peer,
|
struct peer *peer,
|
||||||
const struct bitcoin_tx *tx,
|
const struct bitcoin_tx *tx,
|
||||||
enum watch_result (*cb)(struct peer *peer,
|
enum watch_result (*cb)(struct peer *peer,
|
||||||
@@ -110,7 +110,7 @@ struct txwatch *watch_tx_(const tal_t *ctx,
|
|||||||
(cbdata))
|
(cbdata))
|
||||||
|
|
||||||
struct txowatch *watch_txo_(const tal_t *ctx,
|
struct txowatch *watch_txo_(const tal_t *ctx,
|
||||||
struct topology *topo,
|
struct chain_topology *topo,
|
||||||
struct peer *peer,
|
struct peer *peer,
|
||||||
const struct sha256_double *txid,
|
const struct sha256_double *txid,
|
||||||
unsigned int output,
|
unsigned int output,
|
||||||
@@ -129,16 +129,16 @@ struct txowatch *watch_txo_(const tal_t *ctx,
|
|||||||
size_t), \
|
size_t), \
|
||||||
(cbdata))
|
(cbdata))
|
||||||
|
|
||||||
void txwatch_fire(struct topology *topo,
|
void txwatch_fire(struct chain_topology *topo,
|
||||||
const struct sha256_double *txid,
|
const struct sha256_double *txid,
|
||||||
unsigned int depth);
|
unsigned int depth);
|
||||||
|
|
||||||
void txowatch_fire(struct topology *topo,
|
void txowatch_fire(struct chain_topology *topo,
|
||||||
const struct txowatch *txow,
|
const struct txowatch *txow,
|
||||||
const struct bitcoin_tx *tx, size_t input_num);
|
const struct bitcoin_tx *tx, size_t input_num);
|
||||||
|
|
||||||
bool watching_txid(const struct topology *topo,
|
bool watching_txid(const struct chain_topology *topo,
|
||||||
const struct sha256_double *txid);
|
const struct sha256_double *txid);
|
||||||
|
|
||||||
void watch_topology_changed(struct topology *topo);
|
void watch_topology_changed(struct chain_topology *topo);
|
||||||
#endif /* LIGHTNING_DAEMON_WATCH_H */
|
#endif /* LIGHTNING_DAEMON_WATCH_H */
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ struct peer *find_peer(struct lightningd_state *dstate, const struct pubkey *id)
|
|||||||
FIXME_IMPLEMENT();
|
FIXME_IMPLEMENT();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t get_tx_depth(const struct topology *topo,
|
size_t get_tx_depth(const struct chain_topology *topo,
|
||||||
const struct sha256_double *txid)
|
const struct sha256_double *txid)
|
||||||
{
|
{
|
||||||
FIXME_IMPLEMENT();
|
FIXME_IMPLEMENT();
|
||||||
@@ -54,7 +54,7 @@ void debug_dump_peers(struct lightningd_state *dstate)
|
|||||||
FIXME_IMPLEMENT();
|
FIXME_IMPLEMENT();
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 get_block_height(const struct topology *topo)
|
u32 get_block_height(const struct chain_topology *topo)
|
||||||
{
|
{
|
||||||
/* FIXME_IMPLEMENT(); */
|
/* FIXME_IMPLEMENT(); */
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user