mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-31 16:21:21 +00:00
net api service (#933)
This commit is contained in:
parent
081d02920d
commit
6976f58f6a
@ -139,6 +139,7 @@ func GetAPI(db ethdb.KV, eth ethdb.Backend, enabledApis []string) []rpc.API {
|
||||
dbReader := ethdb.NewObjectDatabase(db)
|
||||
chainContext := NewChainContext(dbReader)
|
||||
apiImpl := NewAPI(db, dbReader, chainContext, eth)
|
||||
netImpl := NewNetAPIImpl(eth)
|
||||
dbgAPIImpl := NewPrivateDebugAPI(db, dbReader, chainContext)
|
||||
|
||||
for _, enabledAPI := range enabledApis {
|
||||
@ -157,6 +158,13 @@ func GetAPI(db ethdb.KV, eth ethdb.Backend, enabledApis []string) []rpc.API {
|
||||
Service: PrivateDebugAPI(dbgAPIImpl),
|
||||
Version: "1.0",
|
||||
})
|
||||
case "net":
|
||||
rpcAPI = append(rpcAPI, rpc.API{
|
||||
Namespace: "net",
|
||||
Public: true,
|
||||
Service: NetAPI(netImpl),
|
||||
Version: "1.0",
|
||||
})
|
||||
|
||||
default:
|
||||
log.Error("Unrecognised", "api", enabledAPI)
|
||||
|
@ -17,7 +17,6 @@ import (
|
||||
// EthAPI is a collection of functions that are exposed in the
|
||||
type EthAPI interface {
|
||||
Coinbase(ctx context.Context) (common.Address, error)
|
||||
NetVersion(ctx context.Context) uint64
|
||||
BlockNumber(ctx context.Context) (hexutil.Uint64, error)
|
||||
GetBlockByNumber(ctx context.Context, number rpc.BlockNumber, fullTx bool) (map[string]interface{}, error)
|
||||
GetBalance(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Big, error)
|
||||
|
22
cmd/rpcdaemon/commands/net.go
Normal file
22
cmd/rpcdaemon/commands/net.go
Normal file
@ -0,0 +1,22 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/ledgerwatch/turbo-geth/ethdb"
|
||||
)
|
||||
|
||||
type NetAPI interface {
|
||||
Version(ctx context.Context) uint64
|
||||
}
|
||||
|
||||
type NetAPIImpl struct {
|
||||
ethBackend ethdb.Backend
|
||||
}
|
||||
|
||||
// NwtNetAPIImpl returns NetAPIImplImpl instance
|
||||
func NewNetAPIImpl(eth ethdb.Backend) *NetAPIImpl {
|
||||
return &NetAPIImpl{
|
||||
ethBackend: eth,
|
||||
}
|
||||
}
|
@ -4,6 +4,6 @@ import (
|
||||
"context"
|
||||
)
|
||||
|
||||
func (api *APIImpl) NetVersion(_ context.Context) uint64 {
|
||||
func (api *NetAPIImpl) Version(_ context.Context) uint64 {
|
||||
return api.ethBackend.NetVersion()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user