aboutsummaryrefslogtreecommitdiff
path: root/plugin/evm
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/evm')
-rw-r--r--plugin/evm/config.go1
-rw-r--r--plugin/evm/service.go12
-rw-r--r--plugin/evm/vm.go4
3 files changed, 17 insertions, 0 deletions
diff --git a/plugin/evm/config.go b/plugin/evm/config.go
index c38a798..4d6650a 100644
--- a/plugin/evm/config.go
+++ b/plugin/evm/config.go
@@ -5,6 +5,7 @@ type CommandLineConfig struct {
// Coreth APIs
SnowmanAPIEnabled bool `json:"snowman-api-enabled"`
CorethAdminAPIEnabled bool `json:"coreth-admin-api-enabled"`
+ NetAPIEnabled bool `json:"net-api-enabled"`
// Coreth API Gas/Price Caps
RPCGasCap uint64 `json:"rpc-gas-cap"`
diff --git a/plugin/evm/service.go b/plugin/evm/service.go
index 3509929..0ec7620 100644
--- a/plugin/evm/service.go
+++ b/plugin/evm/service.go
@@ -38,6 +38,18 @@ type SnowmanAPI struct{ vm *VM }
// AvaxAPI offers Avalanche network related API methods
type AvaxAPI struct{ vm *VM }
+// NetAPI offers network related API methods
+type NetAPI struct{ vm *VM }
+
+// Listening returns an indication if the node is listening for network connections.
+func (s *NetAPI) Listening() bool { return true } // always listening
+
+// PeerCount returns the number of connected peers
+func (s *NetAPI) PeerCount() hexutil.Uint { return hexutil.Uint(0) } // TODO: report number of connected peers
+
+// Version returns the current ethereum protocol version.
+func (s *NetAPI) Version() string { return fmt.Sprintf("%d", s.vm.networkID) }
+
// GetAcceptedFrontReply defines the reply that will be sent from the
// GetAcceptedFront API call
type GetAcceptedFrontReply struct {
diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go
index c191720..53dc349 100644
--- a/plugin/evm/vm.go
+++ b/plugin/evm/vm.go
@@ -515,6 +515,10 @@ func (vm *VM) CreateHandlers() map[string]*commonEng.HTTPHandler {
handler.RegisterName("admin", &admin.Performance{})
enabledAPIs = append(enabledAPIs, "coreth-admin")
}
+ if vm.CLIConfig.NetAPIEnabled {
+ handler.RegisterName("net", &NetAPI{vm})
+ enabledAPIs = append(enabledAPIs, "net")
+ }
log.Info(fmt.Sprintf("Enabled APIs: %s", strings.Join(enabledAPIs, ", ")))