aboutsummaryrefslogtreecommitdiffstats
path: root/eth/backend.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-10-27 21:10:30 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-10-28 18:44:15 +0800
commite46ab3bdcde7236c8fe54d6c83655e50bd19fe31 (patch)
tree4f30c5f9757ebfbde6501e1d53484ff51fd2fad9 /eth/backend.go
parent05f74077fb1bc23937f3b25fd4e826dcf5789212 (diff)
downloaddexon-e46ab3bdcde7236c8fe54d6c83655e50bd19fe31.tar
dexon-e46ab3bdcde7236c8fe54d6c83655e50bd19fe31.tar.gz
dexon-e46ab3bdcde7236c8fe54d6c83655e50bd19fe31.tar.bz2
dexon-e46ab3bdcde7236c8fe54d6c83655e50bd19fe31.tar.lz
dexon-e46ab3bdcde7236c8fe54d6c83655e50bd19fe31.tar.xz
dexon-e46ab3bdcde7236c8fe54d6c83655e50bd19fe31.tar.zst
dexon-e46ab3bdcde7236c8fe54d6c83655e50bd19fe31.zip
eth, p2p, rpc/api: polish protocol info gathering
Diffstat (limited to 'eth/backend.go')
-rw-r--r--eth/backend.go60
1 files changed, 4 insertions, 56 deletions
diff --git a/eth/backend.go b/eth/backend.go
index ee857e146..1f3a52d5a 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -472,62 +472,10 @@ func New(config *Config) (*Ethereum, error) {
return eth, nil
}
-type NodeInfo struct {
- Name string
- NodeUrl string
- NodeID string
- IP string
- DiscPort int // UDP listening port for discovery protocol
- TCPPort int // TCP listening port for RLPx
- Td string
- ListenAddr string
-}
-
-func (s *Ethereum) NodeInfo() *NodeInfo {
- node := s.net.Self()
-
- return &NodeInfo{
- Name: s.Name(),
- NodeUrl: node.String(),
- NodeID: node.ID.String(),
- IP: node.IP.String(),
- DiscPort: int(node.UDP),
- TCPPort: int(node.TCP),
- ListenAddr: s.net.ListenAddr,
- Td: s.BlockChain().GetTd(s.BlockChain().CurrentBlock().Hash()).String(),
- }
-}
-
-type PeerInfo struct {
- ID string
- Name string
- Caps string
- RemoteAddress string
- LocalAddress string
-}
-
-func newPeerInfo(peer *p2p.Peer) *PeerInfo {
- var caps []string
- for _, cap := range peer.Caps() {
- caps = append(caps, cap.String())
- }
- return &PeerInfo{
- ID: peer.ID().String(),
- Name: peer.Name(),
- Caps: strings.Join(caps, ", "),
- RemoteAddress: peer.RemoteAddr().String(),
- LocalAddress: peer.LocalAddr().String(),
- }
-}
-
-// PeersInfo returns an array of PeerInfo objects describing connected peers
-func (s *Ethereum) PeersInfo() (peersinfo []*PeerInfo) {
- for _, peer := range s.net.Peers() {
- if peer != nil {
- peersinfo = append(peersinfo, newPeerInfo(peer))
- }
- }
- return
+// Network retrieves the underlying P2P network server. This should eventually
+// be moved out into a protocol independent package, but for now use an accessor.
+func (s *Ethereum) Network() *p2p.Server {
+ return s.net
}
func (s *Ethereum) ResetWithGenesisBlock(gb *types.Block) {