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
42123b43
Commit
42123b43
authored
Feb 10, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed peer handling
parent
0ae6a388
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
peer.go
peer.go
+8
-7
No files found.
peer.go
View file @
42123b43
...
...
@@ -319,7 +319,8 @@ func (p *Peer) HandleInbound() {
peers
:=
make
([]
string
,
data
.
Length
())
// Parse each possible peer
for
i
:=
0
;
i
<
data
.
Length
();
i
++
{
peers
[
i
]
=
unpackAddr
(
data
.
Get
(
i
)
.
Get
(
0
),
data
.
Get
(
i
)
.
Get
(
1
)
.
AsUint
())
value
:=
ethutil
.
NewValue
(
data
.
Get
(
i
)
.
AsRaw
())
peers
[
i
]
=
unpackAddr
(
value
.
Get
(
0
),
value
.
Get
(
1
)
.
Uint
())
}
// Connect to the list of peers
...
...
@@ -380,17 +381,17 @@ func packAddr(address, port string) ([]interface{}, uint16) {
b
,
_
:=
strconv
.
Atoi
(
addr
[
1
])
c
,
_
:=
strconv
.
Atoi
(
addr
[
2
])
d
,
_
:=
strconv
.
Atoi
(
addr
[
3
])
host
:=
[]
interface
{}{
byte
(
a
),
byte
(
b
),
byte
(
c
),
byte
(
d
)}
host
:=
[]
interface
{}{
int32
(
a
),
int32
(
b
),
int32
(
c
),
int32
(
d
)}
prt
,
_
:=
strconv
.
Atoi
(
port
)
return
host
,
uint16
(
prt
)
}
func
unpackAddr
(
value
*
ethutil
.
Rlp
Value
,
p
uint64
)
string
{
a
:=
strconv
.
Itoa
(
int
(
value
.
Get
(
0
)
.
As
Uint
()))
b
:=
strconv
.
Itoa
(
int
(
value
.
Get
(
1
)
.
As
Uint
()))
c
:=
strconv
.
Itoa
(
int
(
value
.
Get
(
2
)
.
As
Uint
()))
d
:=
strconv
.
Itoa
(
int
(
value
.
Get
(
3
)
.
As
Uint
()))
func
unpackAddr
(
value
*
ethutil
.
Value
,
p
uint64
)
string
{
a
:=
strconv
.
Itoa
(
int
(
value
.
Get
(
0
)
.
Uint
()))
b
:=
strconv
.
Itoa
(
int
(
value
.
Get
(
1
)
.
Uint
()))
c
:=
strconv
.
Itoa
(
int
(
value
.
Get
(
2
)
.
Uint
()))
d
:=
strconv
.
Itoa
(
int
(
value
.
Get
(
3
)
.
Uint
()))
host
:=
strings
.
Join
([]
string
{
a
,
b
,
c
,
d
},
"."
)
port
:=
strconv
.
Itoa
(
int
(
p
))
...
...
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