mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
avoid use map point
This commit is contained in:
parent
ca0813a7b7
commit
419f55d8d4
4 changed files with 23 additions and 23 deletions
|
|
@ -843,7 +843,7 @@ func TestTracingWithOverrides(t *testing.T) {
|
||||||
byte(vm.PUSH1), 00,
|
byte(vm.PUSH1), 00,
|
||||||
byte(vm.RETURN),
|
byte(vm.RETURN),
|
||||||
}),
|
}),
|
||||||
StateDiff: &map[common.Hash]common.Hash{
|
StateDiff: map[common.Hash]common.Hash{
|
||||||
common.HexToHash("0x03"): common.HexToHash("0x11"),
|
common.HexToHash("0x03"): common.HexToHash("0x11"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -908,7 +908,7 @@ func newRPCBytes(bytes []byte) *hexutil.Bytes {
|
||||||
return &rpcBytes
|
return &rpcBytes
|
||||||
}
|
}
|
||||||
|
|
||||||
func newStates(keys []common.Hash, vals []common.Hash) *map[common.Hash]common.Hash {
|
func newStates(keys []common.Hash, vals []common.Hash) map[common.Hash]common.Hash {
|
||||||
if len(keys) != len(vals) {
|
if len(keys) != len(vals) {
|
||||||
panic("invalid input")
|
panic("invalid input")
|
||||||
}
|
}
|
||||||
|
|
@ -916,7 +916,7 @@ func newStates(keys []common.Hash, vals []common.Hash) *map[common.Hash]common.H
|
||||||
for i := 0; i < len(keys); i++ {
|
for i := 0; i < len(keys); i++ {
|
||||||
m[keys[i]] = vals[i]
|
m[keys[i]] = vals[i]
|
||||||
}
|
}
|
||||||
return &m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTraceChain(t *testing.T) {
|
func TestTraceChain(t *testing.T) {
|
||||||
|
|
|
||||||
|
|
@ -432,7 +432,7 @@ type StructLogRes struct {
|
||||||
Stack *[]string `json:"stack,omitempty"`
|
Stack *[]string `json:"stack,omitempty"`
|
||||||
ReturnData string `json:"returnData,omitempty"`
|
ReturnData string `json:"returnData,omitempty"`
|
||||||
Memory *[]string `json:"memory,omitempty"`
|
Memory *[]string `json:"memory,omitempty"`
|
||||||
Storage *map[string]string `json:"storage,omitempty"`
|
Storage map[string]string `json:"storage,omitempty"`
|
||||||
RefundCounter uint64 `json:"refund,omitempty"`
|
RefundCounter uint64 `json:"refund,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -471,7 +471,7 @@ func formatLogs(logs []StructLog) []StructLogRes {
|
||||||
for i, storageValue := range trace.Storage {
|
for i, storageValue := range trace.Storage {
|
||||||
storage[fmt.Sprintf("%x", i)] = fmt.Sprintf("%x", storageValue)
|
storage[fmt.Sprintf("%x", i)] = fmt.Sprintf("%x", storageValue)
|
||||||
}
|
}
|
||||||
formatted[index].Storage = &storage
|
formatted[index].Storage = storage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return formatted
|
return formatted
|
||||||
|
|
|
||||||
|
|
@ -971,8 +971,8 @@ type OverrideAccount struct {
|
||||||
Nonce *hexutil.Uint64 `json:"nonce"`
|
Nonce *hexutil.Uint64 `json:"nonce"`
|
||||||
Code *hexutil.Bytes `json:"code"`
|
Code *hexutil.Bytes `json:"code"`
|
||||||
Balance **hexutil.Big `json:"balance"`
|
Balance **hexutil.Big `json:"balance"`
|
||||||
State *map[common.Hash]common.Hash `json:"state"`
|
State map[common.Hash]common.Hash `json:"state"`
|
||||||
StateDiff *map[common.Hash]common.Hash `json:"stateDiff"`
|
StateDiff map[common.Hash]common.Hash `json:"stateDiff"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// StateOverride is the collection of overridden accounts.
|
// StateOverride is the collection of overridden accounts.
|
||||||
|
|
@ -1002,11 +1002,11 @@ func (diff *StateOverride) Apply(statedb *state.StateDB) error {
|
||||||
}
|
}
|
||||||
// Replace entire state if caller requires.
|
// Replace entire state if caller requires.
|
||||||
if account.State != nil {
|
if account.State != nil {
|
||||||
statedb.SetStorage(addr, *account.State)
|
statedb.SetStorage(addr, account.State)
|
||||||
}
|
}
|
||||||
// Apply state diff into specified accounts.
|
// Apply state diff into specified accounts.
|
||||||
if account.StateDiff != nil {
|
if account.StateDiff != nil {
|
||||||
for key, value := range *account.StateDiff {
|
for key, value := range account.StateDiff {
|
||||||
statedb.SetState(addr, key, value)
|
statedb.SetState(addr, key, value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -904,7 +904,7 @@ func TestCall(t *testing.T) {
|
||||||
overrides: StateOverride{
|
overrides: StateOverride{
|
||||||
randomAccounts[2].addr: OverrideAccount{
|
randomAccounts[2].addr: OverrideAccount{
|
||||||
Code: hex2Bytes("6080604052348015600f57600080fd5b506004361060285760003560e01c80638381f58a14602d575b600080fd5b60336049565b6040518082815260200191505060405180910390f35b6000548156fea2646970667358221220eab35ffa6ab2adfe380772a48b8ba78e82a1b820a18fcb6f59aa4efb20a5f60064736f6c63430007040033"),
|
Code: hex2Bytes("6080604052348015600f57600080fd5b506004361060285760003560e01c80638381f58a14602d575b600080fd5b60336049565b6040518082815260200191505060405180910390f35b6000548156fea2646970667358221220eab35ffa6ab2adfe380772a48b8ba78e82a1b820a18fcb6f59aa4efb20a5f60064736f6c63430007040033"),
|
||||||
StateDiff: &map[common.Hash]common.Hash{{}: common.BigToHash(big.NewInt(123))},
|
StateDiff: map[common.Hash]common.Hash{{}: common.BigToHash(big.NewInt(123))},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
want: "0x000000000000000000000000000000000000000000000000000000000000007b",
|
want: "0x000000000000000000000000000000000000000000000000000000000000007b",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue