-
Notifications
You must be signed in to change notification settings - Fork 324
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor evm function parameters by HelperContext
- Loading branch information
Showing
9 changed files
with
102 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package evm | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/iotexproject/iotex-core/pkg/log" | ||
) | ||
|
||
type ( | ||
helperContextKey struct{} | ||
|
||
// HelperContext is the context for EVM helper | ||
HelperContext struct { | ||
GetBlockHash GetBlockHash | ||
DepositGasFunc DepositGasWithSGD | ||
// TODO: sgd should be moved into depositGasFunc | ||
Sgd SGDRegistry | ||
} | ||
) | ||
|
||
// WithHelperCtx returns a new context with helper context | ||
func WithHelperCtx(ctx context.Context, hctx HelperContext) context.Context { | ||
return context.WithValue(ctx, helperContextKey{}, hctx) | ||
} | ||
|
||
// mustGetHelperCtx returns the helper context from the context | ||
func mustGetHelperCtx(ctx context.Context) HelperContext { | ||
hc, ok := ctx.Value(helperContextKey{}).(HelperContext) | ||
if !ok { | ||
log.S().Panic("Miss evm helper context") | ||
} | ||
return hc | ||
} |
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
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
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
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