essential_rest_client::builder_client

Struct EssentialBuilderClient

source
pub struct EssentialBuilderClient { /* private fields */ }
Expand description

Client that binds to an Essential builder address.

Implementations§

source§

impl EssentialBuilderClient

source

pub fn new(addr: String) -> Result<Self>

Create a new client with the given address.

source

pub async fn deploy_contract( &self, contract: &Contract, ) -> Result<ContentAddress>

Deploy contract.

Creates a solution to the contract registry predicate and submits it.

source

pub async fn submit_solution( &self, solution: &Solution, ) -> Result<ContentAddress>

Submit solution.

This allows submitting a solution to be included in an upcoming block. Once a solution is submitted it is added to the pool. The block builder runs on a regular loop interval and will include the solution in a block in FIFO order if it satisfies the constraints.

The block builder is likely to become more sophisticated in the future.

Note that currently if you submit a solution that conflicts with another solution then whichever solution is submitted first will be included in the block and the other solution will fail. Failed solutions are not retried and will eventually be pruned.

A solution can conflict with another solution when one solution is built on top of pre-state that the other solution changes. For example if a counter can only increment by 1 and is currently set to 5 then you submit a solution setting it to 6 but another solution is submitted before yours that sets the counter to 6 then your solution will fail to satisfy the constraints. In fact in this example your solution will never satisfy again unless you update the state mutation to the current count + 1. But to do this you have to resubmit your solution.

Submitting the same solution twice (even by different user) is idempotent.

Returns the content address of the submitted solution.

source

pub async fn latest_solution_failures( &self, solution_ca: &ContentAddress, limit: u32, ) -> Result<Vec<SolutionFailure<'static>>>

For solution in the given content address, get the latest solution failures.

The number of failures returned is limited by the limit parameter. The failures are ordered by block number and solution index in descending order.

This allows querying the latest failures of a solution. A solution is either successfully included in a block or it fails with a reason.

One thing to keep in mind is solutions are not necessarily unique. It is possible for the same solution to be submitted multiple times. For example if the counter example also allowed decrementing by 1 then a solution could increment the count from 4 to 5 and another solution could decrement the count from 5 to 4. Then a solution that increments the count from 4 to 5 could be submitted again. These two solutions would have the exact same content address. This results in the same solution hash returning multiple outcomes.

This might make it difficult to know if it was the solution that you submitted that was successful or failed. But actually it doesn’t really matter because there is no real ownership over a solution. Remember if two of the same solution are submitted at the same time then it is as if only one was submitted.

If you are interested in “has my solution worked” then it probably makes more sense to query the state of the contract that you were trying to change.

Trait Implementations§

source§

impl Clone for EssentialBuilderClient

source§

fn clone(&self) -> EssentialBuilderClient

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. 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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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

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