Correct peer connection transition logic (#2725)
## Description This PR updates the peer connection transition logic. It is acceptable for a peer to immediately transition from a disconnected state to a disconnecting state. This can occur when we are at our peer limit and a new peer's dial us.
This commit is contained in:
parent
a7b675460d
commit
180c90bf6d
24
Cargo.lock
generated
24
Cargo.lock
generated
@ -107,9 +107,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ahash"
|
name = "ahash"
|
||||||
version = "0.7.5"
|
version = "0.7.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "991984e3fd003e7ba02eb724f87a0f997b78677c46c0e91f8424ad7394c9886a"
|
checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"getrandom 0.2.3",
|
"getrandom 0.2.3",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
@ -3029,9 +3029,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.103"
|
version = "0.2.104"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dd8f7255a17a627354f321ef0055d63b898c6fb27eff628af4d1b66b7331edf6"
|
checksum = "7b2f96d100e1cf1929e7719b7edb3b90ab5298072638fccd77be9ce942ecdfce"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libflate"
|
name = "libflate"
|
||||||
@ -3115,7 +3115,7 @@ dependencies = [
|
|||||||
"log",
|
"log",
|
||||||
"multiaddr",
|
"multiaddr",
|
||||||
"multihash",
|
"multihash",
|
||||||
"multistream-select 0.10.2",
|
"multistream-select 0.10.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"pin-project 1.0.8",
|
"pin-project 1.0.8",
|
||||||
"prost",
|
"prost",
|
||||||
@ -3148,7 +3148,7 @@ dependencies = [
|
|||||||
"log",
|
"log",
|
||||||
"multiaddr",
|
"multiaddr",
|
||||||
"multihash",
|
"multihash",
|
||||||
"multistream-select 0.10.4",
|
"multistream-select 0.10.4 (git+https://github.com/libp2p/rust-libp2p?rev=ce23cbe76a0382b6fcb0e49f1b2612df86f6465d)",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"pin-project 1.0.8",
|
"pin-project 1.0.8",
|
||||||
"prost",
|
"prost",
|
||||||
@ -3868,9 +3868,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mio"
|
name = "mio"
|
||||||
version = "0.7.13"
|
version = "0.7.14"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8c2bdb6314ec10835cd3293dd268473a835c02b7b352e788be788b3c6ca6bb16"
|
checksum = "8067b404fe97c70829f082dec8bcf4f71225d7eaea1d8645349cb76fa06205cc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
@ -3979,9 +3979,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "multistream-select"
|
name = "multistream-select"
|
||||||
version = "0.10.2"
|
version = "0.10.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7d91ec0a2440aaff5f78ec35631a7027d50386c6163aa975f7caa0d5da4b6ff8"
|
checksum = "56a336acba8bc87c8876f6425407dbbe6c417bf478b22015f8fb0994ef3bc0ab"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes 1.1.0",
|
"bytes 1.1.0",
|
||||||
"futures",
|
"futures",
|
||||||
@ -4542,9 +4542,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ppv-lite86"
|
name = "ppv-lite86"
|
||||||
version = "0.2.10"
|
version = "0.2.14"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
|
checksum = "c3ca011bd0129ff4ae15cd04c4eef202cadf6c51c21e47aba319b4e0501db741"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "primitive-types"
|
name = "primitive-types"
|
||||||
|
@ -782,15 +782,15 @@ impl<TSpec: EthSpec> PeerDB<TSpec> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Handle the transition to the disconnecting state */
|
/* Handle the transition to the disconnecting state */
|
||||||
(
|
(PeerConnectionStatus::Banned { .. }, NewConnectionState::Disconnecting { to_ban }) => {
|
||||||
PeerConnectionStatus::Banned { .. } | PeerConnectionStatus::Disconnected { .. },
|
error!(self.log, "Disconnecting from a banned peer"; "peer_id" => %peer_id);
|
||||||
NewConnectionState::Disconnecting { to_ban },
|
|
||||||
) => {
|
|
||||||
error!(self.log, "Disconnecting from an already disconnected peer"; "peer_id" => %peer_id);
|
|
||||||
info.set_connection_status(PeerConnectionStatus::Disconnecting { to_ban });
|
info.set_connection_status(PeerConnectionStatus::Disconnecting { to_ban });
|
||||||
}
|
}
|
||||||
(_, NewConnectionState::Disconnecting { to_ban }) => {
|
(_, NewConnectionState::Disconnecting { to_ban }) => {
|
||||||
// We overwrite all states and set this peer to be disconnecting.
|
// We overwrite all states and set this peer to be disconnecting.
|
||||||
|
// NOTE: A peer can be in the disconnected state and transition straight to a
|
||||||
|
// disconnected state. This occurs when a disconnected peer dials us, we have too
|
||||||
|
// many peers and we transition them straight to the disconnecting state.
|
||||||
info.set_connection_status(PeerConnectionStatus::Disconnecting { to_ban });
|
info.set_connection_status(PeerConnectionStatus::Disconnecting { to_ban });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user