test-validator clone with get_multiple_accounts
This commit is contained in:
parent
1cf9077d06
commit
1fd04cdb42
|
@ -3,6 +3,7 @@
|
||||||
use {
|
use {
|
||||||
log::*,
|
log::*,
|
||||||
solana_cli_output::CliAccount,
|
solana_cli_output::CliAccount,
|
||||||
|
solana_client::rpc_request::MAX_MULTIPLE_ACCOUNTS,
|
||||||
solana_core::{
|
solana_core::{
|
||||||
tower_storage::TowerStorage,
|
tower_storage::TowerStorage,
|
||||||
validator::{Validator, ValidatorConfig, ValidatorStartProgress},
|
validator::{Validator, ValidatorConfig, ValidatorStartProgress},
|
||||||
|
@ -285,15 +286,20 @@ impl TestValidatorGenesis {
|
||||||
where
|
where
|
||||||
T: IntoIterator<Item = Pubkey>,
|
T: IntoIterator<Item = Pubkey>,
|
||||||
{
|
{
|
||||||
for address in addresses {
|
let addresses: Vec<Pubkey> = addresses.into_iter().collect();
|
||||||
info!("Fetching {} over RPC...", address);
|
for chunk in addresses.chunks(MAX_MULTIPLE_ACCOUNTS) {
|
||||||
let res = rpc_client.get_account(&address);
|
info!("Fetching {:?} over RPC...", chunk);
|
||||||
if let Ok(account) = res {
|
let responses = rpc_client
|
||||||
self.add_account(address, AccountSharedData::from(account));
|
.get_multiple_accounts(chunk)
|
||||||
} else if skip_missing {
|
.map_err(|err| format!("Failed to fetch: {}", err))?;
|
||||||
warn!("Could not find {}, skipping.", address);
|
for (address, res) in chunk.iter().zip(responses) {
|
||||||
} else {
|
if let Some(account) = res {
|
||||||
return Err(format!("Failed to fetch {}: {}", address, res.unwrap_err()));
|
self.add_account(*address, AccountSharedData::from(account));
|
||||||
|
} else if skip_missing {
|
||||||
|
warn!("Could not find {}, skipping.", address);
|
||||||
|
} else {
|
||||||
|
return Err(format!("Failed to fetch {}", address));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(self)
|
Ok(self)
|
||||||
|
|
Loading…
Reference in New Issue