[][src]Struct exonum_merkledb::SystemSchema

pub struct SystemSchema<T>(_);

System-wide information about the database.

Examples

let db = TemporaryDB::new();
let fork = db.fork();
fork.get_proof_list("list").extend(vec![1_u32, 2, 3]);
fork.get_map(("plain_map", &1)).put(&1_u8, "so plain".to_owned());
fork.get_map(("plain_map", &2)).put(&2_u8, "s0 plane".to_owned());

let patch = fork.into_patch();
let state_hash = SystemSchema::new(&patch).state_hash();
// ^-- State hash of the entire database including changes in the `patch`.
db.merge(patch).unwrap();

let snapshot = db.snapshot();
let aggregator = SystemSchema::new(&snapshot).state_aggregator();
assert_eq!(aggregator.object_hash(), state_hash);
assert_eq!(aggregator.keys().collect::<Vec<_>>(), vec!["list".to_owned()]);
// ^-- No other aggregated indexes so far.
let index_hash = aggregator.get(&"list".to_owned()).unwrap();
assert_eq!(
    index_hash,
    snapshot.get_proof_list::<_, u32>("list").object_hash()
);

// It is possible to prove that an index has a specific state
// given `state_hash`:
let proof = aggregator.get_proof("list".to_owned());
proof.check_against_hash(state_hash).unwrap();

Methods

impl<T: RawAccess> SystemSchema<T>[src]

pub fn new(access: T) -> Self[src]

Creates an instance based on the specified access.

pub fn state_hash(&self) -> Hash[src]

Returns the state hash of the database. The state hash is up to date for Snapshots (including Patches), but is generally stale for Forks.

See state aggregation for details how the database state is aggregated.

impl<T: RawAccess + AsReadonly> SystemSchema<T>[src]

pub fn state_aggregator(&self) -> ProofMapIndex<T::Readonly, str, Hash>[src]

Returns the state aggregator of the database. The aggregator is up to date for Snapshots (including Patches), but is generally stale for Forks.

See state aggregation for details how the database state is aggregated.

Trait Implementations

impl<T: Clone> Clone for SystemSchema<T>[src]

impl<T: Copy> Copy for SystemSchema<T>[src]

impl<T: Debug> Debug for SystemSchema<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for SystemSchema<T> where
    T: RefUnwindSafe

impl<T> Send for SystemSchema<T> where
    T: Send

impl<T> Sync for SystemSchema<T> where
    T: Sync

impl<T> Unpin for SystemSchema<T> where
    T: Unpin

impl<T> UnwindSafe for SystemSchema<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

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