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
dcf4fad9
Commit
dcf4fad9
authored
Jul 24, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Networking code
parent
6d69ca36
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
12 deletions
+16
-12
peer.go
peer.go
+16
-12
No files found.
peer.go
View file @
dcf4fad9
...
...
@@ -177,18 +177,7 @@ func NewOutboundPeer(addr string, ethereum *Ethereum, caps Caps) *Peer {
// Set up the connection in another goroutine so we don't block the main thread
go
func
()
{
var
(
err
error
conn
net
.
Conn
)
for
attempts
:=
0
;
attempts
<
5
;
attempts
++
{
conn
,
err
=
net
.
DialTimeout
(
"tcp"
,
addr
,
10
*
time
.
Second
)
if
err
!=
nil
{
peerlogger
.
Debugf
(
"Peer connection failed. Retrying (%d/5)
\n
"
,
attempts
+
1
)
}
}
conn
,
err
:=
p
.
Connect
(
addr
)
if
err
!=
nil
{
peerlogger
.
Debugln
(
"Connection to peer failed. Giving up."
,
err
)
p
.
Stop
()
...
...
@@ -206,6 +195,21 @@ func NewOutboundPeer(addr string, ethereum *Ethereum, caps Caps) *Peer {
return
p
}
func
(
self
*
Peer
)
Connect
(
addr
string
)
(
conn
net
.
Conn
,
err
error
)
{
for
attempts
:=
0
;
attempts
<
5
;
attempts
++
{
conn
,
err
=
net
.
DialTimeout
(
"tcp"
,
addr
,
10
*
time
.
Second
)
if
err
!=
nil
{
peerlogger
.
Debugf
(
"Peer connection failed. Retrying (%d/5)
\n
"
,
attempts
+
1
)
continue
}
// Success
return
}
return
}
// Getters
func
(
p
*
Peer
)
PingTime
()
string
{
return
p
.
pingTime
.
String
()
...
...
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