|
|
@ -17,8 +17,6 @@ |
|
|
|
package eth |
|
|
|
package eth |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"math/big" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/eth/protocols/eth" |
|
|
|
"github.com/ethereum/go-ethereum/eth/protocols/eth" |
|
|
|
"github.com/ethereum/go-ethereum/eth/protocols/snap" |
|
|
|
"github.com/ethereum/go-ethereum/eth/protocols/snap" |
|
|
|
) |
|
|
|
) |
|
|
@ -26,9 +24,7 @@ import ( |
|
|
|
// ethPeerInfo represents a short summary of the `eth` sub-protocol metadata known
|
|
|
|
// ethPeerInfo represents a short summary of the `eth` sub-protocol metadata known
|
|
|
|
// about a connected peer.
|
|
|
|
// about a connected peer.
|
|
|
|
type ethPeerInfo struct { |
|
|
|
type ethPeerInfo struct { |
|
|
|
Version uint `json:"version"` // Ethereum protocol version negotiated
|
|
|
|
Version uint `json:"version"` // Ethereum protocol version negotiated
|
|
|
|
Difficulty *big.Int `json:"difficulty"` // Total difficulty of the peer's blockchain
|
|
|
|
|
|
|
|
Head string `json:"head"` // Hex hash of the peer's best owned block
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ethPeer is a wrapper around eth.Peer to maintain a few extra metadata.
|
|
|
|
// ethPeer is a wrapper around eth.Peer to maintain a few extra metadata.
|
|
|
@ -39,12 +35,8 @@ type ethPeer struct { |
|
|
|
|
|
|
|
|
|
|
|
// info gathers and returns some `eth` protocol metadata known about a peer.
|
|
|
|
// info gathers and returns some `eth` protocol metadata known about a peer.
|
|
|
|
func (p *ethPeer) info() *ethPeerInfo { |
|
|
|
func (p *ethPeer) info() *ethPeerInfo { |
|
|
|
hash, td := p.Head() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ðPeerInfo{ |
|
|
|
return ðPeerInfo{ |
|
|
|
Version: p.Version(), |
|
|
|
Version: p.Version(), |
|
|
|
Difficulty: td, |
|
|
|
|
|
|
|
Head: hash.Hex(), |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|