mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 14:42:40 +01:00
peer: on restart, only resubmit added HTLCs which weren't already routed.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
d964ad2d94
commit
1bd2a28caa
1 changed files with 18 additions and 0 deletions
|
@ -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. */
|
/* peer has come back online: re-send any we have to send to them. */
|
||||||
static void retry_all_routing(struct peer *restarted_peer)
|
static void retry_all_routing(struct peer *restarted_peer)
|
||||||
{
|
{
|
||||||
struct peer *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) {
|
list_for_each(&restarted_peer->dstate->peers, peer, list) {
|
||||||
struct htlc_map_iter it;
|
struct htlc_map_iter it;
|
||||||
struct htlc *h;
|
struct htlc *h;
|
||||||
|
@ -595,6 +611,8 @@ static void retry_all_routing(struct peer *restarted_peer)
|
||||||
h = htlc_map_next(&peer->htlcs, &it)) {
|
h = htlc_map_next(&peer->htlcs, &it)) {
|
||||||
if (h->state != RCVD_ADD_ACK_REVOCATION)
|
if (h->state != RCVD_ADD_ACK_REVOCATION)
|
||||||
continue;
|
continue;
|
||||||
|
if (htlc_with_source(peer, h))
|
||||||
|
continue;
|
||||||
their_htlc_added(peer, h, restarted_peer);
|
their_htlc_added(peer, h, restarted_peer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue