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
82f0bd90
Commit
82f0bd90
authored
Feb 12, 2015
by
Felix Lange
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
p2p/discover: code review fixes
parent
d0a2e655
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
7 deletions
+9
-7
node.go
p2p/discover/node.go
+3
-1
table.go
p2p/discover/table.go
+4
-4
udp.go
p2p/discover/udp.go
+2
-2
No files found.
p2p/discover/node.go
View file @
82f0bd90
...
...
@@ -18,6 +18,8 @@ import (
"github.com/ethereum/go-ethereum/rlp"
)
const
nodeIDBits
=
512
// Node represents a host on the network.
type
Node
struct
{
ID
NodeID
...
...
@@ -135,7 +137,7 @@ func (n *Node) DecodeRLP(s *rlp.Stream) (err error) {
// NodeID is a unique identifier for each node.
// The node identifier is a marshaled elliptic curve public key.
type
NodeID
[
512
/
8
]
byte
type
NodeID
[
nodeIDBits
/
8
]
byte
// NodeID prints as a long hexadecimal number.
func
(
n
NodeID
)
String
()
string
{
...
...
p2p/discover/table.go
View file @
82f0bd90
...
...
@@ -14,9 +14,9 @@ import (
)
const
(
alpha
=
3
// Kademlia concurrency factor
bucketSize
=
16
// Kademlia bucket size
nBuckets
=
len
(
NodeID
{})
*
8
+
1
// Number of buckets
alpha
=
3
// Kademlia concurrency factor
bucketSize
=
16
// Kademlia bucket size
nBuckets
=
nodeIDBits
+
1
// Number of buckets
)
type
Table
struct
{
...
...
@@ -100,7 +100,7 @@ func (tab *Table) Lookup(target NodeID) []*Node {
tab
.
mutex
.
Unlock
()
for
{
// ask the closest nodes that we haven't asked yet
// ask the
alpha
closest nodes that we haven't asked yet
for
i
:=
0
;
i
<
len
(
result
.
entries
)
&&
pendingQueries
<
alpha
;
i
++
{
n
:=
result
.
entries
[
i
]
if
!
asked
[
n
.
ID
]
{
...
...
p2p/discover/udp.go
View file @
82f0bd90
...
...
@@ -28,7 +28,7 @@ var (
const
(
respTimeout
=
300
*
time
.
Millisecond
sendTimeout
=
300
*
time
.
Millisecond
expiration
=
3
*
time
.
Second
expiration
=
20
*
time
.
Second
refreshInterval
=
1
*
time
.
Hour
)
...
...
@@ -185,7 +185,7 @@ func (t *udp) findnode(to *Node, target NodeID) ([]*Node, error) {
nodes
=
append
(
nodes
,
n
)
}
}
return
nreceived
=
=
bucketSize
return
nreceived
>
=
bucketSize
})
t
.
send
(
to
,
findnodePacket
,
findnode
{
...
...
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