rename signature to selector
This commit is contained in:
parent
f4382a3d79
commit
45ae18fba2
|
@ -37,7 +37,7 @@ type callStack struct {
|
|||
type csCall struct {
|
||||
Op OpCode
|
||||
Address common.Address
|
||||
Signature []byte
|
||||
Selector []byte
|
||||
}
|
||||
|
||||
// newCallStack creates a new call stack.
|
||||
|
@ -47,14 +47,14 @@ func newCallStack() *callStack {
|
|||
|
||||
// Push pushes given call to the stack.
|
||||
func (cs *callStack) Push(op OpCode, addr common.Address, input []byte) {
|
||||
var signature []byte
|
||||
var selector []byte
|
||||
if len(input) >= 4 {
|
||||
signature = input[:4]
|
||||
selector = input[:4]
|
||||
}
|
||||
cs.calls = append(cs.calls, &csCall{
|
||||
Op: op,
|
||||
Address: addr,
|
||||
Signature: signature,
|
||||
Selector: selector,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ func (enc *callStackEncoder) Encode() ([]byte, error) {
|
|||
for _, call := range enc.calls {
|
||||
enc.appendNum(uint256.NewInt(uint64(call.Op)))
|
||||
enc.appendAddr(call.Address)
|
||||
enc.appendNum(uint256.NewInt(0).SetBytes(call.Signature))
|
||||
enc.appendNum(uint256.NewInt(0).SetBytes(call.Selector))
|
||||
}
|
||||
|
||||
return enc.result, nil
|
||||
|
|
|
@ -42,7 +42,7 @@ func benchCallStackPrecompileN(b *testing.B, n int) {
|
|||
calls = append(calls, &csCall{
|
||||
Op: OpCode(i),
|
||||
Address: common.HexToAddress("0xCdA8dcaEe60ce9d63165Ef025fD98CDA2B99B5B2"),
|
||||
Signature: []byte{0xde, 0xad, 0xbe, 0xef},
|
||||
Selector: []byte{0xde, 0xad, 0xbe, 0xef},
|
||||
})
|
||||
}
|
||||
callStack := newCallStack()
|
||||
|
@ -59,12 +59,12 @@ func TestCallStackPrecompile(t *testing.T) {
|
|||
{
|
||||
Op: OpCode(0x10),
|
||||
Address: common.HexToAddress("0xCdA8dcaEe60ce9d63165Ef025fD98CDA2B99B5B2"),
|
||||
Signature: []byte{0xab, 0xcd, 0xef, 0x12},
|
||||
Selector: []byte{0xab, 0xcd, 0xef, 0x12},
|
||||
},
|
||||
{
|
||||
Op: OpCode(0x20),
|
||||
Address: common.HexToAddress("0xCdA8dcaEe60ce9d63165Ef025fD98CDA2B99B5B2"),
|
||||
Signature: []byte{0xde, 0xad, 0xbe, 0xef},
|
||||
Selector: []byte{0xde, 0xad, 0xbe, 0xef},
|
||||
},
|
||||
}
|
||||
b, err := callStack.Run(nil)
|
||||
|
|
Loading…
Reference in New Issue