@@ -2,7 +2,6 @@ package lnwallet
22
33import (
44 "bytes"
5- "container/list"
65 "crypto/sha256"
76 "errors"
87 "fmt"
@@ -768,61 +767,6 @@ func (lc *LightningChannel) diskCommitToMemCommit(isLocal bool,
768767 return commit , nil
769768}
770769
771- // commitmentChain represents a chain of unrevoked commitments. The tail of the
772- // chain is the latest fully signed, yet unrevoked commitment. Two chains are
773- // tracked, one for the local node, and another for the remote node. New
774- // commitments we create locally extend the remote node's chain, and vice
775- // versa. Commitment chains are allowed to grow to a bounded length, after
776- // which the tail needs to be "dropped" before new commitments can be received.
777- // The tail is "dropped" when the owner of the chain sends a revocation for the
778- // previous tail.
779- type commitmentChain struct {
780- // commitments is a linked list of commitments to new states. New
781- // commitments are added to the end of the chain with increase height.
782- // Once a commitment transaction is revoked, the tail is incremented,
783- // freeing up the revocation window for new commitments.
784- commitments * list.List
785- }
786-
787- // newCommitmentChain creates a new commitment chain.
788- func newCommitmentChain () * commitmentChain {
789- return & commitmentChain {
790- commitments : list .New (),
791- }
792- }
793-
794- // addCommitment extends the commitment chain by a single commitment. This
795- // added commitment represents a state update proposed by either party. Once
796- // the commitment prior to this commitment is revoked, the commitment becomes
797- // the new defacto state within the channel.
798- func (s * commitmentChain ) addCommitment (c * commitment ) {
799- s .commitments .PushBack (c )
800- }
801-
802- // advanceTail reduces the length of the commitment chain by one. The tail of
803- // the chain should be advanced once a revocation for the lowest unrevoked
804- // commitment in the chain is received.
805- func (s * commitmentChain ) advanceTail () {
806- s .commitments .Remove (s .commitments .Front ())
807- }
808-
809- // tip returns the latest commitment added to the chain.
810- func (s * commitmentChain ) tip () * commitment {
811- return s .commitments .Back ().Value .(* commitment )
812- }
813-
814- // tail returns the lowest unrevoked commitment transaction in the chain.
815- func (s * commitmentChain ) tail () * commitment {
816- return s .commitments .Front ().Value .(* commitment )
817- }
818-
819- // hasUnackedCommitment returns true if the commitment chain has more than one
820- // entry. The tail of the commitment chain has been ACKed by revoking all prior
821- // commitments, but any subsequent commitments have not yet been ACKed.
822- func (s * commitmentChain ) hasUnackedCommitment () bool {
823- return s .commitments .Front () != s .commitments .Back ()
824- }
825-
826770// LightningChannel implements the state machine which corresponds to the
827771// current commitment protocol wire spec. The state machine implemented allows
828772// for asynchronous fully desynchronized, batched+pipelined updates to
0 commit comments