Skip to content

Commit

Permalink
fix: wait after pruning. (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherbrumm authored Jan 31, 2024
1 parent e4fd80a commit ef1d7ca
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION := v0.3.3
VERSION := v0.3.5

ldflags := $(LDFLAGS)
ldflags += -X main.version=$(VERSION)
Expand Down
2 changes: 1 addition & 1 deletion cmd/supervysor/commands/prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func init() {
panic(fmt.Errorf("flag 'home' should be required: %w", err))
}

pruneCmd.Flags().Int64Var(&untilHeight, "until-height", 0, "prune blocks until specified height (excluding)")
pruneCmd.Flags().Int64Var(&untilHeight, "until-height", 0, "prune until specified height (excluding)")
if err := pruneCmd.MarkFlagRequired("until-height"); err != nil {
panic(fmt.Errorf("flag 'until-height' should be required: %w", err))
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/supervysor/commands/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,20 +130,20 @@ var startCmd = &cobra.Command{
if nodeHeight < poolHeight {
pruneHeight = nodeHeight
}
logger.Info("pruning blocks after node shutdown", "until-height", pruneHeight)
logger.Info("pruning after node shutdown", "until-height", pruneHeight)

err = e.PruneData(supervysorConfig.HomePath, pruneHeight-1, supervysorConfig.StatePruning, binaryFlags)
if err != nil {
logger.Error("could not prune blocks", "err", err)
logger.Error("could not prune", "err", err)
return err
}
} else {
if nodeHeight < poolHeight {
logger.Info("pruning blocks after node shutdown", "until-height", nodeHeight)
logger.Info("pruning after node shutdown", "until-height", nodeHeight)

err = e.PruneData(supervysorConfig.HomePath, nodeHeight-1, supervysorConfig.StatePruning, binaryFlags)
if err != nil {
logger.Error("could not prune blocks", "err", err)
logger.Error("could not prune", "err", err)
return err
}
}
Expand Down
8 changes: 5 additions & 3 deletions executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,12 @@ func (e *Executor) PruneData(homePath string, pruneHeight int, statePruning bool
}
err := store.Prune(homePath, int64(pruneHeight)-1, statePruning, e.Logger)
if err != nil {
e.Logger.Error("could not prune blocks, exiting")
e.Logger.Error("could not prune, exiting")
return err
}

time.Sleep(time.Second * time.Duration(10))

if e.Process.GhostMode {
process, err := node.StartGhostNode(e.Cfg, e.Logger, &e.Process, true, flags)
if err != nil {
Expand All @@ -113,7 +115,7 @@ func (e *Executor) PruneData(homePath string, pruneHeight int, statePruning bool
if process != nil && process.Pid > 0 {
e.Process.Id = process.Pid
e.Process.GhostMode = true
e.Logger.Info("node started in GhostMode after pruning blocks")
e.Logger.Info("node started in GhostMode after pruning")
} else {
return fmt.Errorf("enabling Ghost Mode failed: process is not defined")
}
Expand All @@ -126,7 +128,7 @@ func (e *Executor) PruneData(homePath string, pruneHeight int, statePruning bool
if process != nil && process.Pid > 0 {
e.Process.Id = process.Pid
e.Process.GhostMode = false
e.Logger.Info("Node started in Normal Mode after pruning blocks", "pId", process.Pid)
e.Logger.Info("Node started in Normal Mode after pruning", "pId", process.Pid)
} else {
return fmt.Errorf("GhostMode disabling failed: process is not defined")
}
Expand Down

0 comments on commit ef1d7ca

Please sign in to comment.