| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- package ethapi
- import (
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/hexutil"
- "github.com/ethereum/go-ethereum/core/vm"
- )
- // BlockOverrides is a set of header fields to override.
- type BlockOverrides struct {
- Number *hexutil.Big
- Difficulty *hexutil.Big
- Time *hexutil.Big
- GasLimit *hexutil.Uint64
- Coinbase *common.Address
- Random *common.Hash
- BaseFee *hexutil.Big
- }
- // Apply overrides the given header fields into the given block context.
- func (diff *BlockOverrides) Apply(blockCtx *vm.BlockContext) {
- if diff == nil {
- return
- }
- if diff.Number != nil {
- blockCtx.BlockNumber = diff.Number.ToInt()
- }
- if diff.Difficulty != nil {
- blockCtx.Difficulty = diff.Difficulty.ToInt()
- }
- if diff.Time != nil {
- blockCtx.Time = diff.Time.ToInt()
- }
- if diff.GasLimit != nil {
- blockCtx.GasLimit = uint64(*diff.GasLimit)
- }
- if diff.Coinbase != nil {
- blockCtx.Coinbase = *diff.Coinbase
- }
- if diff.Random != nil {
- blockCtx.Random = diff.Random
- }
- if diff.BaseFee != nil {
- blockCtx.BaseFee = diff.BaseFee.ToInt()
- }
- }
|