feat: add web3_clientVersion rpc method

This commit is contained in:
fearlessfe 2024-04-24 23:14:49 +08:00 committed by Chen Kai
parent 88bee52e81
commit 7a9af4697e
3 changed files with 22 additions and 2 deletions

View file

@ -23,6 +23,7 @@ import (
"github.com/ethereum/go-ethereum/portalnetwork/beacon" "github.com/ethereum/go-ethereum/portalnetwork/beacon"
"github.com/ethereum/go-ethereum/portalnetwork/history" "github.com/ethereum/go-ethereum/portalnetwork/history"
"github.com/ethereum/go-ethereum/portalnetwork/storage" "github.com/ethereum/go-ethereum/portalnetwork/storage"
"github.com/ethereum/go-ethereum/portalnetwork/web3"
"github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/rpc"
_ "github.com/mattn/go-sqlite3" _ "github.com/mattn/go-sqlite3"
"github.com/protolambda/zrnt/eth2/configs" "github.com/protolambda/zrnt/eth2/configs"
@ -112,6 +113,12 @@ func startPortalRpcServer(config Config, conn discover.UDPConn, addr string) err
return err return err
} }
api := &web3.API{}
err = server.RegisterName("web3", api)
if err != nil {
return err
}
if slices.Contains(config.Networks, portalwire.HistoryNetworkName) { if slices.Contains(config.Networks, portalwire.HistoryNetworkName) {
err = initHistory(config, server, conn, localNode, discV5) err = initHistory(config, server, conn, localNode, discV5)
if err != nil { if err != nil {

View file

@ -978,8 +978,8 @@ Please note that --` + MetricsHTTPFlag.Name + ` must be set to start the server.
PortalDataCapacityFlag = &cli.Uint64Flag{ PortalDataCapacityFlag = &cli.Uint64Flag{
Name: "data.capacity", Name: "data.capacity",
Usage: "the capacity of the data stored, the unit is byte", Usage: "the capacity of the data stored, the unit is MB",
Value: 1000 * 1000 * 1000 * 2, // 2 GB Value: 1000 * 10, // 10 GB
Category: flags.PortalNetworkCategory, Category: flags.PortalNetworkCategory,
} }

13
portalnetwork/web3/api.go Normal file
View file

@ -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
}