Skip to content

Commit

Permalink
feat: add web3_clientVersion rpc method
Browse files Browse the repository at this point in the history
  • Loading branch information
fearlessfe authored and GrapeBaBa committed Apr 25, 2024
1 parent 88bee52 commit 7a9af46
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
7 changes: 7 additions & 0 deletions cmd/shisui/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/ethereum/go-ethereum/portalnetwork/beacon"
"github.com/ethereum/go-ethereum/portalnetwork/history"
"github.com/ethereum/go-ethereum/portalnetwork/storage"
"github.com/ethereum/go-ethereum/portalnetwork/web3"
"github.com/ethereum/go-ethereum/rpc"
_ "github.com/mattn/go-sqlite3"
"github.com/protolambda/zrnt/eth2/configs"
Expand Down Expand Up @@ -112,6 +113,12 @@ func startPortalRpcServer(config Config, conn discover.UDPConn, addr string) err
return err
}

api := &web3.API{}
err = server.RegisterName("web3", api)
if err != nil {
return err
}

if slices.Contains(config.Networks, portalwire.HistoryNetworkName) {
err = initHistory(config, server, conn, localNode, discV5)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -978,8 +978,8 @@ Please note that --` + MetricsHTTPFlag.Name + ` must be set to start the server.

PortalDataCapacityFlag = &cli.Uint64Flag{
Name: "data.capacity",
Usage: "the capacity of the data stored, the unit is byte",
Value: 1000 * 1000 * 1000 * 2, // 2 GB
Usage: "the capacity of the data stored, the unit is MB",
Value: 1000 * 10, // 10 GB
Category: flags.PortalNetworkCategory,
}

Expand Down
13 changes: 13 additions & 0 deletions portalnetwork/web3/api.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package web3

import "runtime"

type API struct{}

func (p *API) ClientVersion() string {
// TODO add version
name := "Shisui"
name += "/" + runtime.GOOS + "-" + runtime.GOARCH
name += "/" + runtime.Version()
return name
}

0 comments on commit 7a9af46

Please sign in to comment.