lnwallet: add PendingUpdates method to channel state machine

This commit adds a new method, “PendingUpdates” to the channel state
machine which is intended to be a source to give callers a hint as to
when an additional commitment signature should be sent independent of
any request/response book keeping.
This commit is contained in:
Olaoluwa Osuntokun 2016-07-21 16:52:05 -07:00
parent 4063171918
commit 2bb65a3fb8
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2

@ -821,6 +821,18 @@ func (lc *LightningChannel) ReceiveNewCommitment(rawSig []byte,
return nil
}
// PendingUpdates returns a boolean value reflecting if there are any pending
// updates which need to be committed. The state machine has pending updates if
// the local log index on the local and remote chain tip aren't identical. This
// indicates that either we have pending updates they need to commit, or vice
// versa.
func (lc *LightningChannel) PendingUpdates() bool {
fullySynced := (lc.localCommitChain.tip().ourMessageIndex ==
lc.remoteCommitChain.tip().ourMessageIndex)
return !fullySynced
}
// RevokeCurrentCommitment revokes the next lowest unrevoked commitment
// transaction in the local commitment chain. As a result the edge of our
// revocation window is extended by one, and the tail of our local commitment