From e19d5751fe1042294c1ee69f80bc627350600ead Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 18 Aug 2016 14:23:46 +0930 Subject: [PATCH] peer: remove commit_info's prev pointer. This is the final step before removing old commit_infos entirely. Signed-off-by: Rusty Russell --- daemon/peer.c | 8 ++++---- daemon/peer.h | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/daemon/peer.c b/daemon/peer.c index 9c2b597d4..b77ba6e02 100644 --- a/daemon/peer.c +++ b/daemon/peer.c @@ -765,8 +765,7 @@ static Pkt *handle_pkt_commit(struct peer *peer, const Pkt *pkt) return pkt_err(peer, "Empty commit"); /* Create new commit info for this commit tx. */ - ci->prev = peer->local.commit; - ci->commit_num = ci->prev->commit_num + 1; + ci->commit_num = peer->local.commit->commit_num + 1; ci->revocation_hash = peer->local.next_revocation_hash; /* BOLT #2: @@ -795,6 +794,7 @@ static Pkt *handle_pkt_commit(struct peer *peer, const Pkt *pkt) return pkt_err(peer, "Bad signature"); /* Switch to the new commitment. */ + tal_free(peer->local.commit); peer->local.commit = ci; peer_get_revocation_hash(peer, ci->commit_num + 1, &peer->local.next_revocation_hash); @@ -1520,8 +1520,7 @@ static void do_commit(struct peer *peer, struct command *jsoncmd) fatal("sent commit with no changes"); /* Create new commit info for this commit tx. */ - ci->prev = peer->remote.commit; - ci->commit_num = ci->prev->commit_num + 1; + ci->commit_num = peer->remote.commit->commit_num + 1; ci->revocation_hash = peer->remote.next_revocation_hash; /* BOLT #2: * @@ -1546,6 +1545,7 @@ static void do_commit(struct peer *peer, struct command *jsoncmd) peer_sign_theircommit(peer, ci->tx, &ci->sig->sig); /* Switch to the new commitment. */ + tal_free(peer->remote.commit); peer->remote.commit = ci; peer_add_their_commit(peer, &ci->txid, ci->commit_num); diff --git a/daemon/peer.h b/daemon/peer.h index b91fba8ae..57e16951b 100644 --- a/daemon/peer.h +++ b/daemon/peer.h @@ -39,8 +39,6 @@ struct their_commit { }; struct commit_info { - /* Previous one, if any. */ - struct commit_info *prev; /* Commit number (0 == from open) */ u64 commit_num; /* Revocation hash. */