Cleanup v0.2.0
This commit is contained in:
parent
dfecca72ef
commit
ca538e887e
5
.github/workflows/test-suite.yml
vendored
5
.github/workflows/test-suite.yml
vendored
@ -74,11 +74,6 @@ jobs:
|
|||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
- name: Typecheck benchmark code without running it
|
- name: Typecheck benchmark code without running it
|
||||||
run: make check-benches
|
run: make check-benches
|
||||||
install-lcli:
|
|
||||||
- name: Get latest version of stable Rust
|
|
||||||
run: rustup update stable
|
|
||||||
- name: Build lcli via Makefile
|
|
||||||
run: make install-lcli
|
|
||||||
clippy:
|
clippy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: cargo-fmt
|
needs: cargo-fmt
|
||||||
|
@ -480,10 +480,10 @@ impl<TSubstream: AsyncRead + AsyncWrite, TSpec: EthSpec> Behaviour<TSubstream, T
|
|||||||
PeerManagerEvent::MetaData(peer_id) => {
|
PeerManagerEvent::MetaData(peer_id) => {
|
||||||
self.send_meta_data_request(peer_id);
|
self.send_meta_data_request(peer_id);
|
||||||
}
|
}
|
||||||
PeerManagerEvent::DisconnectPeer(_peer_id) => {
|
PeerManagerEvent::_DisconnectPeer(_peer_id) => {
|
||||||
//TODO: Implement
|
//TODO: Implement
|
||||||
}
|
}
|
||||||
PeerManagerEvent::BanPeer(_peer_id) => {
|
PeerManagerEvent::_BanPeer(_peer_id) => {
|
||||||
//TODO: Implement
|
//TODO: Implement
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -21,7 +21,7 @@ mod peerdb;
|
|||||||
pub use peer_info::{PeerInfo, PeerSyncStatus};
|
pub use peer_info::{PeerInfo, PeerSyncStatus};
|
||||||
/// The minimum reputation before a peer is disconnected.
|
/// The minimum reputation before a peer is disconnected.
|
||||||
// Most likely this needs tweaking
|
// Most likely this needs tweaking
|
||||||
const MINIMUM_REPUTATION_BEFORE_BAN: Rep = 20;
|
const _MINIMUM_REPUTATION_BEFORE_BAN: Rep = 20;
|
||||||
/// The time in seconds between re-status's peers.
|
/// The time in seconds between re-status's peers.
|
||||||
const STATUS_INTERVAL: u64 = 300;
|
const STATUS_INTERVAL: u64 = 300;
|
||||||
/// The time in seconds between PING events. We do not send a ping if the other peer as PING'd us within
|
/// The time in seconds between PING events. We do not send a ping if the other peer as PING'd us within
|
||||||
@ -48,13 +48,13 @@ pub struct PeerManager<TSpec: EthSpec> {
|
|||||||
/// Each variant has an associated reputation change.
|
/// Each variant has an associated reputation change.
|
||||||
pub enum PeerAction {
|
pub enum PeerAction {
|
||||||
/// The peer timed out on an RPC request/response.
|
/// The peer timed out on an RPC request/response.
|
||||||
TimedOut = -10,
|
_TimedOut = -10,
|
||||||
/// The peer sent and invalid request/response or encoding.
|
/// The peer sent and invalid request/response or encoding.
|
||||||
InvalidMessage = -20,
|
_InvalidMessage = -20,
|
||||||
/// The peer sent something objectively malicious.
|
/// The peer sent something objectively malicious.
|
||||||
Malicious = -50,
|
_Malicious = -50,
|
||||||
/// Received an expected message.
|
/// Received an expected message.
|
||||||
ValidMessage = 20,
|
_ValidMessage = 20,
|
||||||
/// Peer disconnected.
|
/// Peer disconnected.
|
||||||
Disconnected = -30,
|
Disconnected = -30,
|
||||||
}
|
}
|
||||||
@ -68,9 +68,9 @@ pub enum PeerManagerEvent {
|
|||||||
/// Request METADATA from a peer.
|
/// Request METADATA from a peer.
|
||||||
MetaData(PeerId),
|
MetaData(PeerId),
|
||||||
/// The peer should be disconnected.
|
/// The peer should be disconnected.
|
||||||
DisconnectPeer(PeerId),
|
_DisconnectPeer(PeerId),
|
||||||
/// The peer should be disconnected and banned.
|
/// The peer should be disconnected and banned.
|
||||||
BanPeer(PeerId),
|
_BanPeer(PeerId),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<TSpec: EthSpec> PeerManager<TSpec> {
|
impl<TSpec: EthSpec> PeerManager<TSpec> {
|
||||||
@ -165,16 +165,17 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
|
|||||||
|
|
||||||
/// Checks the reputation of a peer and if it is too low, bans it and
|
/// Checks the reputation of a peer and if it is too low, bans it and
|
||||||
/// sends the corresponding event. Informs if it got banned
|
/// sends the corresponding event. Informs if it got banned
|
||||||
fn gets_banned(&mut self, peer_id: &PeerId) -> bool {
|
fn _gets_banned(&mut self, peer_id: &PeerId) -> bool {
|
||||||
// if the peer was already banned don't inform again
|
// if the peer was already banned don't inform again
|
||||||
let mut peerdb = self.network_globals.peers.write();
|
let mut peerdb = self.network_globals.peers.write();
|
||||||
|
|
||||||
if let Some(connection_status) = peerdb.connection_status(peer_id) {
|
if let Some(connection_status) = peerdb.connection_status(peer_id) {
|
||||||
if peerdb.reputation(peer_id) < MINIMUM_REPUTATION_BEFORE_BAN
|
if peerdb.reputation(peer_id) < _MINIMUM_REPUTATION_BEFORE_BAN
|
||||||
&& !connection_status.is_banned()
|
&& !connection_status.is_banned()
|
||||||
{
|
{
|
||||||
peerdb.ban(peer_id);
|
peerdb.ban(peer_id);
|
||||||
self.events.push(PeerManagerEvent::BanPeer(peer_id.clone()));
|
self.events
|
||||||
|
.push(PeerManagerEvent::_BanPeer(peer_id.clone()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -182,9 +183,9 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Requests that a peer get disconnected.
|
/// Requests that a peer get disconnected.
|
||||||
pub fn disconnect_peer(&mut self, peer_id: &PeerId) {
|
pub fn _disconnect_peer(&mut self, peer_id: &PeerId) {
|
||||||
self.events
|
self.events
|
||||||
.push(PeerManagerEvent::DisconnectPeer(peer_id.clone()));
|
.push(PeerManagerEvent::_DisconnectPeer(peer_id.clone()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Updates the state of the peer as disconnected.
|
/// Updates the state of the peer as disconnected.
|
||||||
@ -219,7 +220,7 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Provides a given peer's reputation if it exists.
|
/// Provides a given peer's reputation if it exists.
|
||||||
pub fn get_peer_rep(&self, peer_id: &PeerId) -> Rep {
|
pub fn _get_peer_rep(&self, peer_id: &PeerId) -> Rep {
|
||||||
self.network_globals.peers.read().reputation(peer_id)
|
self.network_globals.peers.read().reputation(peer_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,7 +242,7 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
|
|||||||
/// Reports a peer for some action.
|
/// Reports a peer for some action.
|
||||||
///
|
///
|
||||||
/// If the peer doesn't exist, log a warning and insert defaults.
|
/// If the peer doesn't exist, log a warning and insert defaults.
|
||||||
pub fn report_peer(&mut self, peer_id: &PeerId, action: PeerAction) {
|
pub fn _report_peer(&mut self, peer_id: &PeerId, action: PeerAction) {
|
||||||
self.update_reputations();
|
self.update_reputations();
|
||||||
self.network_globals
|
self.network_globals
|
||||||
.peers
|
.peers
|
||||||
|
Loading…
Reference in New Issue
Block a user