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.
|
|
|
||
| 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.
create global constant error using errors.New(), and use it here.
| prevProto, ok := config.Consensus[prevHeader.CurrentProtocol] | ||
| if !ok { | ||
| return nil, protocol.Error(prevHeader.CurrentProtocol) | ||
| } |
There was a problem hiding this comment.
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.
tsachiherman
left a comment
There was a problem hiding this comment.
few small requests, but looks good otherwise.
|
I personally do not see any value in this change. |
winder
left a comment
There was a problem hiding this comment.
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
|
tsachiherman
left a comment
There was a problem hiding this comment.
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.