mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-25 04:57:17 +00:00
4bfcc1ee5c
Useful for integration with external tools as one can just utilize an interface opposed to having to import and build a real EVM object.
37 lines
1.0 KiB
Go
37 lines
1.0 KiB
Go
package commands
|
|
|
|
import (
|
|
"bytes"
|
|
|
|
"github.com/holiman/uint256"
|
|
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
|
|
|
"github.com/ledgerwatch/erigon/core/vm"
|
|
)
|
|
|
|
type TouchTracer struct {
|
|
DefaultTracer
|
|
searchAddr libcommon.Address
|
|
Found bool
|
|
}
|
|
|
|
func NewTouchTracer(searchAddr libcommon.Address) *TouchTracer {
|
|
return &TouchTracer{
|
|
searchAddr: searchAddr,
|
|
}
|
|
}
|
|
|
|
func (t *TouchTracer) captureStartOrEnter(from, to libcommon.Address) {
|
|
if !t.Found && (bytes.Equal(t.searchAddr.Bytes(), from.Bytes()) || bytes.Equal(t.searchAddr.Bytes(), to.Bytes())) {
|
|
t.Found = true
|
|
}
|
|
}
|
|
|
|
func (t *TouchTracer) CaptureStart(env vm.VMInterface, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) {
|
|
t.captureStartOrEnter(from, to)
|
|
}
|
|
|
|
func (t *TouchTracer) CaptureEnter(typ vm.OpCode, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) {
|
|
t.captureStartOrEnter(from, to)
|
|
}
|