Expand description

NEAR Lake Parent Transaction Cache (Context)

Lake Parent Transaction Cache is a ready-to-use context for the Lake Framework in Rust. It provides a cache for keeping the relation between transactions and receipts in cache.

Example Usage

use near_lake_parent_transaction_cache::{ParentTransactionCache, ParentTransactionCacheBuilder};

let parent_transaction_cache_ctx = ParentTransactionCacheBuilder::default()
    .expect("Failed to build the ParentTransactionCache context");

    .expect("Failed to build the Lake Framework")
    .run_with_context(handle_block, &parent_transaction_cache_ctx)
    .expect("Failed to run the Lake Framework");

async fn handle_block(
    mut block: Block,
    ctx: &ParentTransactionCache,
) -> anyhow::Result<()> {
    for action in block.actions() {
            "Action receipt ID: {:?} | Parent TX hash: {:?}",

Getting Started

To use the Lake Parent Transaction Cache context in your Rust project, follow these steps:

  1. Add the following dependencies to your Cargo.toml file:
near-lake-parent-transaction-cache = "<version>"
  1. Import the necessary modules in your code:
use near_lake_parent_transaction_cache::ParentTransactionCache;
use near_lake_primitives::actions::ActionMetaDataExt;
  1. Create an instance of the ParentTransactionCache context:
let parent_transaction_cache_ctx = ParentTransactionCacheBuilder::default();
  1. Configure the Lake Framework and run it with the created context:
    .run_with_context(<your_indexing_function>, &parent_transaction_cache_ctx)?;

Replace <desired_block_height> with the starting block height you want to use. Replace <you_indexing_function> with the function you want to use to index the blocks.

Advanced Usage

Cache size

We use SizedCache under the hood. So we can configure the cache size by using the cache_size method:

let parent_transaction_cache_ctx = ParentTransactionCacheBuilder::default()

By default the cache size is 100,000.

Watch for specific accounts

By default ParentTransactionCache context will cache the relation between Transaction and Receipt for every Transaction in the block. But you can configure it to watch for specific accounts only:

You can pass a Vec of AccountId
use near_lake_framework::near_primitives::types::AccountId;

let accounts_to_watch: Vec<AccountId> = vec![
let parent_transaction_cache_ctx = ParentTransactionCacheBuilder::default()
You can pass accounts to watch one by one using for_account method
use near_lake_framework::near_primitives::types::AccountId;

let parent_transaction_cache_ctx = ParentTransactionCacheBuilder::default()



Type Aliases