pub fn last_committed_state_for_account(
        &self,
        account_id: AccountId,
    ) -> QueryResult<Option<Account>> {
        // Get the last certain state of the account.
        // Note that `account` can be `None` here (if it wasn't verified yet), since
        // we will update the committed changes below.
        let (last_block, account) = self.get_account_and_last_block(account_id)?;

        // Collect the diffs that we have to apply to the account.
        let (account_balance_diff, account_creation_diff) = self
            .0
            .conn()
            .transaction::<_, diesel::result::Error, _>(|| {
                // From `account_balance_updates` load entries with the same ID and height
                // greater than for the last verified block.
                let account_balance_diff: Vec<StorageAccountUpdate> = {
                    account_balance_updates::table
                        .filter(account_balance_updates::account_id.eq(&(i64::from(account_id))))
                        .filter(account_balance_updates::block_number.gt(&last_block))
                        .load::<StorageAccountUpdate>(self.0.conn())?
                };

                // The same as above, but for `account_creates` table.
                let account_creation_diff: Vec<StorageAccountCreation> = {
                    account_creates::table
                        .filter(account_creates::account_id.eq(&(i64::from(account_id))))
                        .filter(account_creates::block_number.gt(&last_block))
                        .load::<StorageAccountCreation>(self.0.conn())?
                };

                Ok((account_balance_diff, account_creation_diff))
            })?;

        // Chain the diffs, converting them into `StorageAccountDiff`.
        let account_diff = {
            let mut account_diff = Vec::new();
            account_diff.extend(
                account_balance_diff
                    .into_iter()
                    .map(StorageAccountDiff::from),
            );
            account_diff.extend(
                account_creation_diff
                    .into_iter()
                    .map(StorageAccountDiff::from),
            );
            account_diff.sort_by(StorageAccountDiff::cmp_order);
            account_diff
                .into_iter()
                .map(Into::into)
                .collect::<AccountUpdates>()
        };

        // Apply all the diffs to obtain the most recent account state.
        let account_state = account_diff
            .into_iter()
            .map(|(_, upd)| upd)
            .fold(account, Account::apply_update);

        Ok(account_state)
    }
/// Loads the last committed (e.g. just added but no necessarily verified) state for
/// account given its ID.
Loads the last committed  state for
account given its ID.
Loads the last committed state for account given its ID .
pub fn last_committed_state_for_account(
        &self,
        account_id: AccountId,
    ) -> QueryResult<Option<Account>> {
        // Get the last certain state of the account.
        // Note that `account` can be `None` here (if it wasn't verified yet), since
        // we will update the committed changes below.
        let (last_block, account) = self.get_account_and_last_block(account_id)?;
        // Collect the diffs that we have to apply to the account.
        let (account_balance_diff, account_creation_diff) = self
            .0
            .conn()
            .transaction::<_, diesel::result::Error, _>(|| {
                // From `account_balance_updates` load entries with the same ID and height
                // greater than for the last verified block.
                let account_balance_diff: Vec<StorageAccountUpdate> = {
                    account_balance_updates::table
                        .filter(account_balance_updates::account_id.eq(&(i64::from(account_id))))
                        .filter(account_balance_updates::block_number.gt(&last_block))
                        .load::<StorageAccountUpdate>(self.0.conn())?
                };
                // The same as above, but for `account_creates` table.
                let account_creation_diff: Vec<StorageAccountCreation> = {
                    account_creates::table
                        .filter(account_creates::account_id.eq(&(i64::from(account_id))))
                        .filter(account_creates::block_number.gt(&last_block))
                        .load::<StorageAccountCreation>(self.0.conn())?
                };
                Ok((account_balance_diff, account_creation_diff))
            })?;
        // Chain the diffs, converting them into `StorageAccountDiff`.
        let account_diff = {
            let mut account_diff = Vec::new();
            account_diff.extend(
                account_balance_diff
                    .into_iter()
                    .map(StorageAccountDiff::from),
            );
            account_diff.extend(
                account_creation_diff
                    .into_iter()
                    .map(StorageAccountDiff::from),
            );
            account_diff.sort_by(StorageAccountDiff::cmp_order);
            account_diff
                .into_iter()
                .map(Into::into)
                .collect::<AccountUpdates>()
        };
        // Apply all the diffs to obtain the most recent account state.
        let account_state = account_diff
            .into_iter()
            .map(|(_, upd)| upd)
            .fold(account, Account::apply_update);
        Ok(account_state)
    }
pub fn last_committed_state_for_account ( & self , account_id : AccountId , ) -> QueryResult < Option < Account > > { // Get the last certain state of the account. // Note that `account` can be `None` here (if it wasn't verified yet), since // we will update the committed changes below. let ( last_block , account ) = self . get_account_and_last_block ( account_id ) ? ; // Collect the diffs that we have to apply to the account. let ( account_balance_diff , account_creation_diff ) = self . 0 . conn ( ) . transaction :: < _ , diesel :: result :: Error , _ > ( | | { // From `account_balance_updates` load entries with the same ID and height // greater than for the last verified block. let account_balance_diff : Vec < StorageAccountUpdate > = { account_balance_updates :: table . filter ( account_balance_updates :: account_id . eq ( & ( i64 :: from ( account_id ) ) ) ) . filter ( account_balance_updates :: block_number . gt ( & last_block ) ) . load :: < StorageAccountUpdate > ( self . 0 . conn ( ) ) ? } ; // The same as above, but for `account_creates` table. let account_creation_diff : Vec < StorageAccountCreation > = { account_creates :: table . filter ( account_creates :: account_id . eq ( & ( i64 :: from ( account_id ) ) ) ) . filter ( account_creates :: block_number . gt ( & last_block ) ) . load :: < StorageAccountCreation > ( self . 0 . conn ( ) ) ? } ; Ok ( ( account_balance_diff , account_creation_diff ) ) } ) ? ; // Chain the diffs, converting them into `StorageAccountDiff`. let account_diff = { let mut account_diff = Vec :: new ( ) ; account_diff . extend ( account_balance_diff . into_iter ( ) . map ( StorageAccountDiff :: from ) , ) ; account_diff . extend ( account_creation_diff . into_iter ( ) . map ( StorageAccountDiff :: from ) , ) ; account_diff . sort_by ( StorageAccountDiff :: cmp_order ) ; account_diff . into_iter ( ) . map ( Into :: into ) . collect :: < AccountUpdates > ( ) } ; // Apply all the diffs to obtain the most recent account state. let account_state = account_diff . into_iter ( ) . map ( | ( _ , upd ) | upd ) . fold ( account , Account :: apply_update ) ; Ok ( account_state ) }
Loads the last committed (e.g.
Loads the last committed ( e . g .
&self
account_id
AccountId