good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
fc4fee86
Unverified
Commit
fc4fee86
authored
Jun 12, 2019
by
Péter Szilágyi
Browse files
Options
Downloads
Patches
Plain Diff
eth: enforce stricter known limits on idle peers
parent
50e3795e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
eth/peer.go
+24
-0
24 additions, 0 deletions
eth/peer.go
with
24 additions
and
0 deletions
eth/peer.go
+
24
−
0
View file @
fc4fee86
...
...
@@ -196,9 +196,13 @@ func (p *peer) MarkTransaction(hash common.Hash) {
// SendTransactions sends transactions to the peer and includes the hashes
// in its transaction hash set for future reference.
func
(
p
*
peer
)
SendTransactions
(
txs
types
.
Transactions
)
error
{
// Mark all the transactions as known, but ensure we don't overflow our limits
for
_
,
tx
:=
range
txs
{
p
.
knownTxs
.
Add
(
tx
.
Hash
())
}
for
p
.
knownTxs
.
Cardinality
()
>=
maxKnownTxs
{
p
.
knownTxs
.
Pop
()
}
return
p2p
.
Send
(
p
.
rw
,
TxMsg
,
txs
)
}
...
...
@@ -207,9 +211,13 @@ func (p *peer) SendTransactions(txs types.Transactions) error {
func
(
p
*
peer
)
AsyncSendTransactions
(
txs
[]
*
types
.
Transaction
)
{
select
{
case
p
.
queuedTxs
<-
txs
:
// Mark all the transactions as known, but ensure we don't overflow our limits
for
_
,
tx
:=
range
txs
{
p
.
knownTxs
.
Add
(
tx
.
Hash
())
}
for
p
.
knownTxs
.
Cardinality
()
>=
maxKnownTxs
{
p
.
knownTxs
.
Pop
()
}
default
:
p
.
Log
()
.
Debug
(
"Dropping transaction propagation"
,
"count"
,
len
(
txs
))
}
...
...
@@ -218,9 +226,13 @@ func (p *peer) AsyncSendTransactions(txs []*types.Transaction) {
// SendNewBlockHashes announces the availability of a number of blocks through
// a hash notification.
func
(
p
*
peer
)
SendNewBlockHashes
(
hashes
[]
common
.
Hash
,
numbers
[]
uint64
)
error
{
// Mark all the block hashes as known, but ensure we don't overflow our limits
for
_
,
hash
:=
range
hashes
{
p
.
knownBlocks
.
Add
(
hash
)
}
for
p
.
knownBlocks
.
Cardinality
()
>=
maxKnownBlocks
{
p
.
knownBlocks
.
Pop
()
}
request
:=
make
(
newBlockHashesData
,
len
(
hashes
))
for
i
:=
0
;
i
<
len
(
hashes
);
i
++
{
request
[
i
]
.
Hash
=
hashes
[
i
]
...
...
@@ -235,7 +247,11 @@ func (p *peer) SendNewBlockHashes(hashes []common.Hash, numbers []uint64) error
func
(
p
*
peer
)
AsyncSendNewBlockHash
(
block
*
types
.
Block
)
{
select
{
case
p
.
queuedAnns
<-
block
:
// Mark all the block hash as known, but ensure we don't overflow our limits
p
.
knownBlocks
.
Add
(
block
.
Hash
())
for
p
.
knownBlocks
.
Cardinality
()
>=
maxKnownBlocks
{
p
.
knownBlocks
.
Pop
()
}
default
:
p
.
Log
()
.
Debug
(
"Dropping block announcement"
,
"number"
,
block
.
NumberU64
(),
"hash"
,
block
.
Hash
())
}
...
...
@@ -243,7 +259,11 @@ func (p *peer) AsyncSendNewBlockHash(block *types.Block) {
// SendNewBlock propagates an entire block to a remote peer.
func
(
p
*
peer
)
SendNewBlock
(
block
*
types
.
Block
,
td
*
big
.
Int
)
error
{
// Mark all the block hash as known, but ensure we don't overflow our limits
p
.
knownBlocks
.
Add
(
block
.
Hash
())
for
p
.
knownBlocks
.
Cardinality
()
>=
maxKnownBlocks
{
p
.
knownBlocks
.
Pop
()
}
return
p2p
.
Send
(
p
.
rw
,
NewBlockMsg
,
[]
interface
{}{
block
,
td
})
}
...
...
@@ -252,7 +272,11 @@ func (p *peer) SendNewBlock(block *types.Block, td *big.Int) error {
func
(
p
*
peer
)
AsyncSendNewBlock
(
block
*
types
.
Block
,
td
*
big
.
Int
)
{
select
{
case
p
.
queuedProps
<-
&
propEvent
{
block
:
block
,
td
:
td
}
:
// Mark all the block hash as known, but ensure we don't overflow our limits
p
.
knownBlocks
.
Add
(
block
.
Hash
())
for
p
.
knownBlocks
.
Cardinality
()
>=
maxKnownBlocks
{
p
.
knownBlocks
.
Pop
()
}
default
:
p
.
Log
()
.
Debug
(
"Dropping block propagation"
,
"number"
,
block
.
NumberU64
(),
"hash"
,
block
.
Hash
())
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment