Struct hypercore::Hypercore

source ·
pub struct Hypercore { /* private fields */ }
Expand description

Hypercore is an append-only log structure.

Implementations§

source§

impl Hypercore

source

pub fn info(&self) -> Info

Gets basic info about the Hypercore

source

pub async fn append( &mut self, data: &[u8], ) -> Result<AppendOutcome, HypercoreError>

Appends a data slice to the hypercore.

source

pub async fn append_batch<A: AsRef<[u8]>, B: AsRef<[A]>>( &mut self, batch: B, ) -> Result<AppendOutcome, HypercoreError>

Appends a given batch of data slices to the hypercore.

source

pub async fn get( &mut self, index: u64, ) -> Result<Option<Vec<u8>>, HypercoreError>

Read value at given index, if any.

source

pub async fn clear( &mut self, start: u64, end: u64, ) -> Result<(), HypercoreError>

Clear data for entries between start and end (exclusive) indexes.

source

pub fn key_pair(&self) -> &PartialKeypair

Access the key pair.

source

pub async fn create_proof( &mut self, block: Option<RequestBlock>, hash: Option<RequestBlock>, seek: Option<RequestSeek>, upgrade: Option<RequestUpgrade>, ) -> Result<Option<Proof>, HypercoreError>

Create a proof for given request

source

pub async fn verify_and_apply_proof( &mut self, proof: &Proof, ) -> Result<bool, HypercoreError>

Verify and apply proof received from peer, returns true if changed, false if not possible to apply.

source

pub async fn missing_nodes(&mut self, index: u64) -> Result<u64, HypercoreError>

Used to fill the nodes field of a RequestBlock during synchronization.

source

pub async fn missing_nodes_from_merkle_tree_index( &mut self, merkle_tree_index: u64, ) -> Result<u64, HypercoreError>

Get missing nodes using a merkle tree index. Advanced variant of missing_nodex that allow for special cases of searching directly from the merkle tree.

source

pub async fn make_read_only(&mut self) -> Result<bool, HypercoreError>

Makes the hypercore read-only by deleting the secret key. Returns true if the hypercore was changed, false if the hypercore was already read-only. This is useful in scenarios where a hypercore should be made immutable after initial values have been stored.

Trait Implementations§

source§

impl Debug for Hypercore

source§

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

Formats the value using the given formatter. Read more

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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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