Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
b0ff946b
Commit
b0ff946b
authored
Jan 06, 2015
by
Felix Lange
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
p2p: move peerList back into baseProtocol
It had been moved to Peer, probably for debugging.
parent
eb0e7b1b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
23 deletions
+23
-23
peer.go
p2p/peer.go
+0
-22
protocol.go
p2p/protocol.go
+23
-1
No files found.
p2p/peer.go
View file @
b0ff946b
...
...
@@ -460,25 +460,3 @@ func (r *eofSignal) Read(buf []byte) (int, error) {
}
return
n
,
err
}
func
(
peer
*
Peer
)
PeerList
()
[]
interface
{}
{
peers
:=
peer
.
otherPeers
()
ds
:=
make
([]
interface
{},
0
,
len
(
peers
))
for
_
,
p
:=
range
peers
{
p
.
infolock
.
Lock
()
addr
:=
p
.
listenAddr
p
.
infolock
.
Unlock
()
// filter out this peer and peers that are not listening or
// have not completed the handshake.
// TODO: track previously sent peers and exclude them as well.
if
p
==
peer
||
addr
==
nil
{
continue
}
ds
=
append
(
ds
,
addr
)
}
ourAddr
:=
peer
.
ourListenAddr
if
ourAddr
!=
nil
&&
!
ourAddr
.
IP
.
IsLoopback
()
&&
!
ourAddr
.
IP
.
IsUnspecified
()
{
ds
=
append
(
ds
,
ourAddr
)
}
return
ds
}
p2p/protocol.go
View file @
b0ff946b
...
...
@@ -169,7 +169,7 @@ func (bp *baseProtocol) handle(rw MsgReadWriter) error {
case
pongMsg
:
case
getPeersMsg
:
peers
:=
bp
.
peer
.
Peer
List
()
peers
:=
bp
.
peerList
()
// this is dangerous. the spec says that we should _delay_
// sending the response if no new information is available.
// this means that would need to send a response later when
...
...
@@ -264,3 +264,25 @@ func (bp *baseProtocol) handshakeMsg() Msg {
bp
.
peer
.
ourID
.
Pubkey
()[
1
:
],
)
}
func
(
bp
*
baseProtocol
)
peerList
()
[]
interface
{}
{
peers
:=
bp
.
peer
.
otherPeers
()
ds
:=
make
([]
interface
{},
0
,
len
(
peers
))
for
_
,
p
:=
range
peers
{
p
.
infolock
.
Lock
()
addr
:=
p
.
listenAddr
p
.
infolock
.
Unlock
()
// filter out this peer and peers that are not listening or
// have not completed the handshake.
// TODO: track previously sent peers and exclude them as well.
if
p
==
bp
.
peer
||
addr
==
nil
{
continue
}
ds
=
append
(
ds
,
addr
)
}
ourAddr
:=
bp
.
peer
.
ourListenAddr
if
ourAddr
!=
nil
&&
!
ourAddr
.
IP
.
IsLoopback
()
&&
!
ourAddr
.
IP
.
IsUnspecified
()
{
ds
=
append
(
ds
,
ourAddr
)
}
return
ds
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment