pub fn from_pairs(
        correlation_id: CorrelationId,
        pairs: &[(Key, StoredValue)],
    ) -> Result<(Self, Digest), error::Error> {
        let state = InMemoryGlobalState::empty()?;
        let mut current_root = state.empty_root_hash;
        {
            let mut txn = state.environment.create_read_write_txn()?;
            for (key, value) in pairs {
                let key = key.normalize();
                match operations::write::<_, _, _, InMemoryTrieStore, in_memory::Error>(
                    correlation_id,
                    &mut txn,
                    &state.trie_store,
                    &current_root,
                    &key,
                    value,
                )? {
                    WriteResult::Written(root_hash) => {
                        current_root = root_hash;
                    }
                    WriteResult::AlreadyExists => (),
                    WriteResult::RootNotFound => panic!("InMemoryGlobalState has invalid root"),
                }
            }
            txn.commit()?;
        }
        Ok((state, current_root))
    }
/// Creates a state from a given set of `Key, StoredValue` pairs.
Creates a state from a given set of `Key, StoredValue` pairs.
Creates a state from a given set of ` Key StoredValue ` pairs .
pub fn from_pairs(
        correlation_id: CorrelationId,
        pairs: &[(Key, StoredValue)],
    ) -> Result<(Self, Digest), error::Error> {
        let state = InMemoryGlobalState::empty()?;
        let mut current_root = state.empty_root_hash;
        {
            let mut txn = state.environment.create_read_write_txn()?;
            for (key, value) in pairs {
                let key = key.normalize();
                match operations::write::<_, _, _, InMemoryTrieStore, in_memory::Error>(
                    correlation_id,
                    &mut txn,
                    &state.trie_store,
                    &current_root,
                    &key,
                    value,
                )? {
                    WriteResult::Written(root_hash) => {
                        current_root = root_hash;
                    }
                    WriteResult::AlreadyExists => (),
                    WriteResult::RootNotFound => panic!("InMemoryGlobalState has invalid root"),
                }
            }
            txn.commit()?;
        }
        Ok((state, current_root))
    }
pub fn from_pairs ( correlation_id : CorrelationId , pairs : & [ ( Key , StoredValue ) ] , ) -> Result < ( Self , Digest ) , error :: Error > { let state = InMemoryGlobalState :: empty ( ) ? ; let mut current_root = state . empty_root_hash ; { let mut txn = state . environment . create_read_write_txn ( ) ? ; for ( key , value ) in pairs { let key = key . normalize ( ) ; match operations :: write :: < _ , _ , _ , InMemoryTrieStore , in_memory :: Error > ( correlation_id , & mut txn , & state . trie_store , & current_root , & key , value , ) ? { WriteResult :: Written ( root_hash ) => { current_root = root_hash ; } WriteResult :: AlreadyExists => ( ) , WriteResult :: RootNotFound => panic ! ( " " ) , } } txn . commit ( ) ? ; } Ok ( ( state , current_root ) ) }
Creates a state from a given set of `Key, StoredValue` pairs.
Creates a state from a given set of ` Key StoredValue ` pairs .
correlation_id
CorrelationId
pairs
&[(Key, StoredValue)]
correlation_id
CorrelationId
pairs
&[(Key, StoredValue)]