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
f7ca03ae
Commit
f7ca03ae
authored
Dec 28, 2017
by
Péter Szilágyi
Committed by
Felix Lange
Dec 28, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth, les, light: expose chain config in les node info too (#15732)
parent
c15d76a4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
11 deletions
+25
-11
handler.go
eth/handler.go
+6
-6
ethstats.go
ethstats/ethstats.go
+2
-2
handler.go
les/handler.go
+14
-3
lightchain.go
light/lightchain.go
+3
-0
No files found.
eth/handler.go
View file @
f7ca03ae
...
...
@@ -744,10 +744,10 @@ func (self *ProtocolManager) txBroadcastLoop() {
}
}
//
EthNodeInfo represents a short summary of the Ethereum sub-protocol metadata known
// about the host peer.
type
Eth
NodeInfo
struct
{
Network
uint64
`json:"network"`
// Ethereum network ID (1=Frontier, 2=Morden, Ropsten=3)
//
NodeInfo represents a short summary of the Ethereum sub-protocol metadata
//
known
about the host peer.
type
NodeInfo
struct
{
Network
uint64
`json:"network"`
// Ethereum network ID (1=Frontier, 2=Morden, Ropsten=3
, Rinkeby=4
)
Difficulty
*
big
.
Int
`json:"difficulty"`
// Total difficulty of the host's blockchain
Genesis
common
.
Hash
`json:"genesis"`
// SHA3 hash of the host's genesis block
Config
*
params
.
ChainConfig
`json:"config"`
// Chain configuration for the fork rules
...
...
@@ -755,9 +755,9 @@ type EthNodeInfo struct {
}
// NodeInfo retrieves some protocol metadata about the running host node.
func
(
self
*
ProtocolManager
)
NodeInfo
()
*
Eth
NodeInfo
{
func
(
self
*
ProtocolManager
)
NodeInfo
()
*
NodeInfo
{
currentBlock
:=
self
.
blockchain
.
CurrentBlock
()
return
&
Eth
NodeInfo
{
return
&
NodeInfo
{
Network
:
self
.
networkId
,
Difficulty
:
self
.
blockchain
.
GetTd
(
currentBlock
.
Hash
(),
currentBlock
.
NumberU64
()),
Genesis
:
self
.
blockchain
.
Genesis
()
.
Hash
(),
...
...
ethstats/ethstats.go
View file @
f7ca03ae
...
...
@@ -374,10 +374,10 @@ func (s *Service) login(conn *websocket.Conn) error {
var
network
,
protocol
string
if
info
:=
infos
.
Protocols
[
"eth"
];
info
!=
nil
{
network
=
fmt
.
Sprintf
(
"%d"
,
info
.
(
*
eth
.
Eth
NodeInfo
)
.
Network
)
network
=
fmt
.
Sprintf
(
"%d"
,
info
.
(
*
eth
.
NodeInfo
)
.
Network
)
protocol
=
fmt
.
Sprintf
(
"eth/%d"
,
eth
.
ProtocolVersions
[
0
])
}
else
{
network
=
fmt
.
Sprintf
(
"%d"
,
infos
.
Protocols
[
"les"
]
.
(
*
eth
.
Eth
NodeInfo
)
.
Network
)
network
=
fmt
.
Sprintf
(
"%d"
,
infos
.
Protocols
[
"les"
]
.
(
*
les
.
NodeInfo
)
.
Network
)
protocol
=
fmt
.
Sprintf
(
"les/%d"
,
les
.
ClientProtocolVersions
[
0
])
}
auth
:=
&
authMsg
{
...
...
les/handler.go
View file @
f7ca03ae
...
...
@@ -32,7 +32,6 @@ import (
"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/eth"
"github.com/ethereum/go-ethereum/eth/downloader"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
...
...
@@ -73,6 +72,7 @@ func errResp(code errCode, format string, v ...interface{}) error {
}
type
BlockChain
interface
{
Config
()
*
params
.
ChainConfig
HasHeader
(
hash
common
.
Hash
,
number
uint64
)
bool
GetHeader
(
hash
common
.
Hash
,
number
uint64
)
*
types
.
Header
GetHeaderByHash
(
hash
common
.
Hash
)
*
types
.
Header
...
...
@@ -1123,12 +1123,23 @@ func (pm *ProtocolManager) txStatus(hashes []common.Hash) []txStatus {
return
stats
}
// NodeInfo represents a short summary of the Ethereum sub-protocol metadata
// known about the host peer.
type
NodeInfo
struct
{
Network
uint64
`json:"network"`
// Ethereum network ID (1=Frontier, 2=Morden, Ropsten=3, Rinkeby=4)
Difficulty
*
big
.
Int
`json:"difficulty"`
// Total difficulty of the host's blockchain
Genesis
common
.
Hash
`json:"genesis"`
// SHA3 hash of the host's genesis block
Config
*
params
.
ChainConfig
`json:"config"`
// Chain configuration for the fork rules
Head
common
.
Hash
`json:"head"`
// SHA3 hash of the host's best owned block
}
// NodeInfo retrieves some protocol metadata about the running host node.
func
(
self
*
ProtocolManager
)
NodeInfo
()
*
eth
.
Eth
NodeInfo
{
return
&
eth
.
Eth
NodeInfo
{
func
(
self
*
ProtocolManager
)
NodeInfo
()
*
NodeInfo
{
return
&
NodeInfo
{
Network
:
self
.
networkId
,
Difficulty
:
self
.
blockchain
.
GetTdByHash
(
self
.
blockchain
.
LastBlockHash
()),
Genesis
:
self
.
blockchain
.
Genesis
()
.
Hash
(),
Config
:
self
.
blockchain
.
Config
(),
Head
:
self
.
blockchain
.
LastBlockHash
(),
}
}
...
...
light/lightchain.go
View file @
f7ca03ae
...
...
@@ -457,6 +457,9 @@ func (self *LightChain) GetHeaderByNumberOdr(ctx context.Context, number uint64)
return
GetHeaderByNumber
(
ctx
,
self
.
odr
,
number
)
}
// Config retrieves the header chain's chain configuration.
func
(
self
*
LightChain
)
Config
()
*
params
.
ChainConfig
{
return
self
.
hc
.
Config
()
}
func
(
self
*
LightChain
)
SyncCht
(
ctx
context
.
Context
)
bool
{
if
self
.
odr
.
ChtIndexer
()
==
nil
{
return
false
...
...
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