aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-03-24 01:06:05 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-03-24 01:06:05 +0800
commite954c24af02802cdee0870230b6dcfc898dd07cd (patch)
tree4e0a620ee3383bd2c41ce9531e3c25cbdc42c6f1
parent60020add74c40225e81122071d20c30f24832007 (diff)
downloaddexon-e954c24af02802cdee0870230b6dcfc898dd07cd.tar.gz
dexon-e954c24af02802cdee0870230b6dcfc898dd07cd.tar.zst
dexon-e954c24af02802cdee0870230b6dcfc898dd07cd.zip
Implement RPC net_version
-rw-r--r--eth/backend.go12
-rw-r--r--rpc/api.go2
-rw-r--r--xeth/xeth.go4
3 files changed, 11 insertions, 7 deletions
diff --git a/eth/backend.go b/eth/backend.go
index ded3f0021..446f06531 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -13,6 +13,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
+ "github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
@@ -21,7 +22,6 @@ import (
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/discover"
"github.com/ethereum/go-ethereum/p2p/nat"
- "github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/whisper"
)
@@ -141,8 +141,8 @@ type Ethereum struct {
Mining bool
DataDir string
version string
- ProtocolVersion int
- NetworkId int
+ protocolVersion int
+ networkId int
}
func New(config *Config) (*Ethereum, error) {
@@ -185,8 +185,8 @@ func New(config *Config) (*Ethereum, error) {
accountManager: config.AccountManager,
DataDir: config.DataDir,
version: config.Name, // TODO should separate from Name
- ProtocolVersion: config.ProtocolVersion,
- NetworkId: config.NetworkId,
+ protocolVersion: config.ProtocolVersion,
+ networkId: config.NetworkId,
}
eth.chainManager = core.NewChainManager(blockDb, stateDb, eth.EventMux())
@@ -325,6 +325,8 @@ func (s *Ethereum) PeerCount() int { return s.net.PeerCoun
func (s *Ethereum) Peers() []*p2p.Peer { return s.net.Peers() }
func (s *Ethereum) MaxPeers() int { return s.net.MaxPeers }
func (s *Ethereum) Version() string { return s.version }
+func (s *Ethereum) ProtocolVersion() int { return s.protocolVersion }
+func (s *Ethereum) NetworkId() int { return s.networkId }
// Start the ethereum
func (s *Ethereum) Start() error {
diff --git a/rpc/api.go b/rpc/api.go
index 19bd9b707..4bc199176 100644
--- a/rpc/api.go
+++ b/rpc/api.go
@@ -62,7 +62,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
case "web3_clientVersion":
*reply = api.xeth().Backend().Version()
case "net_version":
- return NewNotImplementedError(req.Method)
+ *reply = string(api.xeth().Backend().ProtocolVersion())
case "net_listening":
*reply = api.xeth().IsListening()
case "net_peerCount":
diff --git a/xeth/xeth.go b/xeth/xeth.go
index 02a691ffb..98f5f5b36 100644
--- a/xeth/xeth.go
+++ b/xeth/xeth.go
@@ -12,6 +12,7 @@ import (
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
+ "github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/event"
@@ -19,7 +20,6 @@ import (
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/miner"
"github.com/ethereum/go-ethereum/p2p"
- "github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/whisper"
)
@@ -50,6 +50,8 @@ type Backend interface {
StartMining() error
StopMining()
Version() string
+ ProtocolVersion() int
+ NetworkId() int
}
// Frontend should be implemented by users of XEth. Its methods are