MCPcopy Create free account
hub / github.com/CPChain/chain / setDefaults

Function setDefaults

core/vm/runtime/runtime.go:52–82  ·  view source on GitHub ↗

sets defaults on the config

(cfg *Config)

Source from the content-addressed store, hash-verified

50
51// sets defaults on the config
52func setDefaults(cfg *Config) {
53 if cfg.ChainConfig == nil {
54 cfg.ChainConfig = &configs.ChainConfig{
55 ChainID: big.NewInt(configs.MainnetChainId),
56 }
57 }
58
59 if cfg.Difficulty == nil {
60 cfg.Difficulty = new(big.Int)
61 }
62 if cfg.Time == nil {
63 cfg.Time = big.NewInt(time.Now().Unix())
64 }
65 if cfg.GasLimit == 0 {
66 cfg.GasLimit = math.MaxUint64
67 }
68 if cfg.GasPrice == nil {
69 cfg.GasPrice = new(big.Int)
70 }
71 if cfg.Value == nil {
72 cfg.Value = new(big.Int)
73 }
74 if cfg.BlockNumber == nil {
75 cfg.BlockNumber = new(big.Int)
76 }
77 if cfg.GetHashFn == nil {
78 cfg.GetHashFn = func(n uint64) common.Hash {
79 return common.BytesToHash(crypto.Keccak256([]byte(new(big.Int).SetUint64(n).String())))
80 }
81 }
82}
83
84// Execute executes the code using the input as call data during the execution.
85// It returns the EVM's return value, the new state and an error if it failed.

Callers 4

TestDefaultsFunction · 0.85
ExecuteFunction · 0.85
CreateFunction · 0.85
CallFunction · 0.85

Calls 2

NowMethod · 0.65
StringMethod · 0.45

Tested by 1

TestDefaultsFunction · 0.68