peer: keep a single HTLC map for all htlcs.

Not separate "locally-offered" and "remotely-offered" ones; we can
distinguish them by htlc->state now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2016-08-18 14:23:45 +09:30
parent 4b5ec85c25
commit 1af3428c6c
3 changed files with 12 additions and 49 deletions

View File

@@ -269,21 +269,9 @@ static bool htlcs_changestate(struct peer *peer,
struct htlc *h;
bool changed = false;
for (h = htlc_map_first(&peer->local.htlcs, &it);
for (h = htlc_map_first(&peer->htlcs, &it);
h;
h = htlc_map_next(&peer->local.htlcs, &it)) {
size_t i;
for (i = 0; i < n; i++) {
if (h->state == table[i].from) {
htlc_changestate(h, table[i].from, table[i].to);
changed = true;
}
}
}
for (h = htlc_map_first(&peer->remote.htlcs, &it);
h;
h = htlc_map_next(&peer->remote.htlcs, &it)) {
h = htlc_map_next(&peer->htlcs, &it)) {
size_t i;
for (i = 0; i < n; i++) {
if (h->state == table[i].from) {
@@ -689,7 +677,7 @@ Pkt *accept_pkt_htlc_add(struct peer *peer, const Pkt *pkt)
/* Note that it's not *our* problem if they do this, it's
* theirs (future confusion). Nonetheless, we detect and
* error for them. */
if (htlc_map_get(&peer->remote.htlcs, u->id))
if (htlc_get(&peer->htlcs, u->id, REMOTE))
return pkt_err(peer, "HTLC id %"PRIu64" clashes for you", u->id);
/* BOLT #2: