-
Notifications
You must be signed in to change notification settings - Fork 450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify startEvaluator()
#2812
Simplify startEvaluator()
#2812
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2812 +/- ##
=======================================
Coverage 47.11% 47.11%
=======================================
Files 349 349
Lines 56424 56424
=======================================
+ Hits 26582 26583 +1
- Misses 26865 26868 +3
+ Partials 2977 2973 -4
Continue to review full report at Codecov.
|
ledger/eval.go
Outdated
@@ -383,20 +383,32 @@ func (l *Ledger) StartEvaluator(hdr bookkeeping.BlockHeader, paysetHint int) (*B | |||
} | |||
|
|||
func startEvaluator(l ledgerForEvaluator, hdr bookkeeping.BlockHeader, proto config.ConsensusParams, paysetHint int, validate bool, generate bool) (*BlockEvaluator, error) { | |||
if hdr.Round == 0 { | |||
return nil, fmt.Errorf("cannot start evaluator for round 0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create global constant error using errors.New(), and use it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
ledger/eval.go
Outdated
prevProto, ok := config.Consensus[prevHeader.CurrentProtocol] | ||
if !ok { | ||
return nil, protocol.Error(prevHeader.CurrentProtocol) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this section right after
prevHeader, err := l.BlockHdr(hdr.Round - 1)
if err != nil {
return nil, fmt.Errorf(
"can't evaluate block %v without previous header: %v", hdr.Round, err)
}
for further clarity. also, fix %v
-> %d
for the round number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
few small requests, but looks good otherwise.
I personally do not see any value in this change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure this function is never called on round 0? It appears that previously it would be a NoOp (or a crash?), now it's an error.
I tried using it for Indexer for round 0, I got an error. It's probably in
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
look good. thanks for the changes.
Summary
The current code creates an impression that the evaluator can be used for round 0 which is not true. This PR simplifies the code, so this is more evident.
Test Plan
Relying on existing tests.