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
rocksdbis set
Create a new domain with a builder:
- by reading from configuration with Self::from_config, or
- manually by calling Self::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: DomainClientClient 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>
impl Domain<Storage>
Sourcepub fn from_config(config: Config) -> DomainBuilder<DbOptions>
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.
Sourcepub fn builder(
shard: NonZero<Shard>,
keypair: PrivKey,
) -> DomainBuilder<DbOptions>
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 operateskeypair- the domain signs transactions with
§Returns
A DomainBuilder to continue configuration or build the domain.
Sourcepub fn in_mem_builder(
shard: NonZero<Shard>,
keypair: PrivKey,
) -> DomainBuilder<Database<Storage>>
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§
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> 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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request