eth/tracers: migrate go-bindata to embed #24744 (#1279)

This commit is contained in:
Daniel Liu 2025-09-08 20:57:23 +08:00 committed by GitHub
parent 44bd05a732
commit ba2d72e8d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 24 additions and 444 deletions

File diff suppressed because one or more lines are too long

View file

@ -14,8 +14,10 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
//go:generate go run github.com/kevinburke/go-bindata/go-bindata -nometadata -o assets.go -pkg tracers -ignore tracers.go -ignore assets.go ./...
//go:generate gofmt -s -w assets.go
// Package tracers contains the actual JavaScript tracer assets.
package tracers
import "embed"
//go:embed *.js
var FS embed.FS

View file

@ -21,6 +21,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/fs"
"math/big"
"strings"
"sync/atomic"
@ -51,9 +52,23 @@ var assetTracers = make(map[string]string)
// init retrieves the JavaScript transaction tracers included in go-ethereum.
func init() {
for _, file := range tracers.AssetNames() {
name := camel(strings.TrimSuffix(file, ".js"))
assetTracers[name] = string(tracers.MustAsset(file))
err := fs.WalkDir(tracers.FS, ".", func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
if d.IsDir() {
return nil
}
b, err := fs.ReadFile(tracers.FS, path)
if err != nil {
return err
}
name := camel(strings.TrimSuffix(path, ".js"))
assetTracers[name] = string(b)
return nil
})
if err != nil {
panic(err)
}
tracers2.RegisterLookup(true, newJsTracer)
}
@ -685,7 +700,7 @@ func (jst *jsTracer) CaptureTxStart(gasLimit uint64) {
jst.gasLimit = gasLimit
}
// CaptureTxStart implements the Tracer interface and is invoked at the end of
// CaptureTxEnd implements the Tracer interface and is invoked at the end of
// transaction processing.
func (*jsTracer) CaptureTxEnd(restGas uint64) {}