Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
2b93843d
Commit
2b93843d
authored
Mar 25, 2015
by
Taylor Gerring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve protocol version reporting
parent
c956bcb1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
21 deletions
+36
-21
backend.go
eth/backend.go
+21
-18
api.go
rpc/api.go
+5
-1
xeth.go
xeth/xeth.go
+10
-2
No files found.
eth/backend.go
View file @
2b93843d
...
@@ -138,11 +138,12 @@ type Ethereum struct {
...
@@ -138,11 +138,12 @@ type Ethereum struct {
// logger logger.LogSystem
// logger logger.LogSystem
Mining
bool
Mining
bool
DataDir
string
DataDir
string
version
string
clientVersion
string
protocolVersion
int
ethVersionId
int
networkId
int
netVersionId
int
shhVersionId
int
}
}
func
New
(
config
*
Config
)
(
*
Ethereum
,
error
)
{
func
New
(
config
*
Config
)
(
*
Ethereum
,
error
)
{
...
@@ -177,16 +178,16 @@ func New(config *Config) (*Ethereum, error) {
...
@@ -177,16 +178,16 @@ func New(config *Config) (*Ethereum, error) {
servlogger
.
Infof
(
"Protocol Version: %v, Network Id: %v"
,
config
.
ProtocolVersion
,
config
.
NetworkId
)
servlogger
.
Infof
(
"Protocol Version: %v, Network Id: %v"
,
config
.
ProtocolVersion
,
config
.
NetworkId
)
eth
:=
&
Ethereum
{
eth
:=
&
Ethereum
{
shutdownChan
:
make
(
chan
bool
),
shutdownChan
:
make
(
chan
bool
),
blockDb
:
blockDb
,
blockDb
:
blockDb
,
stateDb
:
stateDb
,
stateDb
:
stateDb
,
extraDb
:
extraDb
,
extraDb
:
extraDb
,
eventMux
:
&
event
.
TypeMux
{},
eventMux
:
&
event
.
TypeMux
{},
accountManager
:
config
.
AccountManager
,
accountManager
:
config
.
AccountManager
,
DataDir
:
config
.
DataDir
,
DataDir
:
config
.
DataDir
,
version
:
config
.
Name
,
// TODO should separate from Name
clientVersion
:
config
.
Name
,
// TODO should separate from Name
protocolVersion
:
config
.
ProtocolVersion
,
ethVersionId
:
config
.
ProtocolVersion
,
net
workId
:
config
.
NetworkId
,
net
VersionId
:
config
.
NetworkId
,
}
}
eth
.
chainManager
=
core
.
NewChainManager
(
blockDb
,
stateDb
,
eth
.
EventMux
())
eth
.
chainManager
=
core
.
NewChainManager
(
blockDb
,
stateDb
,
eth
.
EventMux
())
...
@@ -195,6 +196,7 @@ func New(config *Config) (*Ethereum, error) {
...
@@ -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
.
blockProcessor
=
core
.
NewBlockProcessor
(
stateDb
,
extraDb
,
eth
.
pow
,
eth
.
txPool
,
eth
.
chainManager
,
eth
.
EventMux
())
eth
.
chainManager
.
SetProcessor
(
eth
.
blockProcessor
)
eth
.
chainManager
.
SetProcessor
(
eth
.
blockProcessor
)
eth
.
whisper
=
whisper
.
New
()
eth
.
whisper
=
whisper
.
New
()
eth
.
shhVersionId
=
int
(
eth
.
whisper
.
Version
())
eth
.
miner
=
miner
.
New
(
eth
,
eth
.
pow
,
config
.
MinerThreads
)
eth
.
miner
=
miner
.
New
(
eth
,
eth
.
pow
,
config
.
MinerThreads
)
hasBlock
:=
eth
.
chainManager
.
HasBlock
hasBlock
:=
eth
.
chainManager
.
HasBlock
...
@@ -324,9 +326,10 @@ func (s *Ethereum) IsListening() bool { return true } // Alwa
...
@@ -324,9 +326,10 @@ func (s *Ethereum) IsListening() bool { return true } // Alwa
func
(
s
*
Ethereum
)
PeerCount
()
int
{
return
s
.
net
.
PeerCount
()
}
func
(
s
*
Ethereum
)
PeerCount
()
int
{
return
s
.
net
.
PeerCount
()
}
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
)
ClientVersion
()
string
{
return
s
.
clientVersion
}
func
(
s
*
Ethereum
)
ProtocolVersion
()
int
{
return
s
.
protocolVersion
}
func
(
s
*
Ethereum
)
EthVersion
()
int
{
return
s
.
ethVersionId
}
func
(
s
*
Ethereum
)
NetworkId
()
int
{
return
s
.
networkId
}
func
(
s
*
Ethereum
)
NetVersion
()
int
{
return
s
.
netVersionId
}
func
(
s
*
Ethereum
)
ShhVersion
()
int
{
return
s
.
shhVersionId
}
// Start the ethereum
// Start the ethereum
func
(
s
*
Ethereum
)
Start
()
error
{
func
(
s
*
Ethereum
)
Start
()
error
{
...
...
rpc/api.go
View file @
2b93843d
...
@@ -49,7 +49,7 @@ func (api *EthereumApi) Close() {
...
@@ -49,7 +49,7 @@ func (api *EthereumApi) Close() {
}
}
func
(
api
*
EthereumApi
)
GetRequestReply
(
req
*
RpcRequest
,
reply
*
interface
{})
error
{
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
)
rpclogger
.
Debugf
(
"%s %s"
,
req
.
Method
,
req
.
Params
)
switch
req
.
Method
{
switch
req
.
Method
{
...
@@ -68,6 +68,8 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
...
@@ -68,6 +68,8 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
case
"net_peerCount"
:
case
"net_peerCount"
:
v
:=
api
.
xeth
()
.
PeerCount
()
v
:=
api
.
xeth
()
.
PeerCount
()
*
reply
=
common
.
ToHex
(
big
.
NewInt
(
int64
(
v
))
.
Bytes
())
*
reply
=
common
.
ToHex
(
big
.
NewInt
(
int64
(
v
))
.
Bytes
())
case
"eth_version"
:
*
reply
=
api
.
xeth
()
.
EthVersion
()
case
"eth_coinbase"
:
case
"eth_coinbase"
:
// TODO handling of empty coinbase due to lack of accounts
// TODO handling of empty coinbase due to lack of accounts
res
:=
api
.
xeth
()
.
Coinbase
()
res
:=
api
.
xeth
()
.
Coinbase
()
...
@@ -406,6 +408,8 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
...
@@ -406,6 +408,8 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
res
,
_
:=
api
.
db
.
Get
([]
byte
(
args
.
Database
+
args
.
Key
))
res
,
_
:=
api
.
db
.
Get
([]
byte
(
args
.
Database
+
args
.
Key
))
*
reply
=
common
.
ToHex
(
res
)
*
reply
=
common
.
ToHex
(
res
)
case
"shh_version"
:
*
reply
=
api
.
xeth
()
.
WhisperVersion
()
case
"shh_post"
:
case
"shh_post"
:
args
:=
new
(
WhisperMessageArgs
)
args
:=
new
(
WhisperMessageArgs
)
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
...
...
xeth/xeth.go
View file @
2b93843d
...
@@ -221,12 +221,20 @@ func (self *XEth) IsMining() bool {
...
@@ -221,12 +221,20 @@ func (self *XEth) IsMining() bool {
return
self
.
backend
.
IsMining
()
return
self
.
backend
.
IsMining
()
}
}
func
(
self
*
XEth
)
EthVersion
()
string
{
return
string
(
self
.
backend
.
EthVersion
())
}
func
(
self
*
XEth
)
NetworkVersion
()
string
{
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
{
func
(
self
*
XEth
)
ClientVersion
()
string
{
return
self
.
backend
.
Version
()
return
self
.
backend
.
Client
Version
()
}
}
func
(
self
*
XEth
)
SetMining
(
shouldmine
bool
)
bool
{
func
(
self
*
XEth
)
SetMining
(
shouldmine
bool
)
bool
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment