casper_storage/data_access_layer/
contract.rs

1use crate::tracking_copy::TrackingCopyError;
2use casper_types::{Contract, Digest, Key};
3
4/// Represents a request to obtain contract.
5pub struct ContractRequest {
6    state_hash: Digest,
7    key: Key,
8}
9
10impl ContractRequest {
11    /// ctor
12    pub fn new(state_hash: Digest, key: Key) -> Self {
13        ContractRequest { state_hash, key }
14    }
15
16    /// Returns key.
17    pub fn key(&self) -> Key {
18        self.key
19    }
20    /// Returns state root hash.
21    pub fn state_hash(&self) -> Digest {
22        self.state_hash
23    }
24}
25
26/// Represents a result of a `contract` request.
27#[derive(Debug)]
28pub enum ContractResult {
29    /// Invalid state root hash.
30    RootNotFound,
31    /// Value not found.
32    ValueNotFound(String),
33    /// This variant will be returned if the contract was found.
34    Success {
35        /// A contract.
36        contract: Contract,
37    },
38    /// Failure result.
39    Failure(TrackingCopyError),
40}