pub struct BandwidthController<St> { /* private fields */ }Implementations§
Source§impl<St: Storage> BandwidthController<St>
impl<St: Storage> BandwidthController<St>
pub fn new(storage: St) -> Self
pub fn with_credential_public_data_fetcher( self, fetcher: impl CredentialPublicDataFetcher + 'static, ) -> Self
Sourcepub fn get_request_sender(&self) -> BandwidthControllerRequestSender
pub fn get_request_sender(&self) -> BandwidthControllerRequestSender
Get the request channel used to send request to the controller.
Request are handled only if the BandwidthController is running using run
Sourcepub async fn get_next_usable_ticketbook(
&self,
ticketbook_type: TicketType,
tickets: u32,
) -> Result<Option<RetrievedTicketbook>, BandwidthControllerError>
pub async fn get_next_usable_ticketbook( &self, ticketbook_type: TicketType, tickets: u32, ) -> Result<Option<RetrievedTicketbook>, BandwidthControllerError>
Tries to retrieve one of the stored, unused credentials for the given type that hasn’t yet expired.
pub async fn attempt_revert_ticket_usage( &self, info: PreparedCredentialMetadata, ) -> Result<bool, BandwidthControllerError>
pub async fn get_aggregate_verification_key( &self, epoch_id: EpochId, ) -> Result<Option<VerificationKeyAuth>, BandwidthControllerError>
pub async fn get_coin_index_signatures( &self, epoch_id: EpochId, ) -> Result<Option<Vec<AnnotatedCoinIndexSignature>>, BandwidthControllerError>
pub async fn get_expiration_date_signatures( &self, epoch_id: EpochId, expiration_date: Date, ) -> Result<Option<Vec<AnnotatedExpirationDateSignature>>, BandwidthControllerError>
Sourcepub async fn ensure_global_data(
&self,
epoch_id: EpochId,
expiration_date: Date,
) -> Result<(), BandwidthControllerError>
pub async fn ensure_global_data( &self, epoch_id: EpochId, expiration_date: Date, ) -> Result<(), BandwidthControllerError>
Ensures all global ecash signing materials for the given epoch and expiration date are present in local storage, fetching and persisting any that are missing.
pub async fn prepare_ecash_ticket( &self, ticketbook_type: TicketType, provider_pk: [u8; 32], tickets_to_spend: u32, spend_time: OffsetDateTime, ) -> Result<Option<PreparedCredential>, BandwidthControllerError>
Sourcepub async fn run(self, shutdown_token: ShutdownToken)
pub async fn run(self, shutdown_token: ShutdownToken)
Runs the controller event loop, handling incoming requests until the request channel is closed or cancellation is requested.
Trait Implementations§
Source§impl<St: Storage> BandwidthTicketProvider for BandwidthController<St>
impl<St: Storage> BandwidthTicketProvider for BandwidthController<St>
fn get_ecash_ticket<'life0, 'async_trait>(
&'life0 self,
ticket_type: TicketType,
gateway_id: PublicKey,
tickets_to_spend: u32,
spend_time: OffsetDateTime,
) -> Pin<Box<dyn Future<Output = Result<Option<PreparedCredential>, BandwidthControllerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_upgrade_mode_token<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, BandwidthControllerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn attempt_revert_spending<'life0, 'async_trait>(
&'life0 self,
metadata: PreparedCredentialMetadata,
) -> Pin<Box<dyn Future<Output = Result<bool, BandwidthControllerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn close<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl<St> !RefUnwindSafe for BandwidthController<St>
impl<St> !UnwindSafe for BandwidthController<St>
impl<St> Freeze for BandwidthController<St>where
St: Freeze,
impl<St> Send for BandwidthController<St>where
St: Send,
impl<St> Sync for BandwidthController<St>where
St: Sync,
impl<St> Unpin for BandwidthController<St>where
St: Unpin,
impl<St> UnsafeUnpin for BandwidthController<St>where
St: UnsafeUnpin,
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Declassify for T
impl<T> Declassify for T
type Declassified = T
fn declassify(self) -> T
Source§impl<T> Deprecatable for T
impl<T> Deprecatable for T
fn deprecate(self) -> Deprecated<Self>where
Self: Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
Converts
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>
Converts
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 moreSource§impl<T> OptionalSet for T
impl<T> OptionalSet for T
Source§fn with_optional<F, T>(self, f: F, val: Option<T>) -> Self
fn with_optional<F, T>(self, f: F, val: Option<T>) -> Self
If the value is available (i.e.
Some), the provided closure is applied.
Otherwise self is returned with no modifications.Source§fn with_validated_optional<F, T, V, E>(
self,
f: F,
value: Option<T>,
validate: V,
) -> Result<Self, E>
fn with_validated_optional<F, T, V, E>( self, f: F, value: Option<T>, validate: V, ) -> Result<Self, E>
If the value is available (i.e.
Some) it is validated and then the provided closure is applied.
Otherwise self is returned with no modifications.Source§fn with_optional_env<F, T>(self, f: F, val: Option<T>, env_var: &str) -> Self
fn with_optional_env<F, T>(self, f: F, val: Option<T>, env_var: &str) -> Self
If the value is available (i.e.
Some), the provided closure is applied.
Otherwise, if the environment was configured and the corresponding variable was set,
the value is parsed using the FromStr implementation and the closure is applied on that instead.
Finally, if none of those were available, self is returned with no modifications.Source§fn with_optional_custom_env<F, T, G>(
self,
f: F,
val: Option<T>,
env_var: &str,
parser: G,
) -> Self
fn with_optional_custom_env<F, T, G>( self, f: F, val: Option<T>, env_var: &str, parser: G, ) -> Self
If the value is available (i.e.
Some), the provided closure is applied.
Otherwise, if the environment was configured and the corresponding variable was set,
the value is parsed using the provided parser and the closure is applied on that instead.
Finally, if none of those were available, self is returned with no modifications.