sets defaults on the config
(cfg *Config)
| 50 | |
| 51 | // sets defaults on the config |
| 52 | func 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. |