Skip to main content

SimplexClient

Struct SimplexClient 

Source
pub struct SimplexClient { /* private fields */ }
Expand description

Store-backed writer for Commonware Simplex blocks and certificates.

The writer stores five logical indexes:

  • header bytes by header digest
  • full { header, body } bytes by header digest
  • notarized { proof, header } bytes by Simplex view
  • finalized { proof, header } bytes by Simplex view
  • finalized { proof, header } bytes by header height

Implementations§

Source§

impl SimplexClient

Source

pub fn new(store_url: &str) -> Self

Source

pub fn from_client(client: StoreClient) -> Self

Source

pub fn store_client(&self) -> &StoreClient

Source

pub fn into_store_client(self) -> StoreClient

Source

pub fn prepare_header<B>(&self, header: &B) -> PreparedUpload
where B: Block,

Source

pub fn prepare_block<B>( &self, header: &B, body: impl Into<Bytes>, ) -> PreparedUpload
where B: Block,

Source

pub fn prepare_block_data<B>(&self, data: &BlockData<B>) -> PreparedUpload
where B: Block,

Source

pub fn prepare_notarized<B, S, D>( &self, notarized: &Notarized<B, S, D>, ) -> Result<PreparedUpload, SimplexError>
where B: Block<Digest = D>, S: Scheme, D: Digest,

Source

pub fn prepare_finalized<B, S, D>( &self, finalized: &Finalized<B, S, D>, ) -> Result<PreparedUpload, SimplexError>
where B: Block<Digest = D>, S: Scheme, D: Digest,

Source

pub fn stage_upload( &self, prepared: &PreparedUpload, batch: &mut StoreWriteBatch, ) -> Result<(), SimplexError>

Source

pub async fn mark_upload_persisted( &self, prepared: PreparedUpload, sequence_number: u64, ) -> UploadReceipt

Source

pub async fn mark_upload_failed( &self, _prepared: PreparedUpload, _err: impl ToString, )

Source

pub async fn upload_header<B>( &self, header: &B, ) -> Result<UploadReceipt, SimplexError>
where B: Block,

Source

pub async fn upload_block<B>( &self, header: &B, body: impl Into<Bytes>, ) -> Result<UploadReceipt, SimplexError>
where B: Block,

Source

pub async fn upload_notarized<B, S, D>( &self, notarized: &Notarized<B, S, D>, ) -> Result<UploadReceipt, SimplexError>
where B: Block<Digest = D>, S: Scheme, D: Digest,

Source

pub async fn upload_finalized<B, S, D>( &self, finalized: &Finalized<B, S, D>, ) -> Result<UploadReceipt, SimplexError>
where B: Block<Digest = D>, S: Scheme, D: Digest,

Source

pub async fn get_header_raw<D: Digest>( &self, digest: &D, ) -> Result<Option<Bytes>, SimplexError>

Source

pub async fn get_block_raw<D: Digest>( &self, digest: &D, ) -> Result<Option<Bytes>, SimplexError>

Source

pub async fn get_notarized_raw( &self, view: View, ) -> Result<Option<Bytes>, SimplexError>

Source

pub async fn get_finalized_by_view_raw( &self, view: View, ) -> Result<Option<Bytes>, SimplexError>

Source

pub async fn get_finalized_by_height_raw( &self, height: Height, ) -> Result<Option<Bytes>, SimplexError>

Source

pub async fn latest_finalized_raw(&self) -> Result<Option<Bytes>, SimplexError>

Source

pub async fn get_header<B, D>( &self, digest: &D, cfg: &<B as Read>::Cfg, ) -> Result<Option<B>, SimplexError>
where B: Block<Digest = D>, D: Digest,

Source

pub async fn get_block<B, D>( &self, digest: &D, cfg: &<BlockData<B> as Read>::Cfg, ) -> Result<Option<BlockData<B>>, SimplexError>
where B: Block<Digest = D>, D: Digest,

Source

pub async fn get_notarized<B, S, D>( &self, view: View, cfg: &<Notarized<B, S, D> as Read>::Cfg, ) -> Result<Option<Notarized<B, S, D>>, SimplexError>
where B: Block<Digest = D>, S: Scheme, D: Digest, <S::Certificate as Read>::Cfg: Clone,

Source

pub async fn get_finalized_by_height<B, S, D>( &self, height: Height, cfg: &<Finalized<B, S, D> as Read>::Cfg, ) -> Result<Option<Finalized<B, S, D>>, SimplexError>
where B: Block<Digest = D>, S: Scheme, D: Digest, <S::Certificate as Read>::Cfg: Clone,

Source

pub async fn get_finalized_by_view<B, S, D>( &self, view: View, cfg: &<Finalized<B, S, D> as Read>::Cfg, ) -> Result<Option<Finalized<B, S, D>>, SimplexError>
where B: Block<Digest = D>, S: Scheme, D: Digest, <S::Certificate as Read>::Cfg: Clone,

Source

pub async fn latest_finalized<B, S, D>( &self, cfg: &<Finalized<B, S, D> as Read>::Cfg, ) -> Result<Option<Finalized<B, S, D>>, SimplexError>
where B: Block<Digest = D>, S: Scheme, D: Digest, <S::Certificate as Read>::Cfg: Clone,

Trait Implementations§

Source§

impl Clone for SimplexClient

Source§

fn clone(&self) -> SimplexClient

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SimplexClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl StoreBatchUpload for SimplexClient

Source§

type Prepared = PreparedUpload

Source§

type Receipt = UploadReceipt

Source§

type Error = SimplexError

Source§

fn stage_upload( &self, prepared: &Self::Prepared, batch: &mut StoreWriteBatch, ) -> Result<(), Self::Error>

Source§

fn commit_error(&self, error: ClientError) -> Self::Error

Source§

fn mark_upload_persisted<'a>( &'a self, prepared: Self::Prepared, sequence_number: u64, ) -> BoxFuture<'a, Self::Receipt>
where Self: Sync + 'a, Self::Prepared: 'a,

Source§

fn mark_upload_failed<'a>( &'a self, prepared: Self::Prepared, error: String, ) -> BoxFuture<'a, ()>
where Self: Sync + 'a, Self::Prepared: 'a,

Source§

fn commit_upload<'a>( &'a self, client: &'a StoreClient, prepared: Self::Prepared, ) -> Pin<Box<dyn Future<Output = Result<Self::Receipt, Self::Error>> + Send + 'a>>
where Self: Sized + Sync + 'a, Self::Prepared: 'a, Self::Receipt: 'a, Self::Error: 'a,

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more