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
impl SimplexClient
pub fn new(store_url: &str) -> Self
pub fn from_client(client: StoreClient) -> Self
pub fn store_client(&self) -> &StoreClient
pub fn into_store_client(self) -> StoreClient
pub fn prepare_header<B>(&self, header: &B) -> PreparedUploadwhere
B: Block,
pub fn prepare_block<B>(
&self,
header: &B,
body: impl Into<Bytes>,
) -> PreparedUploadwhere
B: Block,
pub fn prepare_block_data<B>(&self, data: &BlockData<B>) -> PreparedUploadwhere
B: Block,
pub fn prepare_notarized<B, S, D>( &self, notarized: &Notarized<B, S, D>, ) -> Result<PreparedUpload, SimplexError>
pub fn prepare_finalized<B, S, D>( &self, finalized: &Finalized<B, S, D>, ) -> Result<PreparedUpload, SimplexError>
pub fn stage_upload( &self, prepared: &PreparedUpload, batch: &mut StoreWriteBatch, ) -> Result<(), SimplexError>
pub async fn mark_upload_persisted( &self, prepared: PreparedUpload, sequence_number: u64, ) -> UploadReceipt
pub async fn mark_upload_failed( &self, _prepared: PreparedUpload, _err: impl ToString, )
pub async fn upload_header<B>(
&self,
header: &B,
) -> Result<UploadReceipt, SimplexError>where
B: Block,
pub async fn upload_block<B>(
&self,
header: &B,
body: impl Into<Bytes>,
) -> Result<UploadReceipt, SimplexError>where
B: Block,
pub async fn upload_notarized<B, S, D>( &self, notarized: &Notarized<B, S, D>, ) -> Result<UploadReceipt, SimplexError>
pub async fn upload_finalized<B, S, D>( &self, finalized: &Finalized<B, S, D>, ) -> Result<UploadReceipt, SimplexError>
pub async fn get_header_raw<D: Digest>( &self, digest: &D, ) -> Result<Option<Bytes>, SimplexError>
pub async fn get_block_raw<D: Digest>( &self, digest: &D, ) -> Result<Option<Bytes>, SimplexError>
pub async fn get_notarized_raw( &self, view: View, ) -> Result<Option<Bytes>, SimplexError>
pub async fn get_finalized_by_view_raw( &self, view: View, ) -> Result<Option<Bytes>, SimplexError>
pub async fn get_finalized_by_height_raw( &self, height: Height, ) -> Result<Option<Bytes>, SimplexError>
pub async fn latest_finalized_raw(&self) -> Result<Option<Bytes>, SimplexError>
pub async fn get_header<B, D>( &self, digest: &D, cfg: &<B as Read>::Cfg, ) -> Result<Option<B>, SimplexError>
pub async fn get_block<B, D>( &self, digest: &D, cfg: &<BlockData<B> as Read>::Cfg, ) -> Result<Option<BlockData<B>>, SimplexError>
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>
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>
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>
pub async fn latest_finalized<B, S, D>( &self, cfg: &<Finalized<B, S, D> as Read>::Cfg, ) -> Result<Option<Finalized<B, S, D>>, SimplexError>
Trait Implementations§
Source§impl Clone for SimplexClient
impl Clone for SimplexClient
Source§fn clone(&self) -> SimplexClient
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)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SimplexClient
impl Debug for SimplexClient
Source§impl StoreBatchUpload for SimplexClient
impl StoreBatchUpload for SimplexClient
type Prepared = PreparedUpload
type Receipt = UploadReceipt
type Error = SimplexError
fn stage_upload( &self, prepared: &Self::Prepared, batch: &mut StoreWriteBatch, ) -> Result<(), Self::Error>
fn commit_error(&self, error: ClientError) -> Self::Error
fn mark_upload_persisted<'a>( &'a self, prepared: Self::Prepared, sequence_number: u64, ) -> BoxFuture<'a, Self::Receipt>
fn mark_upload_failed<'a>( &'a self, prepared: Self::Prepared, error: String, ) -> BoxFuture<'a, ()>
fn commit_upload<'a>( &'a self, client: &'a StoreClient, prepared: Self::Prepared, ) -> Pin<Box<dyn Future<Output = Result<Self::Receipt, Self::Error>> + Send + 'a>>
Auto Trait Implementations§
impl !Freeze for SimplexClient
impl !RefUnwindSafe for SimplexClient
impl Send for SimplexClient
impl Sync for SimplexClient
impl Unpin for SimplexClient
impl UnsafeUnpin for SimplexClient
impl !UnwindSafe for SimplexClient
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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 more