Implement RPC net_version

pull/553/head
Taylor Gerring 10 years ago
parent 60020add74
commit e954c24af0
  1. 12
      eth/backend.go
  2. 2
      rpc/api.go
  3. 4
      xeth/xeth.go

@ -13,6 +13,7 @@ import (
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types" "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/crypto"
"github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/event"
@ -21,7 +22,6 @@ import (
"github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/discover" "github.com/ethereum/go-ethereum/p2p/discover"
"github.com/ethereum/go-ethereum/p2p/nat" "github.com/ethereum/go-ethereum/p2p/nat"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/whisper" "github.com/ethereum/go-ethereum/whisper"
) )
@ -141,8 +141,8 @@ type Ethereum struct {
Mining bool Mining bool
DataDir string DataDir string
version string version string
ProtocolVersion int protocolVersion int
NetworkId int networkId int
} }
func New(config *Config) (*Ethereum, error) { func New(config *Config) (*Ethereum, error) {
@ -185,8 +185,8 @@ func New(config *Config) (*Ethereum, error) {
accountManager: config.AccountManager, accountManager: config.AccountManager,
DataDir: config.DataDir, DataDir: config.DataDir,
version: config.Name, // TODO should separate from Name version: config.Name, // TODO should separate from Name
ProtocolVersion: config.ProtocolVersion, protocolVersion: config.ProtocolVersion,
NetworkId: config.NetworkId, networkId: config.NetworkId,
} }
eth.chainManager = core.NewChainManager(blockDb, stateDb, eth.EventMux()) 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) Peers() []*p2p.Peer { return s.net.Peers() }
func (s *Ethereum) MaxPeers() int { return s.net.MaxPeers } func (s *Ethereum) MaxPeers() int { return s.net.MaxPeers }
func (s *Ethereum) Version() string { return s.version } 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 // Start the ethereum
func (s *Ethereum) Start() error { func (s *Ethereum) Start() error {

@ -62,7 +62,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
case "web3_clientVersion": case "web3_clientVersion":
*reply = api.xeth().Backend().Version() *reply = api.xeth().Backend().Version()
case "net_version": case "net_version":
return NewNotImplementedError(req.Method) *reply = string(api.xeth().Backend().ProtocolVersion())
case "net_listening": case "net_listening":
*reply = api.xeth().IsListening() *reply = api.xeth().IsListening()
case "net_peerCount": case "net_peerCount":

@ -12,6 +12,7 @@ import (
"github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core" "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/core/types"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/event"
@ -19,7 +20,6 @@ import (
"github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/miner" "github.com/ethereum/go-ethereum/miner"
"github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/whisper" "github.com/ethereum/go-ethereum/whisper"
) )
@ -50,6 +50,8 @@ type Backend interface {
StartMining() error StartMining() error
StopMining() StopMining()
Version() string Version() string
ProtocolVersion() int
NetworkId() int
} }
// Frontend should be implemented by users of XEth. Its methods are // Frontend should be implemented by users of XEth. Its methods are

Loading…
Cancel
Save