mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
core/vm: reuse pooled bigints for ADDRESS, ORIGIN and CALLER
This commit is contained in:
parent
bda409a02a
commit
e5945d58f0
2 changed files with 6 additions and 3 deletions
|
|
@ -205,6 +205,9 @@ func (a Address) Bytes() []byte { return a[:] }
|
|||
// Big converts an address to a big integer.
|
||||
func (a Address) Big() *big.Int { return new(big.Int).SetBytes(a[:]) }
|
||||
|
||||
// SetBig converts an address to a given big integer.
|
||||
func (a Address) SetBig(int *big.Int) *big.Int { return int.SetBytes(a[:]) }
|
||||
|
||||
// Hash converts an address to a hash by left-padding it with zeros.
|
||||
func (a Address) Hash() Hash { return BytesToHash(a[:]) }
|
||||
|
||||
|
|
|
|||
|
|
@ -405,7 +405,7 @@ func opSha3(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory
|
|||
}
|
||||
|
||||
func opAddress(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
||||
stack.push(contract.Address().Big())
|
||||
stack.push(contract.Address().SetBig(interpreter.intPool.get()))
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
|
@ -416,12 +416,12 @@ func opBalance(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memo
|
|||
}
|
||||
|
||||
func opOrigin(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
||||
stack.push(interpreter.evm.Origin.Big())
|
||||
stack.push(interpreter.evm.Origin.SetBig(interpreter.intPool.get()))
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func opCaller(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
||||
stack.push(contract.Caller().Big())
|
||||
stack.push(contract.Caller().SetBig(interpreter.intPool.get()))
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue