Browse Source

daemon: allow multiple watches on the same tx.

This turns out to make life easier for watching HTLC timeouts (we just
place a new watch for each HTLC).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 9 years ago
parent
commit
c94c495257
  1. 6
      daemon/chaintopology.c
  2. 2
      daemon/watch.c

6
daemon/chaintopology.c

@ -137,6 +137,7 @@ static void connect_blocks(struct lightningd_state *dstate, struct block *b)
struct bitcoin_tx *tx = b->full_txs[i];
struct txwatch *w;
struct sha256_double txid;
struct txwatch_hash_iter iter;
size_t j;
/* Tell them if it spends a txo we care about. */
@ -153,8 +154,9 @@ static void connect_blocks(struct lightningd_state *dstate, struct block *b)
/* We do spends first, in case that tells us to watch tx. */
bitcoin_txid(tx, &txid);
w = txwatch_hash_get(&dstate->txwatches, &txid);
if (w) {
for (w = txwatch_hash_getfirst(&dstate->txwatches, &txid, &iter);
w;
w = txwatch_hash_getnext(&dstate->txwatches, &txid, &iter)){
add_tx_to_block(b, w);
/* Fire if it's the first we've seen it: this might
* set up txo watches, which could fire in this block */

2
daemon/watch.c

@ -90,8 +90,6 @@ struct txwatch *watch_txid_(const tal_t *ctx,
{
struct txwatch *w;
assert(!txwatch_hash_get(&peer->dstate->txwatches, txid));
w = tal(ctx, struct txwatch);
w->depth = -1;
w->txid = *txid;

Loading…
Cancel
Save