diff --git a/cmd/otter/main.go b/cmd/otter/main.go index a030a4f..195551b 100644 --- a/cmd/otter/main.go +++ b/cmd/otter/main.go @@ -28,7 +28,12 @@ func main() { defer borDb.Close() } r := chi.NewRouter() - RouteServer(r, *cfg) + // route the server + + if !cfg.OtsServerDisable { + RouteServer(r, *cfg) + } + apiList := mycmds.APIList(db, borDb, backend, txPool, mining, ff, stateCache, blockReader, agg, *cfg) if err := cli.StartRpcServer(ctx, r, *cfg, apiList); err != nil { log.Error(err.Error()) diff --git a/cmd/otter/server.go b/cmd/otter/server.go index 7206bfa..98528d0 100644 --- a/cmd/otter/server.go +++ b/cmd/otter/server.go @@ -6,6 +6,8 @@ import ( "strings" "gfx.cafe/open/4bytes/sigs" + "gfx.cafe/open/4bytes/topics" + "gfx.cafe/open/4bytes/triemap" "github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5/middleware" "github.com/wmitsuda/otterscan/cmd/otter/cli/httpcfg" @@ -16,7 +18,8 @@ func RouteServer(r chi.Router, cfg httpcfg.HttpCfg) { filesDir := http.Dir(cfg.OtsStaticDir) r.Use(middleware.Logger) r.Use(middleware.Recoverer) - r.Handle("/signatures/{hash}", &sigs.HttpServer{}) + r.HandleFunc("/signatures/{hash}", triemap.HttpHandler(sigs.Both)) + r.HandleFunc("/topic0/{hash}", triemap.HttpHandler(topics.Both)) r.HandleFunc("/config.json", func(w http.ResponseWriter, r *http.Request) { json.NewEncoder(w).Encode(map[string]any{ "erigonURL": cfg.OtsRpcDaemonUrl, diff --git a/docker-compose.yaml b/docker-compose.yaml index 19356f0..c242b2f 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -16,4 +16,4 @@ services: --metrics --metrics.addr=0.0.0.0 --metrics.port=6064 --pprof --pprof.addr=0.0.0.0 --pprof.port=6000 ports: - - 3000:8545 + - 3001:8545 diff --git a/go.mod b/go.mod index bb775ce..bd36874 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.19 replace github.com/tendermint/tendermint => github.com/bnb-chain/tendermint v0.31.12 require ( - gfx.cafe/open/4bytes v0.0.0-20221025085909-a307043c1e5e + gfx.cafe/open/4bytes v0.0.0-20221025122240-de8bf0bf48d0 github.com/RoaringBitmap/roaring v1.2.1 github.com/go-chi/chi/v5 v5.0.7 github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d diff --git a/go.sum b/go.sum index 2371782..a17f2c2 100644 --- a/go.sum +++ b/go.sum @@ -8,6 +8,12 @@ crawshaw.io/sqlite v0.3.3-0.20210127221821-98b1f83c5508/go.mod h1:igAO5JulrQ1Dbd filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU= gfx.cafe/open/4bytes v0.0.0-20221025085909-a307043c1e5e h1:Fl+QPNlTOVAxKqSEdut5fH+/To4TPE8kg8weQ3LGzUY= gfx.cafe/open/4bytes v0.0.0-20221025085909-a307043c1e5e/go.mod h1:C0vwSYhh1b/ckPTkpq0kDXk32vU4DT5QuQwYLxO6W2c= +gfx.cafe/open/4bytes v0.0.0-20221025114135-d7c548af19db h1:M34YDF/XRgqMSV9YAamH8u599fd67SJ95v6PQxP/96o= +gfx.cafe/open/4bytes v0.0.0-20221025114135-d7c548af19db/go.mod h1:C0vwSYhh1b/ckPTkpq0kDXk32vU4DT5QuQwYLxO6W2c= +gfx.cafe/open/4bytes v0.0.0-20221025121800-1d49c2434a12 h1:DpJNnzuMmIyIB1NTNJKybdYkR4gjIV7q/WzNQMS5/J0= +gfx.cafe/open/4bytes v0.0.0-20221025121800-1d49c2434a12/go.mod h1:C0vwSYhh1b/ckPTkpq0kDXk32vU4DT5QuQwYLxO6W2c= +gfx.cafe/open/4bytes v0.0.0-20221025122240-de8bf0bf48d0 h1:LOv6iGWTv80aSGw9zb7P8varDijsj/G2s7pr32VH1d0= +gfx.cafe/open/4bytes v0.0.0-20221025122240-de8bf0bf48d0/go.mod h1:C0vwSYhh1b/ckPTkpq0kDXk32vU4DT5QuQwYLxO6W2c= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= diff --git a/package.json b/package.json index b9a8e0c..8d1436d 100644 --- a/package.json +++ b/package.json @@ -45,21 +45,16 @@ }, "scripts": { "start": "vite", - "clean": "rm -rf chains topic0 4bytes dist", + "clean": "rm -rf chains dist", "fullbuild": "npm run dl-all && npm run build", "build": "tsc && vite build", "postbuild": "npm run copy-all", "preview": "vite preview", - "dl-all":"npm run clean && npm run dl-chains && npm run dl-topic0", + "dl-all":"npm run clean && npm run dl-chains", "dl-chains": "svn checkout https://github.com/ethereum-lists/chains/trunk/_data/chains && rm -rf chains/.svn", - "dl-topic0": "git clone https://github.com/wmitsuda/topic0 && rm -rf topic0/.git", - "copy-all":"npm run copy-chains && npm run copy-topic0", + "copy-all":"npm run copy-chains", "copy-chains": "rsync -ah chains dist", - "copy-topic0": "mkdir -p dist/topic0 && rsync -ah topic0/with_parameter_names/ dist/topic0/", "source-map-explorer": "source-map-explorer build/static/js/*.js", - "assets-start": "docker run --rm -p 3001:80 --name otterscan-assets -d -v$(pwd)/4bytes/signatures:/usr/share/nginx/html/signatures/ -v$(pwd)/trustwallet/blockchains/ethereum/assets:/usr/share/nginx/html/assets/1 -v$(pwd)/topic0/with_parameter_names:/usr/share/nginx/html/topic0/ -v$(pwd)/chains/_data/chains:/usr/share/nginx/html/chains/ -v$(pwd)/nginx/nginx.conf:/etc/nginx/nginx.conf -v$(pwd)/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf nginx:1.21.1-alpine", - "assets-start-with-param-names": "docker run --rm -p 3001:80 --name otterscan-assets -d -v$(pwd)/4bytes/with_parameter_names:/usr/share/nginx/html/signatures/ -v$(pwd)/trustwallet/blockchains/ethereum/assets:/usr/share/nginx/html/assets/1 -v$(pwd)/topic0/with_parameter_names:/usr/share/nginx/html/topic0/ -v$(pwd)/chains/_data/chains:/usr/share/nginx/html/chains/ -v$(pwd)/nginx/nginx.conf:/etc/nginx/nginx.conf -v$(pwd)/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf nginx:1.21.1-alpine", - "assets-stop": "docker stop otterscan-assets", "docker-build": "docker buildx build -t otterscan .", "docker-start": "docker run --rm -p 5000:80 --name otterscan -d otterscan", "docker-stop": "docker stop otterscan"