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>
This commit is contained in:
Rusty Russell 2016-05-03 11:01:20 +09:30
parent 77a89bcf2b
commit c94c495257
2 changed files with 4 additions and 4 deletions

View File

@ -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 */

View File

@ -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;