Skip to main content

cache_le

Function cache_le 

Source
pub fn cache_le(entry_id: &LedgerEntryIdBytes) -> Result<i32>
Expand description

Load the ledger entry with the given ID into a host cache slot, returning that slot.

The host assigns the next free slot; its cache holds up to 255 entries at once, so a contract that caches in a loop can exhaust it and see host::Error::SlotsFull. An ID that matches no entry in the ledger is host::Error::LedgerObjNotFound, which is how a contract asks “does this object exist?”.

use xrpl_common_stdlib::host::Result;
use xrpl_common_stdlib::ledger_entry_ids::accountroot_id;
use xrpl_common_stdlib::objects::{AccountRoot, AccountRootFields, cache_le};
use xrpl_common_stdlib::types::account_id::AccountID;
if let Result::Ok(id) = accountroot_id(account) {
    if let Result::Ok(slot) = cache_le(&id) {
        let balance = AccountRoot::new(slot).balance();
    }
}