Browse Source

peer: on restart, only resubmit added HTLCs which weren't already routed.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 8 years ago
parent
commit
1bd2a28caa
  1. 18
      daemon/peer.c

18
daemon/peer.c

@ -578,11 +578,27 @@ static void our_htlc_fulfilled(struct peer *peer, struct htlc *htlc,
}
}
/* FIXME: Slow! */
static struct htlc *htlc_with_source(struct peer *peer, struct htlc *src)
{
struct htlc_map_iter it;
struct htlc *h;
for (h = htlc_map_first(&peer->htlcs, &it);
h;
h = htlc_map_next(&peer->htlcs, &it)) {
if (h->src == src)
return h;
}
return NULL;
}
/* peer has come back online: re-send any we have to send to them. */
static void retry_all_routing(struct peer *restarted_peer)
{
struct peer *peer;
/* Look for added htlcs from other peers which need to go here. */
list_for_each(&restarted_peer->dstate->peers, peer, list) {
struct htlc_map_iter it;
struct htlc *h;
@ -595,6 +611,8 @@ static void retry_all_routing(struct peer *restarted_peer)
h = htlc_map_next(&peer->htlcs, &it)) {
if (h->state != RCVD_ADD_ACK_REVOCATION)
continue;
if (htlc_with_source(peer, h))
continue;
their_htlc_added(peer, h, restarted_peer);
}
}

Loading…
Cancel
Save