-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b6ef673
commit f389954
Showing
6 changed files
with
61 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
package app | ||
|
||
import "github.com/cybercongress/cyberd/x/rank" | ||
import ( | ||
"github.com/cybercongress/cyberd/x/debug" | ||
"github.com/cybercongress/cyberd/x/rank" | ||
) | ||
|
||
type Options struct { | ||
// main options | ||
ComputeUnit rank.ComputeUnit | ||
AllowSearch bool | ||
|
||
// debug options | ||
FailBeforeHeight int64 | ||
Debug debug.Options | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package debug | ||
|
||
import ( | ||
abci "github.com/tendermint/tendermint/abci/types" | ||
"github.com/tendermint/tendermint/libs/log" | ||
"math/rand" | ||
"os" | ||
) | ||
|
||
func BeginBlocker(state *State, req abci.RequestBeginBlock, log log.Logger) { | ||
|
||
if state.Opts.FailRandomlyInNextNBlocks != 0 { | ||
randNum := rand.Int63n(state.Opts.FailRandomlyInNextNBlocks) + 1 | ||
state.Opts.FailBeforeBlock = state.StartupBlock + randNum | ||
state.Opts.FailRandomlyInNextNBlocks = 0 | ||
log.Info("Scheduled forced panic at begin blocker ", "height", state.Opts.FailBeforeBlock) | ||
} | ||
|
||
failBeforeBlock := state.Opts.FailBeforeBlock | ||
if failBeforeBlock != 0 && req.Header.Height == failBeforeBlock { | ||
log.Info("Forced panic at begin blocker", "height", failBeforeBlock) | ||
os.Exit(1) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package debug | ||
|
||
type Options struct { | ||
FailBeforeBlock int64 | ||
FailRandomlyInNextNBlocks int64 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package debug | ||
|
||
type State struct { | ||
Opts Options | ||
StartupBlock int64 | ||
} |