node/transaction_pool/
transaction_pool_effects.rs1use std::collections::BTreeMap;
2
3use crate::{ledger::LedgerService, snark::SnarkStore};
4
5use super::TransactionPoolEffectfulAction;
6
7impl TransactionPoolEffectfulAction {
8 pub fn effects<Store, S>(self, store: &mut Store)
9 where
10 Store: SnarkStore<S>,
11 Store::Service: LedgerService,
12 {
13 match self {
14 TransactionPoolEffectfulAction::FetchAccounts {
15 account_ids,
16 ledger_hash,
17 on_result,
18 pending_id,
19 from_source,
20 } => {
21 openmina_core::log::info!(
22 openmina_core::log::system_time();
23 kind = "TransactionPoolEffectfulFetchAccounts",
24 summary = "fetching accounts for tx pool");
25 let accounts = match store
31 .service()
32 .ledger_manager()
33 .get_accounts(&ledger_hash, account_ids.iter().cloned().collect())
34 {
35 Ok(accounts) => accounts,
36 Err(err) => {
37 openmina_core::log::error!(
38 openmina_core::log::system_time();
39 kind = "Error",
40 summary = "failed to fetch accounts for tx pool",
41 error = format!("ledger {:?}, error: {:?}", ledger_hash, err));
42 return;
43 }
44 };
45
46 let accounts = accounts
47 .into_iter()
48 .map(|account| (account.id(), account))
49 .collect::<BTreeMap<_, _>>();
50
51 store.dispatch_callback(on_result, (accounts, pending_id, from_source));
52 }
53 }
54 }
55}