contractcourt/chain_watcher: handleKnownRemoteState

Similar to what we did for the local state handling, we extract handling
all known remote states we can act on (breach, current, pending state)
into its own method.

Since we want to handle the case where we lost state (both in case of
local and remote close) last, we don't rely on the remote state number
to check which commit we are looking at, but match on TXIDs directly.
This commit is contained in:
Johan T. Halseth
2020-11-18 22:45:35 +01:00
parent acc45934f8
commit 743ea7be74
3 changed files with 131 additions and 77 deletions

View File

@@ -163,9 +163,9 @@ var (
// channel.
ErrChanBorked = fmt.Errorf("cannot mutate borked channel")
// errLogEntryNotFound is returned when we cannot find a log entry at
// ErrLogEntryNotFound is returned when we cannot find a log entry at
// the height requested in the revocation log.
errLogEntryNotFound = fmt.Errorf("log entry not found")
ErrLogEntryNotFound = fmt.Errorf("log entry not found")
// errHeightNotFound is returned when a query for channel balances at
// a height that we have not reached yet is made.
@@ -3469,7 +3469,7 @@ func fetchChannelLogEntry(log kvdb.RBucket,
logEntrykey := makeLogKey(updateNum)
commitBytes := log.Get(logEntrykey[:])
if commitBytes == nil {
return ChannelCommitment{}, errLogEntryNotFound
return ChannelCommitment{}, ErrLogEntryNotFound
}
commitReader := bytes.NewReader(commitBytes)