1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use clap::{crate_description, crate_name, value_t_or_exit, App, Arg};
use log::*;
use solana_runtime::append_vec::AppendVec;

fn main() {
    solana_logger::setup_with_default("solana=info");
    let matches = App::new(crate_name!())
        .about(crate_description!())
        .version(solana_version::version!())
        .arg(
            Arg::with_name("file")
                .long("file")
                .takes_value(true)
                .value_name("<PATH>")
                .help("store to open"),
        )
        .arg(
            Arg::with_name("len")
                .long("len")
                .takes_value(true)
                .value_name("LEN")
                .help("len of store to open"),
        )
        .get_matches();

    let file = value_t_or_exit!(matches, "file", String);
    let len = value_t_or_exit!(matches, "len", usize);
    let (mut store, num_accounts) = AppendVec::new_from_file(file, len).expect("should succeed");
    store.set_no_remove_on_drop();
    info!(
        "store: len: {} capacity: {} accounts: {}",
        store.len(),
        store.capacity(),
        num_accounts,
    );
    for account in store.accounts(0) {
        info!(
            "  account: {:?} version: {} data: {} hash: {:?}",
            account.meta.pubkey, account.meta.write_version, account.meta.data_len, account.hash
        );
    }
}

#[cfg(test)]
pub mod test {}