Skip to content

Commit

Permalink
applied mr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rnovikov committed Nov 12, 2024
1 parent c81692b commit eecd6b1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions evm_loader/lib/src/rpc/validator_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ impl Rpc for CloneRpcClient {
async fn get_account_slice(
&self,
key: &Pubkey,
_offset: usize,
_data_size: usize,
offset: usize,
data_size: usize,
) -> ClientResult<Option<Account>> {
let slice_shape = UiDataSliceConfig {
offset: _offset,
length: _data_size,
offset,
length: data_size,
};

let request = || {
Expand Down
20 changes: 10 additions & 10 deletions evm_loader/lib/src/types/account_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use std::sync::RwLock;

use bincode::serialize;
use tokio::sync::OnceCell;

use tracing::info;
#[derive(Debug, Eq, PartialEq, Hash)]
pub struct KeyAccountCache {
addr: Pubkey,
Expand Down Expand Up @@ -90,34 +90,34 @@ pub async fn acc_hash_get_values_by_keys(
//future_requests.push(rpc.get_account_slice(key, 0, 512));
}

assert!(
programdata_keys.len() == future_requests.len(),
assert_eq!(
programdata_keys.len(),
future_requests.len(),
"programdata_keys.size()!=future_requests.size()"
);
let results = join_all(future_requests).await;

for (i, result) in results.iter().enumerate() {
let key = programdata_keys[i];
for (result, key) in results.iter().zip(programdata_keys) {
match result {
Ok(Some(account)) => {
// Extract the slot value from the account data
let slot_val = get_programdata_slot_from_account(account);
// Assuming `acc_hash_get` is an async function that returns an `Option`
if let Some(acc) = acc_hash_get(key, slot_val).await {
if let Some(acc) = acc_hash_get(*key, slot_val).await {
answer.push(Some(acc));
} else if let Ok(Some(tmp_acc)) = rpc.get_account(&key).await {
acc_hash_add(key, slot_val, tmp_acc.clone()).await;
} else if let Ok(Some(tmp_acc)) = rpc.get_account(key).await {
acc_hash_add(*key, slot_val, tmp_acc.clone()).await;
answer.push(Some(tmp_acc));
} else {
answer.push(None);
}
}
Ok(None) => {
println!("Account for key {key:?} is None.");
info!("Account for key {key:?} is None.");
// need return
}
Err(e) => {
println!("Error fetching account for key {key:?}: {e:?}");
info!("Error fetching account for key {key:?}: {e:?}");
}
}
}
Expand Down

0 comments on commit eecd6b1

Please sign in to comment.