diff --git a/src/extract_snapshot.rs b/src/extract_snapshot.rs index f253dfd..33b4916 100644 --- a/src/extract_snapshot.rs +++ b/src/extract_snapshot.rs @@ -2,17 +2,20 @@ use std::path::Path; use anyhow::Result; use diem_types::account_view::AccountView; -use libra_backwards_compatibility::version_five::{balance_v5::BalanceResourceV5, state_snapshot_v5::v5_accounts_from_manifest_path}; +use libra_backwards_compatibility::version_five::{ + balance_v5::BalanceResourceV5, ol_wallet::SlowWalletResourceV5, + state_snapshot_v5::v5_accounts_from_manifest_path, +}; use libra_storage::read_snapshot::{accounts_from_snapshot_backup, load_snapshot_manifest}; use libra_types::exports::AccountAddress; -use log::{info, warn}; +use log::{error, info, warn}; use crate::schema_account_state::WarehouseAccState; // uses libra-compatibility to parse the v5 manifest files, and decode v5 format bytecode into current version data structures (v6+); pub async fn extract_v5_snapshot(v5_manifest_path: &Path) -> Result> { let account_blobs = v5_accounts_from_manifest_path(v5_manifest_path).await?; - dbg!(&account_blobs.len()); + info!("account records found: {}", &account_blobs.len()); let mut warehouse_state = vec![]; for el in account_blobs.iter() { let acc = el.to_account_state()?; @@ -24,18 +27,21 @@ pub async fn extract_v5_snapshot(v5_manifest_path: &Path) -> Result().ok() { - s.balance = Some(b.coin()) + s.balance = Some(b.coin()) + } + if let Some(sw) = acc.get_resource::().ok() { + s.slow_wallet_locked = sw.unlocked; + s.slow_wallet_transferred = sw.transferred; } - warehouse_state.push(s); } Err(e) => { - println!("WARN: could not parse blob to V5 Address{}", &e); + error!("could not parse blob to V5 Address: {}", &e); } } } diff --git a/src/schema_account_state.rs b/src/schema_account_state.rs index 67956fa..feccd4e 100644 --- a/src/schema_account_state.rs +++ b/src/schema_account_state.rs @@ -7,6 +7,8 @@ pub struct WarehouseAccState { pub time: WarehouseTime, pub sequence_num: u64, pub balance: Option, + pub slow_wallet_locked: u64, + pub slow_wallet_transferred: u64, } impl WarehouseAccState { @@ -16,6 +18,9 @@ impl WarehouseAccState { sequence_num: 0, time: WarehouseTime::default(), balance: None, + slow_wallet_locked: 0, + slow_wallet_transferred: 0, + } } pub fn set_time(&mut self, timestamp: u64, version: u64, epoch: u64) { diff --git a/tests/test_extract.rs b/tests/test_extract_state.rs similarity index 100% rename from tests/test_extract.rs rename to tests/test_extract_state.rs