Skip to content

Commit

Permalink
Validator improvements. (#569)
Browse files Browse the repository at this point in the history
- Add retry count to error results.
- Add early exit to retry loop when the rounds are equal.
  • Loading branch information
winder authored Jul 13, 2021
1 parent 3047583 commit 17ddbea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions cmd/validator/struct_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ func (gp StructProcessor) ProcessAddress(algodData, indexerData []byte) (Result,
differences := equals(indexerAcct, algodAcct)
if len(differences) > 0 {
return Result{
Equal: false,
Retries: 0,
Equal: false,
SameRound: indexerAcct.Round == algodAcct.Round,
Retries: 0,
Details: &ErrorDetails{
algod: mustEncode(algodAcct),
indexer: mustEncode(indexerAcct),
Expand Down
7 changes: 5 additions & 2 deletions cmd/validator/validate_accounting.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ type Processor interface {
// Result is the output of ProcessAddress.
type Result struct {
// Error is set if there were errors running the test.
Error error
Error error
SameRound bool

Equal bool
Retries int
Expand Down Expand Up @@ -235,7 +236,7 @@ func callProcessor(processor Processor, addrInput string, config Params, results

result, err := processor.ProcessAddress(algodData, indexerData)

if err == nil && (result.Equal || i >= config.retries) {
if err == nil && (result.Equal || result.SameRound || i >= config.retries) {
// Return when results are equal, or when finished retrying.
result.Retries = i
if result.Details != nil {
Expand Down Expand Up @@ -318,6 +319,8 @@ func resultsPrinter(config Params, printCurl bool, results <-chan Result) int {
errorLog.Printf("%s", time.Now().Format("2006-01-02 3:4:5 PM"))
errorLog.Printf("Account: %s", r.Details.address)
errorLog.Printf("Error #: %d", numErrors)
errorLog.Printf("Retries: %d", r.Retries)
errorLog.Printf("Rounds Match: %t", r.SameRound)

// Print error message if there is one.
if r.Error != nil {
Expand Down

0 comments on commit 17ddbea

Please sign in to comment.