mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-25 04:57:17 +00:00
5b4445ecea
This reverts commit 00415eee76
.
49 lines
1.1 KiB
Go
49 lines
1.1 KiB
Go
package commands
|
|
|
|
import (
|
|
"context"
|
|
"strconv"
|
|
|
|
"github.com/ledgerwatch/turbo-geth/common/hexutil"
|
|
|
|
"github.com/ledgerwatch/turbo-geth/ethdb"
|
|
)
|
|
|
|
type NetAPI interface {
|
|
Listening(_ context.Context) (bool, error)
|
|
Version(_ context.Context) (string, error)
|
|
PeerCount(_ context.Context) (hexutil.Uint, error)
|
|
}
|
|
|
|
type NetAPIImpl struct {
|
|
ethBackend ethdb.Backend
|
|
}
|
|
|
|
// NewtNetAPIImpl returns NetAPIImplImpl instance
|
|
func NewNetAPIImpl(eth ethdb.Backend) *NetAPIImpl {
|
|
return &NetAPIImpl{
|
|
ethBackend: eth,
|
|
}
|
|
}
|
|
|
|
// Listen implements RPC call for net_listening
|
|
// TODO(tjayrush) remove hard coded value
|
|
func (api *NetAPIImpl) Listening(_ context.Context) (bool, error) {
|
|
return true, nil
|
|
}
|
|
|
|
// Version implements RPC call for net_version
|
|
func (api *NetAPIImpl) Version(_ context.Context) (string, error) {
|
|
res, err := api.ethBackend.NetVersion()
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return strconv.FormatUint(res, 10), nil
|
|
}
|
|
|
|
// PeerCount implements RPC call for net_peerCount
|
|
// TODO(tjayrush) remove hard coded value
|
|
func (api *NetAPIImpl) PeerCount(_ context.Context) (hexutil.Uint, error) {
|
|
return hexutil.Uint(25), nil
|
|
}
|