From 4dde274a022c5e7fe559c9bd273189cfbe9f3127 Mon Sep 17 00:00:00 2001 From: Steven Luscher Date: Thu, 19 Dec 2024 19:39:43 +0000 Subject: [PATCH] Send call to `get_largest_accounts` to the background pool --- rpc/src/rpc.rs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/rpc/src/rpc.rs b/rpc/src/rpc.rs index 6e9b33abcaa157..baffa72b8e0788 100644 --- a/rpc/src/rpc.rs +++ b/rpc/src/rpc.rs @@ -1065,13 +1065,21 @@ impl JsonRpcRequestProcessor { } else { (HashSet::new(), AccountAddressFilter::Exclude) }; - let accounts = bank - .get_largest_accounts( - NUM_LARGEST_ACCOUNTS, - &addresses, - address_filter, - sort_results, - ) + let accounts = self + .runtime + .spawn_blocking({ + let bank = Arc::clone(&bank); + move || { + bank.get_largest_accounts( + NUM_LARGEST_ACCOUNTS, + &addresses, + address_filter, + sort_results, + ) + } + }) + .await + .expect("Failed to spawn blocking task") .map_err(|e| RpcCustomError::ScanError { message: e.to_string(), })?