mirror of https://github.com/status-im/op-geth.git
Get peers returns now both in and outbound peers
This commit is contained in:
parent
dfa38b3f91
commit
da66eddfcc
16
ethereum.go
16
ethereum.go
|
@ -144,6 +144,18 @@ func (s *Ethereum) InboundPeers() []*Peer {
|
|||
return inboundPeers[:length]
|
||||
}
|
||||
|
||||
func (s *Ethereum) InOutPeers() []*Peer {
|
||||
// Create a new peer slice with at least the length of the total peers
|
||||
inboundPeers := make([]*Peer, s.peers.Len())
|
||||
length := 0
|
||||
eachPeer(s.peers, func(p *Peer, e *list.Element) {
|
||||
inboundPeers[length] = p
|
||||
length++
|
||||
})
|
||||
|
||||
return inboundPeers[:length]
|
||||
}
|
||||
|
||||
func (s *Ethereum) Broadcast(msgType ethwire.MsgType, data interface{}) {
|
||||
msg := ethwire.NewMessage(msgType, data)
|
||||
eachPeer(s.peers, func(p *Peer, e *list.Element) {
|
||||
|
@ -151,6 +163,10 @@ func (s *Ethereum) Broadcast(msgType ethwire.MsgType, data interface{}) {
|
|||
})
|
||||
}
|
||||
|
||||
func (s *Ethereum) Peers() *list.List {
|
||||
return s.peers
|
||||
}
|
||||
|
||||
func (s *Ethereum) ReapDeadPeers() {
|
||||
for {
|
||||
eachPeer(s.peers, func(p *Peer, e *list.Element) {
|
||||
|
|
4
peer.go
4
peer.go
|
@ -335,9 +335,9 @@ func (p *Peer) pushHandshake() error {
|
|||
|
||||
// Pushes the list of outbound peers to the client when requested
|
||||
func (p *Peer) pushPeers() {
|
||||
outPeers := make([]interface{}, len(p.ethereum.OutboundPeers()))
|
||||
outPeers := make([]interface{}, len(p.ethereum.InOutPeers()))
|
||||
// Serialise each peer
|
||||
for i, peer := range p.ethereum.OutboundPeers() {
|
||||
for i, peer := range p.ethereum.InOutPeers() {
|
||||
outPeers[i] = peer.RlpData()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue