fn flush_changes(&mut self) {
        let mut state = &mut self.state;
        let r = RocksHandle::new(RocksDatabaseHandle::new(self.kvs.db()));

        let mut storage_tries = TrieCollection::new(r.clone(), StaticEntries::default());
        let mut account_tries = TrieCollection::new(r, StaticEntries::default());

        let mut accounts =
            FixedSecureTrieMut::<_, H160, Account>::new(account_tries.trie_for(state.state_root));

        for (address, (state, storages)) in state.state_updates.drain() {
            if let Maybe::Just(AccountState {
                nonce,
                balance,
                code,
            }) = state
            {
                let mut account = accounts.get(&address).unwrap_or_default();

                account.nonce = nonce;
                account.balance = balance;

                if !code.is_empty() {
                    let code_hash = code.hash();
                    self.kvs.set::<Codes>(code_hash, code);
                    account.code_hash = code_hash;
                }

                let mut storage = FixedSecureTrieMut::<_, H256, U256>::new(
                    storage_tries.trie_for(account.storage_root),
                );

                for (index, value) in storages {
                    if value != H256::default() {
                        let value = U256::from_big_endian(&value[..]);
                        storage.insert(&index, &value);
                    } else {
                        storage.delete(&index);
                    }
                }

                let storage_patch = storage.to_trie().into_patch();
                let storage_root = storage_tries.apply(storage_patch);
                account.storage_root = storage_root;

                accounts.insert(&address, &account);
            } else {
                accounts.delete(&address);
            }
        }

        let accounts_patch = accounts.to_trie().into_patch();
        let new_root = account_tries.apply(accounts_patch);

        // for (hash, receipt) in std::mem::take(&mut self.receipts) {
        //     self.kvs.set::<Receipts>(hash, receipt);
        // }

        state.state_root = new_root;
    }
/// Apply state updates.
/// Be sure to commit_block manually after calling this method,
/// because it clear pending state, and is_active_changes cannot detect any state changes.
Apply state updates.
Be sure to commit_block manually after calling this method,
because it clear pending state, and is_active_changes cannot detect any state changes.
Apply state updates . Be sure to commit_block manually after calling this method because it clear pending state and is_active_changes cannot detect any state changes .
fn flush_changes(&mut self) {
        let mut state = &mut self.state;
        let r = RocksHandle::new(RocksDatabaseHandle::new(self.kvs.db()));
        let mut storage_tries = TrieCollection::new(r.clone(), StaticEntries::default());
        let mut account_tries = TrieCollection::new(r, StaticEntries::default());
        let mut accounts =
            FixedSecureTrieMut::<_, H160, Account>::new(account_tries.trie_for(state.state_root));
        for (address, (state, storages)) in state.state_updates.drain() {
            if let Maybe::Just(AccountState {
                nonce,
                balance,
                code,
            }) = state
            {
                let mut account = accounts.get(&address).unwrap_or_default();
                account.nonce = nonce;
                account.balance = balance;
                if !code.is_empty() {
                    let code_hash = code.hash();
                    self.kvs.set::<Codes>(code_hash, code);
                    account.code_hash = code_hash;
                }
                let mut storage = FixedSecureTrieMut::<_, H256, U256>::new(
                    storage_tries.trie_for(account.storage_root),
                );
                for (index, value) in storages {
                    if value != H256::default() {
                        let value = U256::from_big_endian(&value[..]);
                        storage.insert(&index, &value);
                    } else {
                        storage.delete(&index);
                    }
                }
                let storage_patch = storage.to_trie().into_patch();
                let storage_root = storage_tries.apply(storage_patch);
                account.storage_root = storage_root;
                accounts.insert(&address, &account);
            } else {
                accounts.delete(&address);
            }
        }
        let accounts_patch = accounts.to_trie().into_patch();
        let new_root = account_tries.apply(accounts_patch);
        // for (hash, receipt) in std::mem::take(&mut self.receipts) {
        //     self.kvs.set::<Receipts>(hash, receipt);
        // }
        state.state_root = new_root;
    }
fn flush_changes ( & mut self ) { let mut state = & mut self . state ; let r = RocksHandle :: new ( RocksDatabaseHandle :: new ( self . kvs . db ( ) ) ) ; let mut storage_tries = TrieCollection :: new ( r . clone ( ) , StaticEntries :: default ( ) ) ; let mut account_tries = TrieCollection :: new ( r , StaticEntries :: default ( ) ) ; let mut accounts = FixedSecureTrieMut :: < _ , H160 , Account > :: new ( account_tries . trie_for ( state . state_root ) ) ; for ( address , ( state , storages ) ) in state . state_updates . drain ( ) { if let Maybe :: Just ( AccountState { nonce , balance , code , } ) = state { let mut account = accounts . get ( & address ) . unwrap_or_default ( ) ; account . nonce = nonce ; account . balance = balance ; if ! code . is_empty ( ) { let code_hash = code . hash ( ) ; self . kvs . set :: < Codes > ( code_hash , code ) ; account . code_hash = code_hash ; } let mut storage = FixedSecureTrieMut :: < _ , H256 , U256 > :: new ( storage_tries . trie_for ( account . storage_root ) , ) ; for ( index , value ) in storages { if value != H256 :: default ( ) { let value = U256 :: from_big_endian ( & value [ .. ] ) ; storage . insert ( & index , & value ) ; } else { storage . delete ( & index ) ; } } let storage_patch = storage . to_trie ( ) . into_patch ( ) ; let storage_root = storage_tries . apply ( storage_patch ) ; account . storage_root = storage_root ; accounts . insert ( & address , & account ) ; } else { accounts . delete ( & address ) ; } } let accounts_patch = accounts . to_trie ( ) . into_patch ( ) ; let new_root = account_tries . apply ( accounts_patch ) ; // for (hash, receipt) in std::mem::take(&mut self.receipts) { //     self.kvs.set::<Receipts>(hash, receipt); // } state . state_root = new_root ; }
Apply state updates.
Apply state updates .
&mut self
&mut self