struct RaceHistory {
races: VecDeque<Race>,
open: HashMap<HoprSurbId, Race>,
open_legs: HashMap<HoprSurbId, ([Option<OffchainPublicKey>; 5], usize)>,
memory: Duration,
last_home: HashMap<Hop, Instant>,
}Fields§
§races: VecDeque<Race>§open: HashMap<HoprSurbId, Race>Races whose partner is home while this relayer’s reply is not, by the SURB still out. Each counts as lost by at least the time since the partner came home.
open_legs: HashMap<HoprSurbId, ([Option<OffchainPublicKey>; 5], usize)>The leg each of those replies is out on, and this relayer’s position on it. Beside open and
not in it: a race is the same race over any leg, the leg only decides how long the reply is
given and which reply answers it (see unanswered).
memory: DurationHow far back its races count, set when it is judged; zero until then.
last_home: HashMap<Hop, Instant>When a reply last came home through this relayer over each of its two hops, whether or not it
settled a race.
Forgotten after PENDING_SURB_TTL, when no open race is old enough for it to matter.
Implementations§
Source§impl RaceHistory
impl RaceHistory
fn forget_older_than(&mut self, memory: Duration)
Sourcefn finished(&self) -> impl Iterator<Item = &Race>
fn finished(&self) -> impl Iterator<Item = &Race>
The races that settled, as opposed to those that expired open and were booked as lost.
Sourcefn bar(&self, fallback_usual: Option<f64>) -> Option<f64>
fn bar(&self, fallback_usual: Option<f64>) -> Option<f64>
The bar this relayer’s replies are held to: how late one usually is (see
usual_margin), or, while it has settled too few races for that,
fallback_usual raised to whatever its own settled races measure. None while neither exists.
Sourcefn usual_margin(&self) -> Option<f64>
fn usual_margin(&self) -> Option<f64>
How late a reply of this relayer usually is: the largest margin of its settled races, or None
until it has settled MIN_RACES of them, too few for the figure to mean anything.
Sourcefn unanswered(
&self,
last_reply: Option<Instant>,
fallback_usual: Option<f64>,
bars: &HashMap<OffchainPublicKey, f64>,
) -> Vec<(HoprSurbId, Instant)>
fn unanswered( &self, last_reply: Option<Instant>, fallback_usual: Option<f64>, bars: &HashMap<OffchainPublicKey, f64>, ) -> Vec<(HoprSurbId, Instant)>
The replies through it that are out for longer than its bar, with nothing home through it, over
the hop each of them is out on, since it fell due. At least MIN_RACES of them that nothing has
come home after over either hop make it a black hole (see unanswered_at_all),
and MIN_RACES_OVER_ONE_HOP over one hop while it delivers over the other make it one over that
hop (see hop_at_fault). The bar is the largest margin of the races it
finished, or, while it has finished too few, the borrowed one below.
A reply is overdue only if a reply came home, through any relayer, after its grace ran out
(last_reply): the network was delivering while this relayer was not. Without that, nothing
tells a dead relayer from a pause. The replier’s stream stops for a settle, a phase change or
idle, nothing is home for anybody during it, and a few replies lost at random before it would
pass for a verdict, each costing the session its whole stock. An outage of every return
relayer is likewise no verdict on any one of them. When the stream resumes an alive relayer
settles a race, which clears the condition below, while a dead one never does.
A relayer that has settled fewer than MIN_RACES races has no margin of its own to go by,
and races settle only in the abnormal order, so a clean history is common. It borrows
fallback_usual, the bar of the best-measured relayer, raised to whatever its own settled races
measure (own.max(fallback)), and is not judged at all while no relayer has one. “Home through
it” is any reply over a leg it is on that reached it over the same hop as the overdue one would
(see Hop): from the replier when it is first on both legs, from another relayer when it is
not. The same hop, because that is what the overdue reply says something about. A relayer cut off
from the replier goes on delivering behind other relayers, and counting those replies kept it from
ever being a suspect: measured with that link cut, the relayer behind it on those legs was judged
in its place and stayed out for 90 s, or nobody was and the replier spent a quarter of its replies
into the cut for as long as its stock lasted. The relayer’s own races that expired open and were
booked as lost are not replies that came home, and must not reset the clock.
A reply is held to the bar of the slowest relayer on its leg, bars having every relayer’s: it
can be no earlier than that relayer lets it be, whichever of them is asked. Held to its own bar,
a relayer behind a slower one had replies overdue that the slower one did not, and was the only
suspect. Measured on a cluster behind a relayer stalling for seconds: three such replies, the
relayer judged in the stalling one’s place and out for 80 s, the stock wiped twice.
Each overdue race is judged on its own: one that a reply through the relayer came home after is answered, the relayer was delivering after the reply it lost, which was then lost at random. Comparing the latest reply with the oldest overdue race instead lets one stale race, or the replies already past the relayer when it died, hold a verdict back until that race expires, up to a minute.
Returns those replies, by SURB and with when each fell due, empty while the relayer cannot be
judged at all; whether they make it a black hole is up to explain_away, which sets aside the
ones a relayer already judged dead explains.
Sourcefn unanswered_at_all(
&self,
unanswered: &[(HoprSurbId, Instant)],
) -> Vec<HoprSurbId> ⓘ
fn unanswered_at_all( &self, unanswered: &[(HoprSurbId, Instant)], ) -> Vec<HoprSurbId> ⓘ
Of the replies unanswered over the hop they are out on, those that nothing has come home after
through this relayer over either hop: what it is judged on as a whole.
Any reply through it answers them, as before its hops were told apart, and not only one over
the same hop. Counting what is unanswered over each hop and adding the two up judged a
relayer for a reply lost here and two lost there while it delivered over both: simulated as
for Hop, 13 wipes with the two added up against 4 this way, and 2 with the hops not told
apart at all.
Sourcefn hop_at_fault(&self, unanswered: &[(HoprSurbId, Instant)]) -> Option<Hop>
fn hop_at_fault(&self, unanswered: &[(HoprSurbId, Instant)]) -> Option<Hop>
The hop the replies unanswered are out on, if they are all out on the same one and the relayer
has delivered over the other since the oldest of them opened. Its verdict is then about that hop
and not about the relayer as a whole: the replier can no longer reach it, say, while other
relayers still can.
Sourcefn home_over_the_hop_of(&self, surb: &HoprSurbId) -> Option<Instant>
fn home_over_the_hop_of(&self, surb: &HoprSurbId) -> Option<Instant>
When a reply last came home through this relayer over the hop the open race of surb waits on.
Any reply over that hop counts, in the normal order too: it settles no race, but it is the relayer delivering all the same.
Trait Implementations§
Source§impl Debug for RaceHistory
impl Debug for RaceHistory
Source§impl Default for RaceHistory
impl Default for RaceHistory
Source§fn default() -> RaceHistory
fn default() -> RaceHistory
Auto Trait Implementations§
impl Freeze for RaceHistory
impl RefUnwindSafe for RaceHistory
impl Send for RaceHistory
impl Sync for RaceHistory
impl Unpin for RaceHistory
impl UnsafeUnpin for RaceHistory
impl UnwindSafe for RaceHistory
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.