lnwallet/channel: make ErrCommitSyncLocalDataLoss type

This commit converts the ErrCommitSyncLocalDataLoss error into a struct,
that also holds the received last unrevoked commit point from the remote
party.
This commit is contained in:
Johan T. Halseth
2019-09-06 13:14:39 +02:00
parent d75feeb953
commit f40f4620f7
3 changed files with 37 additions and 14 deletions

View File

@@ -895,6 +895,11 @@ func (l *channelLink) htlcManager() {
if l.cfg.SyncStates {
err := l.syncChanStates()
if err != nil {
log.Warnf("Error when syncing channel states: %v", err)
_, localDataLoss :=
err.(*lnwallet.ErrCommitSyncLocalDataLoss)
switch {
case err == ErrLinkShuttingDown:
log.Debugf("unable to sync channel states, " +
@@ -936,7 +941,7 @@ func (l *channelLink) htlcManager() {
// TODO(halseth): mark this, such that we prevent
// channel from being force closed by the user or
// contractcourt etc.
case err == lnwallet.ErrCommitSyncLocalDataLoss:
case localDataLoss:
// We determined the commit chains were not possible to
// sync. We cautiously fail the channel, but don't