Domain

Struct Domain 

Source
pub struct Domain<S = Storage>
where S: KeyValueStorageWithColumnFamilies<ColumnFamilyIdentifier = ColumnFamilies, Error = StorageError> + Send + Sync + 'static,
{ pub runner: Runner<S>, pub client: DomainClient, pub views: Views<S>, }
Expand description

A delta domain

This struct gives access to all domain operations:

  • the runner to run the domain’s event processing
  • the client to perform actions on the domain
  • the views to read data and state from the domain

The struct is generic over:

  • S: the storage back-end, defaults to the storage back-end defined by the cargo features (see below)

Storage back-ends can be enabled via cargo features:

  • in-memory storage by default
  • RocksDB storage if feature rocksdb is set

Create a new domain with a builder:

Destructuring into the three components is recommended upon creation:

use delta_domain_sdk::{Domain, Config};

async fn example() -> Result<(), Box<dyn std::error::Error>> {
    let config = Config::load()?;
    let Domain {
        runner,
        client,
        views,
    } = Domain::from_config(config).build().await?;
    Ok(())
}

Fields§

§runner: Runner<S>

Runner to start the domain.

The runner must be used once to launch the domain’s event loop with Runner::run. It’s not cloneable.

§client: DomainClient

Client to performing actions on a running domain.

§views: Views<S>

Read-only views of the domain’s state and data.

Implementations§

Source§

impl Domain<Storage>

Source

pub fn from_config(config: Config) -> DomainBuilder<DbOptions>

Construct a new domain from configuration.

See Config for how to load configuration.

By default, a mock RPC is configured. Use DomainBuilder::with_rpc or set a rpc_url in the configuration file to use a real base layer RPC.

By default, a mock proving client is used. To configure a proving client use with_proving_client or set proving in the configuration file.

§Returns

A DomainBuilder to continue configuration or build the domain.

Source

pub fn builder( shard: NonZero<Shard>, keypair: PrivKey, ) -> DomainBuilder<DbOptions>

Construct a new domain with the builder.

The storage layer used is defined by the cargo feature rocksdb (RocksDB if set, in-memory if not).

§Parameters
  • shard - the shard this domain operates
  • keypair - the domain signs transactions with
§Returns

A DomainBuilder to continue configuration or build the domain.

Source

pub fn in_mem_builder( shard: NonZero<Shard>, keypair: PrivKey, ) -> DomainBuilder<Database<Storage>>

Same as Self::builder but with storage forced to in-memory.

Trait Implementations§

Source§

impl<S> Debug for Domain<S>
where S: KeyValueStorageWithColumnFamilies<ColumnFamilyIdentifier = ColumnFamilies, Error = StorageError> + Send + Sync + 'static + Debug,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S = RocksDb<DbSpec>> !Freeze for Domain<S>

§

impl<S = RocksDb<DbSpec>> !RefUnwindSafe for Domain<S>

§

impl<S> Send for Domain<S>

§

impl<S> Sync for Domain<S>

§

impl<S> Unpin for Domain<S>

§

impl<S = RocksDb<DbSpec>> !UnwindSafe for Domain<S>

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.

§

impl<T> Instrument for T

§

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

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

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

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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