diff options
author | obscuren <geffobscura@gmail.com> | 2014-01-31 18:57:56 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-01-31 18:57:56 +0800 |
commit | da66eddfccf86eb5dc036e023ddc2e0278105706 (patch) | |
tree | 6eb3453a2297696a2a5adc1132f3974dcf93a2e1 /ethereum.go | |
parent | dfa38b3f91d124f97350429c4664b62a5cb7dd08 (diff) | |
download | go-tangerine-da66eddfccf86eb5dc036e023ddc2e0278105706.tar.gz go-tangerine-da66eddfccf86eb5dc036e023ddc2e0278105706.tar.zst go-tangerine-da66eddfccf86eb5dc036e023ddc2e0278105706.zip |
Get peers returns now both in and outbound peers
Diffstat (limited to 'ethereum.go')
-rw-r--r-- | ethereum.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/ethereum.go b/ethereum.go index e1fb5945c..b9fc94d50 100644 --- a/ethereum.go +++ b/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) { |