-
Notifications
You must be signed in to change notification settings - Fork 324
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
unify workingset api #1702
unify workingset api #1702
Conversation
return stx.runAction(protocol.MustGetRunActionsCtx(ctx), elp) | ||
} | ||
|
||
func (stx *stateTX) runAction( |
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.
107-143 lines are duplicate of state/factory/workingset.go:176-213
(from dupl
)
return ws.runAction(protocol.MustGetRunActionsCtx(ctx), elp) | ||
} | ||
|
||
func (ws *workingSet) runAction( |
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.
176-213 lines are duplicate of state/factory/statetx.go:107-143
(from dupl
)
} | ||
} | ||
stx.UpdateBlockLevelInfo(blockHeight) | ||
return receipts, nil | ||
} | ||
|
||
// RunAction runs action in the block and track pending changes in working set | ||
func (stx *stateTX) RunAction( | ||
func (stx *stateTX) RunAction(ctx context.Context, elp action.SealedEnvelope) (*action.Receipt, error) { |
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.
hugeParam: elp is heavy (88 bytes); consider passing it by pointer (from gocritic
)
func (ws *workingSet) RunAction( | ||
ctx context.Context, | ||
elp action.SealedEnvelope, |
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.
hugeParam: elp is heavy (88 bytes); consider passing it by pointer (from gocritic
)
blockchain/blockchain.go
Outdated
@@ -928,7 +929,7 @@ func (bc *blockchain) pickAndRunActions(ctx context.Context, actionMap map[strin | |||
switch errors.Cause(err) { | |||
case nil: | |||
if !skip { | |||
receipt, err := ws.RunAction(raCtx, putPollResult) | |||
receipt, err := ws.RunAction(ctx, putPollResult) |
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.
shadow: declaration of "err" shadows declaration at line 928 (from govet
)
Codecov Report
@@ Coverage Diff @@
## master #1702 +/- ##
==========================================
- Coverage 55.32% 55.21% -0.12%
==========================================
Files 155 155
Lines 13476 13496 +20
==========================================
- Hits 7456 7452 -4
- Misses 5061 5071 +10
- Partials 959 973 +14
Continue to review full report at Codecov.
|
8eaa6a5
to
3289d0e
Compare
// Finalize runs action in the block and track pending changes in working set | ||
func (stx *stateTX) Finalize() error { | ||
if stx.finalized { | ||
return errors.New("Cannot finalize a working set twice") |
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.
error strings should not be capitalized or end with punctuation or a newline (from golint
)
// Finalize runs action in the block and track pending changes in working set | ||
func (ws *workingSet) Finalize() error { | ||
if ws.finalized { | ||
return errors.New("Cannot finalize a working set twice") |
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.
error strings should not be capitalized or end with punctuation or a newline (from golint
)
|
||
func (ws *workingSet) runAction( | ||
ctx context.Context, | ||
elp action.SealedEnvelope, |
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.
hugeParam: elp is heavy (88 bytes); consider passing it by pointer (from gocritic
)
if err != nil { | ||
return err | ||
} | ||
if err = blk.VerifyDeltaStateDigest(digest); err != nil { |
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.
sloppyReassign: re-assignment to err
can be replaced with err := blk.VerifyDeltaStateDigest(digest)
(from gocritic
)
@@ -259,32 +246,41 @@ func testState(sf Factory, t *testing.T) { | |||
registry := protocol.NewRegistry() | |||
acc := account.NewProtocol() | |||
require.NoError(t, registry.Register(account.ProtocolID, acc)) | |||
require.NoError(t, sf.Start(context.Background())) | |||
ge := genesis.Default | |||
ge.InitBalanceMap[a] = "100" |
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.
string 100
has 2 occurrences, make it a constant (from goconst
)
@@ -84,19 +83,19 @@ func TestActPool_NewActPool(t *testing.T) { | |||
|
|||
func TestActPool_validateGenericAction(t *testing.T) { | |||
require := require.New(t) | |||
cfg := config.Default | |||
cfg.Genesis.InitBalanceMap[addr1] = "100" |
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.
string 100
has 13 occurrences, make it a constant (from goconst
)
require.NoError(registry.Register(account.ProtocolID, account.NewProtocol())) | ||
cfg := config.Default | ||
cfg.Genesis.InitBalanceMap[addr1] = "100" | ||
cfg.Genesis.InitBalanceMap[addr2] = "10" |
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.
string 10
has 3 occurrences, make it a constant (from goconst
)
3289d0e
to
f2ff65b
Compare
Test Plan:
make mockgen && make test && make minicluster