Struct narwhal_storage::CertificateStore
source · [−]pub struct CertificateStore { /* private fields */ }
Expand description
The main storage when we have to deal with certificates. It maintains
two storages, one main which saves the certificates by their ids, and a
secondary one which acts as an index to allow us fast retrieval based
for queries based in certificate rounds.
It also offers pub/sub capabilities in write events. By using the
notify_read
someone can wait to hear until a certificate by a specific
id has been written in storage.
Implementations
sourceimpl CertificateStore
impl CertificateStore
pub fn new(
certificates_by_id: DBMap<CertificateDigest, Certificate>,
certificate_ids_by_round: DBMap<(Round, CertificateDigest), CertificateToken>
) -> CertificateStore
sourcepub fn write(&self, certificate: Certificate) -> StoreResult<()>
pub fn write(&self, certificate: Certificate) -> StoreResult<()>
Inserts a certificate to the store
sourcepub fn write_all(
&self,
certificates: impl IntoIterator<Item = Certificate>
) -> StoreResult<()>
pub fn write_all(
&self,
certificates: impl IntoIterator<Item = Certificate>
) -> StoreResult<()>
Inserts multiple certificates in the storage. This is an atomic operation. In the end it notifies any subscribers that are waiting to hear for the value.
sourcepub fn read(&self, id: CertificateDigest) -> StoreResult<Option<Certificate>>
pub fn read(&self, id: CertificateDigest) -> StoreResult<Option<Certificate>>
Retrieves a certificate from the store. If not found then None is returned as result.
sourcepub fn read_all(
&self,
ids: impl IntoIterator<Item = CertificateDigest>
) -> StoreResult<Vec<Option<Certificate>>>
pub fn read_all(
&self,
ids: impl IntoIterator<Item = CertificateDigest>
) -> StoreResult<Vec<Option<Certificate>>>
Retrieves multiple certificates by their provided ids. The results are returned in the same sequence as the provided keys.
sourcepub async fn notify_read(
&self,
id: CertificateDigest
) -> StoreResult<Certificate>
pub async fn notify_read(
&self,
id: CertificateDigest
) -> StoreResult<Certificate>
Waits to get notified until the requested certificate becomes available
sourcepub fn delete(&self, id: CertificateDigest) -> StoreResult<()>
pub fn delete(&self, id: CertificateDigest) -> StoreResult<()>
Deletes a single certificate by its digest.
sourcepub fn delete_all(
&self,
ids: impl IntoIterator<Item = CertificateDigest>
) -> StoreResult<()>
pub fn delete_all(
&self,
ids: impl IntoIterator<Item = CertificateDigest>
) -> StoreResult<()>
Deletes multiple certificates in an atomic way.
sourcepub fn after_round(&self, round: Round) -> StoreResult<Vec<Certificate>>
pub fn after_round(&self, round: Round) -> StoreResult<Vec<Certificate>>
Retrieves all the certificates with round >= the provided round. The result is returned with certificates sorted in round asc order
sourcepub fn last_round(&self) -> StoreResult<Vec<Certificate>>
pub fn last_round(&self) -> StoreResult<Vec<Certificate>>
Retrieves the certificates of the last round
sourcepub fn last_round_number(&self) -> Option<Round>
pub fn last_round_number(&self) -> Option<Round>
Retrieves the latest round number of certificates in store. Returns None if there is no certificate.
sourcepub fn clear(&self) -> StoreResult<()>
pub fn clear(&self) -> StoreResult<()>
Clears both the main storage of the certificates and the secondary index
Trait Implementations
sourceimpl Clone for CertificateStore
impl Clone for CertificateStore
sourcefn clone(&self) -> CertificateStore
fn clone(&self) -> CertificateStore
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations
impl !RefUnwindSafe for CertificateStore
impl Send for CertificateStore
impl Sync for CertificateStore
impl Unpin for CertificateStore
impl !UnwindSafe for CertificateStore
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
sourcefn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a Request
impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
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 morefn 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 morefn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
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) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> Rwhere
Self: Deref<Target = T>,
T: 'a + ?Sized,
R: 'a,
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> Rwhere
Self: Deref<Target = T>,
T: 'a + ?Sized,
R: 'a,
self
, then passes self.deref()
into the pipe function.impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Tap for T
impl<T> Tap for T
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
Borrow<B>
of a value. Read morefn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
BorrowMut<B>
of a value. Read morefn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
AsRef<R>
view of a value. Read morefn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
AsMut<R>
view of a value. Read morefn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
Deref::Target
of a value. Read morefn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
Deref::Target
of a value. Read morefn 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. Read morefn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
.tap_borrow()
only in debug builds, and is erased in release
builds. Read morefn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
.tap_borrow_mut()
only in debug builds, and is erased in release
builds. Read morefn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
.tap_ref()
only in debug builds, and is erased in release
builds. Read morefn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
.tap_ref_mut()
only in debug builds, and is erased in release
builds. Read more