Improve protocol version reporting
This commit is contained in:
parent
c956bcb13c
commit
2b93843d86
@ -140,9 +140,10 @@ type Ethereum struct {
|
||||
|
||||
Mining bool
|
||||
DataDir string
|
||||
version string
|
||||
protocolVersion int
|
||||
networkId int
|
||||
clientVersion string
|
||||
ethVersionId int
|
||||
netVersionId int
|
||||
shhVersionId int
|
||||
}
|
||||
|
||||
func New(config *Config) (*Ethereum, error) {
|
||||
@ -184,9 +185,9 @@ func New(config *Config) (*Ethereum, error) {
|
||||
eventMux: &event.TypeMux{},
|
||||
accountManager: config.AccountManager,
|
||||
DataDir: config.DataDir,
|
||||
version: config.Name, // TODO should separate from Name
|
||||
protocolVersion: config.ProtocolVersion,
|
||||
networkId: config.NetworkId,
|
||||
clientVersion: config.Name, // TODO should separate from Name
|
||||
ethVersionId: config.ProtocolVersion,
|
||||
netVersionId: config.NetworkId,
|
||||
}
|
||||
|
||||
eth.chainManager = core.NewChainManager(blockDb, stateDb, eth.EventMux())
|
||||
@ -195,6 +196,7 @@ func New(config *Config) (*Ethereum, error) {
|
||||
eth.blockProcessor = core.NewBlockProcessor(stateDb, extraDb, eth.pow, eth.txPool, eth.chainManager, eth.EventMux())
|
||||
eth.chainManager.SetProcessor(eth.blockProcessor)
|
||||
eth.whisper = whisper.New()
|
||||
eth.shhVersionId = int(eth.whisper.Version())
|
||||
eth.miner = miner.New(eth, eth.pow, config.MinerThreads)
|
||||
|
||||
hasBlock := eth.chainManager.HasBlock
|
||||
@ -324,9 +326,10 @@ func (s *Ethereum) IsListening() bool { return true } // Alwa
|
||||
func (s *Ethereum) PeerCount() int { return s.net.PeerCount() }
|
||||
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 }
|
||||
func (s *Ethereum) ClientVersion() string { return s.clientVersion }
|
||||
func (s *Ethereum) EthVersion() int { return s.ethVersionId }
|
||||
func (s *Ethereum) NetVersion() int { return s.netVersionId }
|
||||
func (s *Ethereum) ShhVersion() int { return s.shhVersionId }
|
||||
|
||||
// Start the ethereum
|
||||
func (s *Ethereum) Start() error {
|
||||
|
@ -49,7 +49,7 @@ func (api *EthereumApi) Close() {
|
||||
}
|
||||
|
||||
func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error {
|
||||
// Spec at https://github.com/ethereum/wiki/wiki/Generic-JSON-RPC
|
||||
// Spec at https://github.com/ethereum/wiki/wiki/JSON-RPC
|
||||
rpclogger.Debugf("%s %s", req.Method, req.Params)
|
||||
|
||||
switch req.Method {
|
||||
@ -68,6 +68,8 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
|
||||
case "net_peerCount":
|
||||
v := api.xeth().PeerCount()
|
||||
*reply = common.ToHex(big.NewInt(int64(v)).Bytes())
|
||||
case "eth_version":
|
||||
*reply = api.xeth().EthVersion()
|
||||
case "eth_coinbase":
|
||||
// TODO handling of empty coinbase due to lack of accounts
|
||||
res := api.xeth().Coinbase()
|
||||
@ -406,6 +408,8 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
|
||||
|
||||
res, _ := api.db.Get([]byte(args.Database + args.Key))
|
||||
*reply = common.ToHex(res)
|
||||
case "shh_version":
|
||||
*reply = api.xeth().WhisperVersion()
|
||||
case "shh_post":
|
||||
args := new(WhisperMessageArgs)
|
||||
if err := json.Unmarshal(req.Params, &args); err != nil {
|
||||
|
12
xeth/xeth.go
12
xeth/xeth.go
@ -221,12 +221,20 @@ func (self *XEth) IsMining() bool {
|
||||
return self.backend.IsMining()
|
||||
}
|
||||
|
||||
func (self *XEth) EthVersion() string {
|
||||
return string(self.backend.EthVersion())
|
||||
}
|
||||
|
||||
func (self *XEth) NetworkVersion() string {
|
||||
return string(self.backend.ProtocolVersion())
|
||||
return string(self.backend.NetVersion())
|
||||
}
|
||||
|
||||
func (self *XEth) WhisperVersion() string {
|
||||
return string(self.backend.ShhVersion())
|
||||
}
|
||||
|
||||
func (self *XEth) ClientVersion() string {
|
||||
return self.backend.Version()
|
||||
return self.backend.ClientVersion()
|
||||
}
|
||||
|
||||
func (self *XEth) SetMining(shouldmine bool) bool {
|
||||
|
Loading…
Reference in New Issue
Block a user