diff options
author | Maran <maran.hidskes@gmail.com> | 2014-06-02 21:20:27 +0800 |
---|---|---|
committer | Maran <maran.hidskes@gmail.com> | 2014-06-02 21:20:27 +0800 |
commit | fb6ff61730ed92ada68c9c5a5b3a6f9976a78161 (patch) | |
tree | 63cd039495d38dd047c231d52a3356bdb5e8b3f2 /ethpub/pub.go | |
parent | ff8a834ccc630e85292968aaed8abc52044797f8 (diff) | |
download | go-tangerine-fb6ff61730ed92ada68c9c5a5b3a6f9976a78161.tar go-tangerine-fb6ff61730ed92ada68c9c5a5b3a6f9976a78161.tar.gz go-tangerine-fb6ff61730ed92ada68c9c5a5b3a6f9976a78161.tar.bz2 go-tangerine-fb6ff61730ed92ada68c9c5a5b3a6f9976a78161.tar.lz go-tangerine-fb6ff61730ed92ada68c9c5a5b3a6f9976a78161.tar.xz go-tangerine-fb6ff61730ed92ada68c9c5a5b3a6f9976a78161.tar.zst go-tangerine-fb6ff61730ed92ada68c9c5a5b3a6f9976a78161.zip |
Implemented Public Peer interface
Diffstat (limited to 'ethpub/pub.go')
-rw-r--r-- | ethpub/pub.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/ethpub/pub.go b/ethpub/pub.go index a9a962f14..6d4c230ad 100644 --- a/ethpub/pub.go +++ b/ethpub/pub.go @@ -6,6 +6,7 @@ import ( "github.com/ethereum/eth-go/ethutil" "math/big" "strings" + "sync/atomic" ) type PEthereum struct { @@ -51,6 +52,18 @@ func (lib *PEthereum) GetPeerCount() int { return lib.manager.PeerCount() } +func (lib *PEthereum) GetPeers() []PPeer { + var peers []PPeer + for peer := lib.manager.Peers().Front(); peer != nil; peer = peer.Next() { + p := peer.Value.(ethchain.Peer) + if atomic.LoadInt32(p.Connected()) != 0 { + peers = append(peers, *NewPPeer(p)) + } + } + + return peers +} + func (lib *PEthereum) GetIsMining() bool { return lib.manager.IsMining() } |