Skip to content

Commit

Permalink
improve the loop in ExecuteChannelUpgrade
Browse files Browse the repository at this point in the history
Signed-off-by: Masanori Yoshida <[email protected]>
  • Loading branch information
siburu committed Aug 30, 2024
1 parent c086416 commit ca4beb3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions core/channel-upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,22 +109,25 @@ func ExecuteChannelUpgrade(pathName string, src, dst *ProvableChain, interval ti
failures := 0
firstCall := true
for {
<-ticker.C
if !firstCall {
<-ticker.C
}

steps, err := upgradeChannelStep(src, dst, targetSrcState, targetDstState, firstCall)
if err != nil {
logger.Error("failed to create channel upgrade step", err)
return err
}

firstCall = false

if steps.Last {
logger.Info("Channel upgrade completed")
return nil
}

if !steps.Ready() {
logger.Debug("Waiting for next channel upgrade step ...")
firstCall = false
continue
}

Expand All @@ -136,7 +139,6 @@ func ExecuteChannelUpgrade(pathName string, src, dst *ProvableChain, interval ti
return err
}

firstCall = false
failures = 0
} else {
if failures++; failures > 2 {
Expand All @@ -146,7 +148,6 @@ func ExecuteChannelUpgrade(pathName string, src, dst *ProvableChain, interval ti
}

logger.Warn("Retrying transaction...")
time.Sleep(5 * time.Second)
}
}
}
Expand Down

0 comments on commit ca4beb3

Please sign in to comment.