diff --git a/src/scan.rs b/src/scan.rs index 7f28bf0..c9cb407 100644 --- a/src/scan.rs +++ b/src/scan.rs @@ -10,6 +10,7 @@ use libra_backwards_compatibility::version_five::{ use libra_storage::read_snapshot::load_snapshot_manifest; use std::{ collections::BTreeMap, + fmt, path::{Path, PathBuf}, }; #[derive(Clone, Debug)] @@ -65,6 +66,12 @@ pub enum FrameworkVersion { V7, } +impl fmt::Display for FrameworkVersion { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{:?}", &self) + } +} + #[derive(Clone, Debug, clap::ValueEnum)] pub enum BundleContent { Unknown, diff --git a/src/schema_account_state.rs b/src/schema_account_state.rs index b3f8465..ad9f858 100644 --- a/src/schema_account_state.rs +++ b/src/schema_account_state.rs @@ -57,13 +57,14 @@ impl WarehouseAccState { /// Note original data was in an RFC rfc3339 with Z for UTC, Cypher seems to prefer with offsets +00000 pub fn to_cypher_object_template(&self) -> String { format!( - r#"{{address: "{}", balance: {}, version: {}, sequence_num: {}, slow_locked: {}, slow_transfer: {} }}"#, + r#"{{address: "{}", balance: {}, version: {}, sequence_num: {}, slow_locked: {}, slow_transfer: {}, framework_version: "{}" }}"#, self.address.to_hex_literal(), self.balance, self.time.version, self.sequence_num, self.slow_wallet_locked, self.slow_wallet_transferred, + self.time.framework_version, ) } @@ -86,8 +87,8 @@ impl WarehouseAccState { UNWIND tx_data AS tx MERGE (addr:Account {{address: tx.address}}) - MERGE (snap:Snapshot {{address: tx.address, balance: tx.balance }}) - MERGE (addr)-[rel:State]->(snap) + MERGE (snap:Snapshot {{address: tx.address, balance: tx.balance, framework_version: tx.framework_version, version: tx.version, sequence_num: tx.sequence_num, slow_locked: tx.slow_locked, slow_transfer: tx.slow_transfer }}) + MERGE (addr)-[rel:State {{version: tx.version}} ]->(snap) RETURN COUNT(snap) AS merged_snapshots diff --git a/tests/test_load_state.rs b/tests/test_load_state.rs index 25ff746..cb93665 100644 --- a/tests/test_load_state.rs +++ b/tests/test_load_state.rs @@ -13,9 +13,6 @@ use support::{ #[tokio::test] async fn test_snapshot_unit() -> anyhow::Result<()> { libra_forensic_db::log_setup(); - // let manifest_file = v5_state_manifest_fixtures_path().join("state.manifest"); - // assert!(manifest_file.exists()); - // let s = extract_v5_snapshot(&manifest_file).await?; let snap1 = WarehouseAccState::default(); let snap2 = WarehouseAccState::default();