Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
polkadot-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package 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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
parity
Mirrored projects
polkadot-sdk
Commits
be117006
Commit
be117006
authored
2 years ago
by
Nathan Whitaker
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Don't ban peers for small duplicate requests (#11084)
* Don't ban peers for small duplicate requests * Address review comment
parent
dd35c571
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
substrate/client/network/src/block_request_handler.rs
+13
-1
13 additions, 1 deletion
substrate/client/network/src/block_request_handler.rs
with
13 additions
and
1 deletion
substrate/client/network/src/block_request_handler.rs
+
13
−
1
View file @
be117006
...
...
@@ -54,6 +54,10 @@ mod rep {
/// Reputation change when a peer sent us the same request multiple times.
pub
const
SAME_REQUEST
:
Rep
=
Rep
::
new_fatal
(
"Same block request multiple times"
);
/// Reputation change when a peer sent us the same "small" request multiple times.
pub
const
SAME_SMALL_REQUEST
:
Rep
=
Rep
::
new
(
-
(
1
<<
10
),
"same small block request multiple times"
);
}
/// Generates a [`ProtocolConfig`] for the block request protocol, refusing incoming requests.
...
...
@@ -200,8 +204,16 @@ impl<B: BlockT> BlockRequestHandler<B> {
Some
(
SeenRequestsValue
::
Fulfilled
(
ref
mut
requests
))
=>
{
*
requests
=
requests
.saturating_add
(
1
);
let
small_request
=
attributes
.difference
(
BlockAttributes
::
HEADER
|
BlockAttributes
::
JUSTIFICATION
)
.is_empty
();
if
*
requests
>
MAX_NUMBER_OF_SAME_REQUESTS_PER_PEER
{
reputation_change
=
Some
(
rep
::
SAME_REQUEST
);
reputation_change
=
Some
(
if
small_request
{
rep
::
SAME_SMALL_REQUEST
}
else
{
rep
::
SAME_REQUEST
});
}
},
None
=>
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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