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
3c8227b9
Commit
3c8227b9
authored
May 20, 2015
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth: fix odd method names in peer set
parent
79042223
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
7 deletions
+7
-7
handler.go
eth/handler.go
+2
-2
peer.go
eth/peer.go
+5
-5
No files found.
eth/handler.go
View file @
3c8227b9
...
...
@@ -350,7 +350,7 @@ func (pm *ProtocolManager) verifyTd(peer *peer, request newBlockMsgData) error {
// sqrt(peers) to determine the amount of peers we broadcast to.
func
(
pm
*
ProtocolManager
)
BroadcastBlock
(
hash
common
.
Hash
,
block
*
types
.
Block
)
{
// Broadcast block to a batch of peers not knowing about it
peers
:=
pm
.
peers
.
BlockLackingPeers
(
hash
)
peers
:=
pm
.
peers
.
PeersWithoutBlock
(
hash
)
peers
=
peers
[
:
int
(
math
.
Sqrt
(
float64
(
len
(
peers
))))]
for
_
,
peer
:=
range
peers
{
peer
.
sendNewBlock
(
block
)
...
...
@@ -363,7 +363,7 @@ func (pm *ProtocolManager) BroadcastBlock(hash common.Hash, block *types.Block)
// sqrt(peers) to determine the amount of peers we broadcast to.
func
(
pm
*
ProtocolManager
)
BroadcastTx
(
hash
common
.
Hash
,
tx
*
types
.
Transaction
)
{
// Broadcast transaction to a batch of peers not knowing about it
peers
:=
pm
.
peers
.
TxLackingPeers
(
hash
)
peers
:=
pm
.
peers
.
PeersWithoutTx
(
hash
)
//FIXME include this again: peers = peers[:int(math.Sqrt(float64(len(peers))))]
for
_
,
peer
:=
range
peers
{
peer
.
sendTransaction
(
tx
)
...
...
eth/peer.go
View file @
3c8227b9
...
...
@@ -213,9 +213,9 @@ func (ps *peerSet) Len() int {
return
len
(
ps
.
peers
)
}
//
BlockLackingPeers retrieves a list of peers that do not have a given block
//
in
their set of known hashes.
func
(
ps
*
peerSet
)
BlockLackingPeers
(
hash
common
.
Hash
)
[]
*
peer
{
//
PeersWithoutBlock retrieves a list of peers that do not have a given block in
// their set of known hashes.
func
(
ps
*
peerSet
)
PeersWithoutBlock
(
hash
common
.
Hash
)
[]
*
peer
{
ps
.
lock
.
RLock
()
defer
ps
.
lock
.
RUnlock
()
...
...
@@ -228,9 +228,9 @@ func (ps *peerSet) BlockLackingPeers(hash common.Hash) []*peer {
return
list
}
//
TxLackingPeers
retrieves a list of peers that do not have a given transaction
//
PeersWithoutTx
retrieves a list of peers that do not have a given transaction
// in their set of known hashes.
func
(
ps
*
peerSet
)
TxLackingPeers
(
hash
common
.
Hash
)
[]
*
peer
{
func
(
ps
*
peerSet
)
PeersWithoutTx
(
hash
common
.
Hash
)
[]
*
peer
{
ps
.
lock
.
RLock
()
defer
ps
.
lock
.
RUnlock
()
...
...
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