pub struct AddressStatus { /* private fields */ }Expand description
Address status Contains information about the number of bans and the time until the next ban is lifted.
Implementations§
Source§impl AddressStatus
impl AddressStatus
Sourcepub fn ban(&mut self, base_ban_period: &Duration)
pub fn ban(&mut self, base_ban_period: &Duration)
Ban the Address so it won’t be available through AddressList::get_live_address for some time.
Back-compat shim for AddressStatus::ban_with_reason with no reason.
Sourcepub fn ban_with_reason(
&mut self,
base_ban_period: &Duration,
reason: Option<String>,
)
pub fn ban_with_reason( &mut self, base_ban_period: &Duration, reason: Option<String>, )
Ban the Address and record the reason for the ban.
Applies exponential backoff: the ban window is base × e^ban_count
(where ban_count is the value before this call), and banned_until
is always re-based to now + window unconditionally, regardless of any
existing active ban. Concretely, a health failure on a node that already
holds a longer rate-limit window (set via AddressStatus::ban_for) will
re-base banned_until to the exponential value, which may be shorter.
This is intentional: the exponential health-ban ladder owns the window for
genuinely-unhealthy nodes; the no-shorten guarantee is deliberately scoped
to ban_for → ban_for sequences only.
ban_count is incremented and ban_reason is updated unconditionally.
The counter resets to 0 on AddressStatus::unban.
Sourcepub fn ban_for(&mut self, period: Duration, reason: Option<String>)
pub fn ban_for(&mut self, period: Duration, reason: Option<String>)
Ban the address for an exact period (server-advertised), bypassing the
exponential ladder used by AddressStatus::ban_with_reason.
The ban window is flat (not exponential). banned_until is advanced to
now + period only when that timestamp is later than the current
banned_until, so a short-reset call never shortens a longer active ban
(health ban or a prior longer rate-limit ban). ban_reason is updated
only when the window is extended. ban_count is raised to
max(ban_count, 1) unconditionally so that is_banned() and
ban_info() correctly report the node as banned. Side-effect: a
previously-clean node (ban_count 0) enters the ladder at floor 1,
meaning its next genuine health failure via
AddressStatus::ban_with_reason uses 60 s × e¹ ≈ 163 s rather
than the first-rung 60 s × e⁰ = 60 s. The counter resets to 0 on
AddressStatus::unban.
Note: the no-shorten guard applies only to ban_for → ban_for call
sequences. AddressStatus::ban_with_reason re-bases banned_until
unconditionally — see its docs for the intentional cross-method semantics.
Trait Implementations§
Source§impl Clone for AddressStatus
impl Clone for AddressStatus
Source§fn clone(&self) -> AddressStatus
fn clone(&self) -> AddressStatus
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AddressStatus
impl Debug for AddressStatus
Source§impl Default for AddressStatus
impl Default for AddressStatus
Source§fn default() -> AddressStatus
fn default() -> AddressStatus
Auto Trait Implementations§
impl Freeze for AddressStatus
impl RefUnwindSafe for AddressStatus
impl Send for AddressStatus
impl Sync for AddressStatus
impl Unpin for AddressStatus
impl UnsafeUnpin for AddressStatus
impl UnwindSafe for AddressStatus
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T, U> IntoPlatformVersioned<U> for Twhere
U: FromPlatformVersioned<T>,
impl<T, U> IntoPlatformVersioned<U> for Twhere
U: FromPlatformVersioned<T>,
Source§fn into_platform_versioned(self, platform_version: &PlatformVersion) -> U
fn into_platform_versioned(self, platform_version: &PlatformVersion) -> U
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].