From 5f58786f9c7fd5d5b2e0fa70328e6e46da4a30af Mon Sep 17 00:00:00 2001 From: 0o-de-lally <1364012+0o-de-lally@users.noreply.github.com> Date: Fri, 22 Nov 2024 17:54:18 -0500 Subject: [PATCH] more data in cypher insert --- src/scan.rs | 7 +++++++ src/schema_account_state.rs | 7 ++++--- tests/test_load_state.rs | 3 --- 3 files changed, 11 insertions(+), 6 deletions(-) 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();