solana-tokens: optimize PickleDb dumps (#13879)
* Dump PickleDb after transaction sends/confirmation * Dump PickleDb on ctrlc * Don't exit during tests * Add build_messages helper and test db dump * Add send_messages helper and test db dump * Add combined test * Add log_transaction_confirmations helper and test db dump * Add update_finalized_transactions test * Return error instead of process::exit * Close TestValidator
This commit is contained in:
@ -1,7 +1,16 @@
|
||||
use solana_cli_config::{Config, CONFIG_FILE};
|
||||
use solana_client::rpc_client::RpcClient;
|
||||
use solana_tokens::{arg_parser::parse_args, args::Command, commands, spl_token};
|
||||
use std::{env, error::Error, path::Path, process};
|
||||
use std::{
|
||||
env,
|
||||
error::Error,
|
||||
path::Path,
|
||||
process,
|
||||
sync::{
|
||||
atomic::{AtomicBool, Ordering},
|
||||
Arc,
|
||||
},
|
||||
};
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
let command_args = parse_args(env::args_os())?;
|
||||
@ -18,10 +27,18 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
let json_rpc_url = command_args.url.unwrap_or(config.json_rpc_url);
|
||||
let client = RpcClient::new(json_rpc_url);
|
||||
|
||||
let exit = Arc::new(AtomicBool::default());
|
||||
let _exit = exit.clone();
|
||||
// Initialize CTRL-C handler to ensure db changes are written before exit.
|
||||
ctrlc::set_handler(move || {
|
||||
_exit.store(true, Ordering::SeqCst);
|
||||
})
|
||||
.expect("Error setting Ctrl-C handler");
|
||||
|
||||
match command_args.command {
|
||||
Command::DistributeTokens(mut args) => {
|
||||
spl_token::update_token_args(&client, &mut args.spl_token_args)?;
|
||||
commands::process_allocations(&client, &args)?;
|
||||
commands::process_allocations(&client, &args, exit)?;
|
||||
}
|
||||
Command::Balances(mut args) => {
|
||||
spl_token::update_decimals(&client, &mut args.spl_token_args)?;
|
||||
|
Reference in New Issue
Block a user