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
7bd3f3d7
Commit
7bd3f3d7
authored
2 years ago
by
Sebastian Kunert
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Remove unused light-client leftover (#13687)
* Remove unused light-client leftover * Remove more unused code
parent
08099005
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
substrate/client/network/sync/src/engine.rs
+1
-38
1 addition, 38 deletions
substrate/client/network/sync/src/engine.rs
with
1 addition
and
38 deletions
substrate/client/network/sync/src/engine.rs
+
1
−
38
View file @
7bd3f3d7
...
...
@@ -58,10 +58,7 @@ use sc_network_common::{
use
sc_utils
::
mpsc
::{
tracing_unbounded
,
TracingUnboundedReceiver
,
TracingUnboundedSender
};
use
sp_blockchain
::
HeaderMetadata
;
use
sp_consensus
::
block_validation
::
BlockAnnounceValidator
;
use
sp_runtime
::{
traits
::{
Block
as
BlockT
,
CheckedSub
,
Header
,
NumberFor
,
Zero
},
SaturatedConversion
,
};
use
sp_runtime
::
traits
::{
Block
as
BlockT
,
Header
,
NumberFor
,
Zero
};
use
std
::{
collections
::{
HashMap
,
HashSet
},
...
...
@@ -77,24 +74,15 @@ use std::{
/// Interval at which we perform time based maintenance
const
TICK_TIMEOUT
:
std
::
time
::
Duration
=
std
::
time
::
Duration
::
from_millis
(
1100
);
/// When light node connects to the full node and the full node is behind light node
/// for at least `LIGHT_MAXIMAL_BLOCKS_DIFFERENCE` blocks, we consider it not useful
/// and disconnect to free connection slot.
const
LIGHT_MAXIMAL_BLOCKS_DIFFERENCE
:
u64
=
8192
;
/// Maximum number of known block hashes to keep for a peer.
const
MAX_KNOWN_BLOCKS
:
usize
=
1024
;
// ~32kb per peer + LruHashSet overhead
mod
rep
{
use
sc_peerset
::
ReputationChange
as
Rep
;
/// Reputation change when we are a light client and a peer is behind us.
pub
const
PEER_BEHIND_US_LIGHT
:
Rep
=
Rep
::
new
(
-
(
1
<<
8
),
"Useless for a light peer"
);
/// We received a message that failed to decode.
pub
const
BAD_MESSAGE
:
Rep
=
Rep
::
new
(
-
(
1
<<
12
),
"Bad message"
);
/// Peer has different genesis.
pub
const
GENESIS_MISMATCH
:
Rep
=
Rep
::
new_fatal
(
"Genesis mismatch"
);
/// Peer role does not match (e.g. light peer connecting to another light peer).
pub
const
BAD_ROLE
:
Rep
=
Rep
::
new_fatal
(
"Unsupported role"
);
/// Peer send us a block announcement that failed at validation.
pub
const
BAD_BLOCK_ANNOUNCEMENT
:
Rep
=
Rep
::
new
(
-
(
1
<<
12
),
"Bad block announcement"
);
}
...
...
@@ -834,31 +822,6 @@ where
return
Err
(())
}
if
self
.roles
.is_light
()
{
// we're not interested in light peers
if
status
.roles
.is_light
()
{
log
::
debug!
(
target
:
"sync"
,
"Peer {} is unable to serve light requests"
,
who
);
self
.network_service
.report_peer
(
who
,
rep
::
BAD_ROLE
);
self
.network_service
.disconnect_peer
(
who
,
self
.block_announce_protocol_name
.clone
());
return
Err
(())
}
// we don't interested in peers that are far behind us
let
self_best_block
=
self
.client
.info
()
.best_number
;
let
blocks_difference
=
self_best_block
.checked_sub
(
&
status
.best_number
)
.unwrap_or_else
(
Zero
::
zero
)
.saturated_into
::
<
u64
>
();
if
blocks_difference
>
LIGHT_MAXIMAL_BLOCKS_DIFFERENCE
{
log
::
debug!
(
target
:
"sync"
,
"Peer {} is far behind us and will unable to serve light requests"
,
who
);
self
.network_service
.report_peer
(
who
,
rep
::
PEER_BEHIND_US_LIGHT
);
self
.network_service
.disconnect_peer
(
who
,
self
.block_announce_protocol_name
.clone
());
return
Err
(())
}
}
let
no_slot_peer
=
self
.default_peers_set_no_slot_peers
.contains
(
&
who
);
let
this_peer_reserved_slot
:
usize
=
if
no_slot_peer
{
1
}
else
{
0
};
...
...
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