pub trait FinalizeStorage<N: Network>: 'static + Clone + Send + Sync {
    type ProgramIDMap: for<'a> Map<'a, ProgramID<N>, IndexSet<Identifier<N>>>;
    type MappingIDMap: for<'a> Map<'a, (ProgramID<N>, Identifier<N>), Field<N>>;
    type KeyValueIDMap: for<'a> Map<'a, Field<N>, IndexMap<Field<N>, Field<N>>>;
    type KeyMap: for<'a> Map<'a, Field<N>, Plaintext<N>>;
    type ValueMap: for<'a> Map<'a, Field<N>, Value<N>>;

Show 35 methods // Required methods fn open(dev: Option<u16>) -> Result<Self>; fn program_id_map(&self) -> &Self::ProgramIDMap; fn mapping_id_map(&self) -> &Self::MappingIDMap; fn key_value_id_map(&self) -> &Self::KeyValueIDMap; fn key_map(&self) -> &Self::KeyMap; fn value_map(&self) -> &Self::ValueMap; fn dev(&self) -> Option<u16>; // Provided methods fn start_atomic(&self) { ... } fn is_atomic_in_progress(&self) -> bool { ... } fn atomic_checkpoint(&self) { ... } fn clear_latest_checkpoint(&self) { ... } fn atomic_rewind(&self) { ... } fn abort_atomic(&self) { ... } fn finish_atomic(&self) -> Result<()> { ... } fn initialize_mapping( &self, program_id: &ProgramID<N>, mapping_name: &Identifier<N> ) -> Result<FinalizeOperation<N>> { ... } fn insert_key_value( &self, program_id: &ProgramID<N>, mapping_name: &Identifier<N>, key: Plaintext<N>, value: Value<N> ) -> Result<FinalizeOperation<N>> { ... } fn update_key_value( &self, program_id: &ProgramID<N>, mapping_name: &Identifier<N>, key: Plaintext<N>, value: Value<N> ) -> Result<FinalizeOperation<N>> { ... } fn remove_key_value( &self, program_id: &ProgramID<N>, mapping_name: &Identifier<N>, key: &Plaintext<N> ) -> Result<FinalizeOperation<N>> { ... } fn remove_mapping( &self, program_id: &ProgramID<N>, mapping_name: &Identifier<N> ) -> Result<FinalizeOperation<N>> { ... } fn remove_program(&self, program_id: &ProgramID<N>) -> Result<()> { ... } fn contains_program_confirmed( &self, program_id: &ProgramID<N> ) -> Result<bool> { ... } fn contains_mapping_confirmed( &self, program_id: &ProgramID<N>, mapping_name: &Identifier<N> ) -> Result<bool> { ... } fn contains_key_confirmed( &self, program_id: &ProgramID<N>, mapping_name: &Identifier<N>, key: &Plaintext<N> ) -> Result<bool> { ... } fn contains_key_speculative( &self, program_id: &ProgramID<N>, mapping_name: &Identifier<N>, key: &Plaintext<N> ) -> Result<bool> { ... } fn get_mapping_names_confirmed( &self, program_id: &ProgramID<N> ) -> Result<Option<IndexSet<Identifier<N>>>> { ... } fn get_mapping_names_speculative( &self, program_id: &ProgramID<N> ) -> Result<Option<IndexSet<Identifier<N>>>> { ... } fn get_mapping_id_confirmed( &self, program_id: &ProgramID<N>, mapping_name: &Identifier<N> ) -> Result<Option<Field<N>>> { ... } fn get_mapping_id_speculative( &self, program_id: &ProgramID<N>, mapping_name: &Identifier<N> ) -> Result<Option<Field<N>>> { ... } fn get_key_id_confirmed( &self, program_id: &ProgramID<N>, mapping_name: &Identifier<N>, key: &Plaintext<N> ) -> Result<Option<Field<N>>> { ... } fn get_key_id_speculative( &self, program_id: &ProgramID<N>, mapping_name: &Identifier<N>, key: &Plaintext<N> ) -> Result<Option<Field<N>>> { ... } fn get_key_speculative( &self, key_id: &Field<N> ) -> Result<Option<Plaintext<N>>> { ... } fn get_value_confirmed( &self, program_id: &ProgramID<N>, mapping_name: &Identifier<N>, key: &Plaintext<N> ) -> Result<Option<Value<N>>> { ... } fn get_value_speculative( &self, program_id: &ProgramID<N>, mapping_name: &Identifier<N>, key: &Plaintext<N> ) -> Result<Option<Value<N>>> { ... } fn get_value_from_key_id_confirmed( &self, key_id: &Field<N> ) -> Result<Option<Value<N>>> { ... } fn get_value_from_key_id_speculative( &self, key_id: &Field<N> ) -> Result<Option<Value<N>>> { ... }
}
Expand description

A trait for program state storage. Note: For the program logic, see DeploymentStorage.

We define the mapping ID := Hash( program ID || mapping name ), and the key ID := Hash ( mapping ID || Hash(key) ), and the value ID := Hash ( key ID || Hash(value) ).

FinalizeStorage emulates the following data structure:

// (program_id => (mapping_name => (key => value)))
BTreeMap<ProgramID<N>, BTreeMap<Identifier<N>, BTreeMap<Key, Value>>>

Required Associated Types§

source

type ProgramIDMap: for<'a> Map<'a, ProgramID<N>, IndexSet<Identifier<N>>>

The mapping of program ID to [mapping name].

source

type MappingIDMap: for<'a> Map<'a, (ProgramID<N>, Identifier<N>), Field<N>>

The mapping of (program ID, mapping name) to mapping ID.

source

type KeyValueIDMap: for<'a> Map<'a, Field<N>, IndexMap<Field<N>, Field<N>>>

The mapping of mapping ID to [(key ID, value ID)].

source

type KeyMap: for<'a> Map<'a, Field<N>, Plaintext<N>>

The mapping of key ID to key.

source

type ValueMap: for<'a> Map<'a, Field<N>, Value<N>>

The mapping of key ID to value.

Required Methods§

source

fn open(dev: Option<u16>) -> Result<Self>

Initializes the program state storage.

source

fn program_id_map(&self) -> &Self::ProgramIDMap

Returns the program ID map.

source

fn mapping_id_map(&self) -> &Self::MappingIDMap

Returns the mapping ID map.

source

fn key_value_id_map(&self) -> &Self::KeyValueIDMap

Returns the key-value ID map.

source

fn key_map(&self) -> &Self::KeyMap

Returns the key map.

source

fn value_map(&self) -> &Self::ValueMap

Returns the value map.

source

fn dev(&self) -> Option<u16>

Returns the optional development ID.

Provided Methods§

source

fn start_atomic(&self)

Starts an atomic batch write operation.

source

fn is_atomic_in_progress(&self) -> bool

Checks if an atomic batch is in progress.

source

fn atomic_checkpoint(&self)

Checkpoints the atomic batch.

source

fn clear_latest_checkpoint(&self)

Clears the latest atomic batch checkpoint.

source

fn atomic_rewind(&self)

Rewinds the atomic batch to the previous checkpoint.

source

fn abort_atomic(&self)

Aborts an atomic batch write operation.

source

fn finish_atomic(&self) -> Result<()>

Finishes an atomic batch write operation.

source

fn initialize_mapping( &self, program_id: &ProgramID<N>, mapping_name: &Identifier<N> ) -> Result<FinalizeOperation<N>>

Initializes the given program ID and mapping name in storage. If the mapping name is already initialized, an error is returned.

source

fn insert_key_value( &self, program_id: &ProgramID<N>, mapping_name: &Identifier<N>, key: Plaintext<N>, value: Value<N> ) -> Result<FinalizeOperation<N>>

Stores the given (key, value) pair at the given program ID and mapping name in storage. If the mapping name is not initialized, an error is returned. If the key already exists, the method returns an error.

source

fn update_key_value( &self, program_id: &ProgramID<N>, mapping_name: &Identifier<N>, key: Plaintext<N>, value: Value<N> ) -> Result<FinalizeOperation<N>>

Stores the given (key, value) pair at the given program ID and mapping name in storage. If the mapping name is not initialized, an error is returned. If the key does not exist, the (key, value) pair is initialized. If the key already exists, the value is overwritten.

source

fn remove_key_value( &self, program_id: &ProgramID<N>, mapping_name: &Identifier<N>, key: &Plaintext<N> ) -> Result<FinalizeOperation<N>>

Removes the key-value pair for the given program ID, mapping name, and key from storage.

source

fn remove_mapping( &self, program_id: &ProgramID<N>, mapping_name: &Identifier<N> ) -> Result<FinalizeOperation<N>>

Removes the mapping for the given program ID and mapping name from storage, along with all associated key-value pairs in storage.

source

fn remove_program(&self, program_id: &ProgramID<N>) -> Result<()>

Removes the program for the given program ID from storage, along with all associated mappings and key-value pairs in storage.

source

fn contains_program_confirmed(&self, program_id: &ProgramID<N>) -> Result<bool>

Returns true if the given program ID exist.

source

fn contains_mapping_confirmed( &self, program_id: &ProgramID<N>, mapping_name: &Identifier<N> ) -> Result<bool>

Returns true if the given program ID and mapping name exist.

source

fn contains_key_confirmed( &self, program_id: &ProgramID<N>, mapping_name: &Identifier<N>, key: &Plaintext<N> ) -> Result<bool>

Returns true if the given program ID, mapping name, and key exist.

source

fn contains_key_speculative( &self, program_id: &ProgramID<N>, mapping_name: &Identifier<N>, key: &Plaintext<N> ) -> Result<bool>

Returns true if the given program ID, mapping name, and key exist.

source

fn get_mapping_names_confirmed( &self, program_id: &ProgramID<N> ) -> Result<Option<IndexSet<Identifier<N>>>>

Returns the confirmed mapping names for the given program ID.

source

fn get_mapping_names_speculative( &self, program_id: &ProgramID<N> ) -> Result<Option<IndexSet<Identifier<N>>>>

Returns the speculative mapping names for the given program ID.

source

fn get_mapping_id_confirmed( &self, program_id: &ProgramID<N>, mapping_name: &Identifier<N> ) -> Result<Option<Field<N>>>

Returns the confirmed mapping ID for the given program ID and mapping name.

source

fn get_mapping_id_speculative( &self, program_id: &ProgramID<N>, mapping_name: &Identifier<N> ) -> Result<Option<Field<N>>>

Returns the speculative mapping ID for the given program ID and mapping name.

source

fn get_key_id_confirmed( &self, program_id: &ProgramID<N>, mapping_name: &Identifier<N>, key: &Plaintext<N> ) -> Result<Option<Field<N>>>

Returns the confirmed key ID for the given program ID, mapping name, and key.

source

fn get_key_id_speculative( &self, program_id: &ProgramID<N>, mapping_name: &Identifier<N>, key: &Plaintext<N> ) -> Result<Option<Field<N>>>

Returns the speculative key ID for the given program ID, mapping name, and key.

source

fn get_key_speculative(&self, key_id: &Field<N>) -> Result<Option<Plaintext<N>>>

Returns the speculative key for the given key ID.

source

fn get_value_confirmed( &self, program_id: &ProgramID<N>, mapping_name: &Identifier<N>, key: &Plaintext<N> ) -> Result<Option<Value<N>>>

Returns the confirmed value for the given program ID, mapping name, and key.

source

fn get_value_speculative( &self, program_id: &ProgramID<N>, mapping_name: &Identifier<N>, key: &Plaintext<N> ) -> Result<Option<Value<N>>>

Returns the speculative value for the given program ID, mapping name, and key.

source

fn get_value_from_key_id_confirmed( &self, key_id: &Field<N> ) -> Result<Option<Value<N>>>

Returns the confirmed value for the given key ID.

source

fn get_value_from_key_id_speculative( &self, key_id: &Field<N> ) -> Result<Option<Value<N>>>

Returns the speculative value for the given key ID.

Implementors§

source§

impl<N: Network> FinalizeStorage<N> for FinalizeMemory<N>

§

type ProgramIDMap = MemoryMap<ProgramID<N>, IndexSet<Identifier<N>, RandomState>>

§

type MappingIDMap = MemoryMap<(ProgramID<N>, Identifier<N>), Field<N>>

§

type KeyValueIDMap = MemoryMap<Field<N>, IndexMap<Field<N>, Field<N>, RandomState>>

§

type KeyMap = MemoryMap<Field<N>, Plaintext<N>>

§

type ValueMap = MemoryMap<Field<N>, Value<N>>