diff options
-rw-r--r-- | ethchain/state_manager.go | 1 | ||||
-rw-r--r-- | ethpipe/js_types.go | 10 | ||||
-rw-r--r-- | peer.go | 4 |
3 files changed, 14 insertions, 1 deletions
diff --git a/ethchain/state_manager.go b/ethchain/state_manager.go index 888c68bb9..8088f6735 100644 --- a/ethchain/state_manager.go +++ b/ethchain/state_manager.go @@ -32,6 +32,7 @@ type Peer interface { Version() string PingTime() string Connected() *int32 + Caps() *ethutil.Value } type EthManager interface { diff --git a/ethpipe/js_types.go b/ethpipe/js_types.go index 7266a5be4..cf5686a4b 100644 --- a/ethpipe/js_types.go +++ b/ethpipe/js_types.go @@ -1,6 +1,7 @@ package ethpipe import ( + "fmt" "strconv" "strings" @@ -151,6 +152,7 @@ type JSPeer struct { Version string `json:"version"` LastResponse string `json:"lastResponse"` Latency string `json:"latency"` + Caps string `json:"caps"` } func NewJSPeer(peer ethchain.Peer) *JSPeer { @@ -164,7 +166,13 @@ func NewJSPeer(peer ethchain.Peer) *JSPeer { } ipAddress := strings.Join(ip, ".") - return &JSPeer{ref: &peer, Inbound: peer.Inbound(), LastSend: peer.LastSend().Unix(), LastPong: peer.LastPong(), Version: peer.Version(), Ip: ipAddress, Port: int(peer.Port()), Latency: peer.PingTime()} + var caps []string + capsIt := peer.Caps().NewIterator() + for capsIt.Next() { + caps = append(caps, capsIt.Value().Str()) + } + + return &JSPeer{ref: &peer, Inbound: peer.Inbound(), LastSend: peer.LastSend().Unix(), LastPong: peer.LastPong(), Version: peer.Version(), Ip: ipAddress, Port: int(peer.Port()), Latency: peer.PingTime(), Caps: fmt.Sprintf("%v", caps)} } type JSReceipt struct { @@ -813,6 +813,10 @@ func (self *Peer) IsCap(cap string) bool { return false } +func (self *Peer) Caps() *ethutil.Value { + return self.protocolCaps +} + func (p *Peer) String() string { var strBoundType string if p.inbound { |