struct SessionSsaState {
params: PixParams,
committed_ssa_watermark: AtomicU32,
returned_at_first_commit: AtomicU64,
sent_deposit_data: Arc<Mutex<HashMap<SsaIndex, HoprPixDepositPayload>>>,
}Expand description
The PIX dimensions this Session negotiated, on the Exit side.
Once carried the SSA index and a fault counter as well. Both moved to the supervisor: it decides when a cycle is requested, so it is also what allocates the index, and it is what enforces the fault limit. Leaving a second copy of either here would have meant two authorities for one fact.
Fields§
§params: PixParamsThe dimensions this Session negotiated, as they went on the wire.
committed_ssa_watermark: AtomicU32Highest SSA index this Session has had the generator commit to, 0 before the first batch.
A deliberate second copy of a fact the generator already holds, and the only one of the three
that came back. The generator’s own watermark lives in a cache with an idle retention, so
“absent” there conflates never committed with state discarded — and those must not be
treated alike, because the first is the opening batch every Session begins with and the second
is a Session whose Entry can no longer serve the cycles it already committed to. This copy
lives exactly as long as the Session does, so it can tell them apart. See the successor gate in
SessionManager::handle_ssa_request.
Entry-side only; an Exit never commits and leaves it at zero. SsaIndex is a NonZero<u32>,
which is what makes 0 an unambiguous “none” rather than a sentinel that has to be defended.
returned_at_first_commit: AtomicU64SessionSlot::returned_packets as it stood when this Session first committed.
The successor gate counts service since that instant, not since the Session opened. Before
the first commitment the generator holds no polynomials, so the SURBs going out carry no
shares — and an Exit may legitimately be served up to max_predeposit_packets of them before
any deposit exists. Crediting that prefix would let the Exit bank unpaid service against the
first cycle it is paid for. Everything after this point rides a share.
sent_deposit_data: Arc<Mutex<HashMap<SsaIndex, HoprPixDepositPayload>>>What this Exit sent as deposit data, per SSA index, for cycles whose deposit address it has not learned yet.
Implementations§
Source§impl SessionSsaState
impl SessionSsaState
pub fn new(params: PixParams) -> Self
Sourcepub fn remember_sent_deposit_data(
&self,
deposit_data: &HashMap<SsaIndex, HoprPixDepositPayload>,
)
pub fn remember_sent_deposit_data( &self, deposit_data: &HashMap<SsaIndex, HoprPixDepositPayload>, )
Files the deposit data of a batch the Exit is about to send, for
take_sent_deposit_data to hand back once the matching
deposit address is known.
Sourcepub fn take_sent_deposit_data(
&self,
session_id: &SessionId,
ssa_index: SsaIndex,
) -> PixDepositData
pub fn take_sent_deposit_data( &self, session_id: &SessionId, ssa_index: SsaIndex, ) -> PixDepositData
Removes and returns what this Exit sent for ssa_index, or empty data if it sent none.
Sourcepub fn committed_watermark(&self) -> Option<SsaIndex>
pub fn committed_watermark(&self) -> Option<SsaIndex>
Highest SSA index committed for this Session, None before the first batch.
Sourcepub fn note_committed(&self, index: SsaIndex, returned_packets: u64)
pub fn note_committed(&self, index: SsaIndex, returned_packets: u64)
Raises the committed-index watermark to index if it is higher, taking the returned-packet
baseline on the first commitment.
fetch_max rather than a store: the gate serialises requests per pseudonym, but a Session’s
slot is shared and monotonicity here must not depend on that lock staying where it is. Its
previous value is also what makes the baseline race-free without leaning on that lock —
exactly one caller can observe a prior watermark of zero, so exactly one stores.
Sourcepub fn served_since_first_commit(&self, returned_packets: u64) -> u64
pub fn served_since_first_commit(&self, returned_packets: u64) -> u64
Exit → Entry packets received since this Session’s first commitment.
Saturating rather than wrapping: returned_packets is monotonic and the baseline is a past
value of it, so an underflow is impossible — and if one ever became possible, reporting zero
service closes the successor gate rather than opening it.
Sourcepub const fn quota_per_ssa(&self) -> u64
pub const fn quota_per_ssa(&self) -> u64
Data quota one SSA cycle of these dimensions covers.
The whole cycle, surplus included, as per pix_params_to_quota: every share a cycle emits
rides one Exit → Entry packet, so all of them are priced.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for SessionSsaState
impl !RefUnwindSafe for SessionSsaState
impl !UnwindSafe for SessionSsaState
impl Send for SessionSsaState
impl Sync for SessionSsaState
impl Unpin for SessionSsaState
impl UnsafeUnpin for SessionSsaState
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.