mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 07:34:24 +01:00
test/test_protocol: don't bother keeping acked (outgoing) queue.
We can simply set a boolean to indicate there are changes. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -41,7 +41,7 @@ THEIR COMMITS:
|
|||||||
Commit 0:
|
Commit 0:
|
||||||
Offered htlcs:
|
Offered htlcs:
|
||||||
Received htlcs:
|
Received htlcs:
|
||||||
Pending outgoing: FEE
|
Pending outgoing
|
||||||
SIGNED
|
SIGNED
|
||||||
***B after receiving second commit***
|
***B after receiving second commit***
|
||||||
OUR COMMITS:
|
OUR COMMITS:
|
||||||
@@ -53,7 +53,7 @@ THEIR COMMITS:
|
|||||||
Commit 0:
|
Commit 0:
|
||||||
Offered htlcs:
|
Offered htlcs:
|
||||||
Received htlcs:
|
Received htlcs:
|
||||||
Pending outgoing: FEE FEE
|
Pending outgoing
|
||||||
SIGNED
|
SIGNED
|
||||||
***B after committing***
|
***B after committing***
|
||||||
OUR COMMITS:
|
OUR COMMITS:
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ struct commit_info {
|
|||||||
/* Channel state. */
|
/* Channel state. */
|
||||||
struct funding funding;
|
struct funding funding;
|
||||||
/* Pending changes (for next commit_info) */
|
/* Pending changes (for next commit_info) */
|
||||||
int *changes_incoming, *changes_outgoing;
|
int *changes_incoming;
|
||||||
|
bool changes_outgoing;
|
||||||
/* Cache of funding with changes applied. */
|
/* Cache of funding with changes applied. */
|
||||||
struct funding funding_next;
|
struct funding funding_next;
|
||||||
/* Have sent/received revocation secret. */
|
/* Have sent/received revocation secret. */
|
||||||
@@ -123,10 +124,7 @@ static bool queue_changes_other(struct commit_info *ci, int *changes)
|
|||||||
&ci->funding_next.fee,
|
&ci->funding_next.fee,
|
||||||
changes[i]))
|
changes[i]))
|
||||||
return false;
|
return false;
|
||||||
add_change_internal(ci, &ci->changes_outgoing,
|
ci->changes_outgoing = true;
|
||||||
&ci->funding.outhtlcs,
|
|
||||||
&ci->funding.inhtlcs,
|
|
||||||
changes[i]);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -151,7 +149,7 @@ static struct commit_info *new_commit_info(const tal_t *ctx,
|
|||||||
struct commit_info *ci = talz(ctx, struct commit_info);
|
struct commit_info *ci = talz(ctx, struct commit_info);
|
||||||
ci->prev = prev;
|
ci->prev = prev;
|
||||||
ci->changes_incoming = tal_arr(ci, int, 0);
|
ci->changes_incoming = tal_arr(ci, int, 0);
|
||||||
ci->changes_outgoing = tal_arr(ci, int, 0);
|
ci->changes_outgoing = false;
|
||||||
if (prev) {
|
if (prev) {
|
||||||
ci->number = prev->number + 1;
|
ci->number = prev->number + 1;
|
||||||
ci->funding = prev->funding;
|
ci->funding = prev->funding;
|
||||||
@@ -217,15 +215,8 @@ static void dump_commit_info(const struct commit_info *ci)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
n = tal_count(ci->changes_outgoing);
|
if (ci->changes_outgoing) {
|
||||||
if (n > 0) {
|
printf("\n Pending outgoing");
|
||||||
printf("\n Pending outgoing:");
|
|
||||||
for (i = 0; i < n; i++) {
|
|
||||||
if (ci->changes_outgoing[i] == 0)
|
|
||||||
printf(" FEE");
|
|
||||||
else
|
|
||||||
printf(" %+i", ci->changes_outgoing[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ci->counterparty_signed)
|
if (ci->counterparty_signed)
|
||||||
@@ -334,7 +325,7 @@ static void send_commit(struct peer *peer)
|
|||||||
|
|
||||||
/* Must have changes. */
|
/* Must have changes. */
|
||||||
if (tal_count(peer->them->changes_incoming) == 0
|
if (tal_count(peer->them->changes_incoming) == 0
|
||||||
&& tal_count(peer->them->changes_outgoing) == 0)
|
&& !peer->them->changes_outgoing)
|
||||||
errx(1, "commit: no changes to commit");
|
errx(1, "commit: no changes to commit");
|
||||||
|
|
||||||
peer->them = apply_changes(peer, peer->them);
|
peer->them = apply_changes(peer, peer->them);
|
||||||
@@ -430,7 +421,7 @@ static void receive_commit(struct peer *peer, const struct signature *sig)
|
|||||||
|
|
||||||
/* Must have changes. */
|
/* Must have changes. */
|
||||||
if (tal_count(peer->us->changes_incoming) == 0
|
if (tal_count(peer->us->changes_incoming) == 0
|
||||||
&& tal_count(peer->us->changes_outgoing) == 0)
|
&& !peer->us->changes_outgoing)
|
||||||
errx(1, "receive_commit: no changes to commit");
|
errx(1, "receive_commit: no changes to commit");
|
||||||
|
|
||||||
peer->us = apply_changes(peer, peer->us);
|
peer->us = apply_changes(peer, peer->us);
|
||||||
|
|||||||
Reference in New Issue
Block a user