Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use context.Context in workingset run actions (#296)
- Loading branch information
Yutong Pei
committed
Nov 7, 2018
1 parent
7f8f108
commit a4c1d6d
Showing
15 changed files
with
278 additions
and
106 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (c) 2018 IoTeX | ||
// This is an alpha (internal) release and is not suitable for production. This source code is provided 'as is' and no | ||
// warranties are given as to title or non-infringement, merchantability or fitness for purpose and, to the extent | ||
// permitted by law, all liability for your use of the code is disclaimed. This source code is governed by Apache | ||
// License 2.0 that can be found in the LICENSE file. | ||
|
||
package state | ||
|
||
import "context" | ||
|
||
type runActionsCtxKey struct{} | ||
|
||
// RunActionsCtx provides the runactions with auxiliary information. | ||
type RunActionsCtx struct { | ||
// producer who compose those actions | ||
ProducerAddr string | ||
|
||
// gas Limit for perform those actions | ||
GasLimit *uint64 | ||
|
||
// whether disable gas charge | ||
EnableGasCharge bool | ||
} | ||
|
||
// WithRunActionsCtx add RunActionsCtx into context. | ||
func WithRunActionsCtx(ctx context.Context, ra RunActionsCtx) context.Context { | ||
return context.WithValue(ctx, runActionsCtxKey{}, ra) | ||
} | ||
|
||
func getRunActionsCtx(ctx context.Context) (RunActionsCtx, bool) { | ||
ra, ok := ctx.Value(runActionsCtxKey{}).(RunActionsCtx) | ||
return ra, ok | ||
} |
Oops, something went wrong.