move RPC scanning cache to borsh

This commit is contained in:
Boog900 2023-12-18 14:36:22 +00:00
parent e264a40feb
commit 84343a8297
No known key found for this signature in database
GPG key ID: 5401367FB7302004
4 changed files with 8 additions and 33 deletions

27
Cargo.lock generated
View file

@ -157,25 +157,6 @@ version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b"
[[package]]
name = "bincode"
version = "2.0.0-rc.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f11ea1a0346b94ef188834a65c068a03aec181c94896d481d7a0a40d85b0ce95"
dependencies = [
"bincode_derive",
"serde",
]
[[package]]
name = "bincode_derive"
version = "2.0.0-rc.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e30759b3b99a1b802a7a3aa21c85c3ded5c28e1c83170d82d70f08bbf7f3e4c"
dependencies = [
"virtue",
]
[[package]]
name = "bit-set"
version = "0.5.3"
@ -472,7 +453,7 @@ dependencies = [
name = "cuprate-consensus"
version = "0.1.0"
dependencies = [
"bincode",
"borsh",
"clap",
"crypto-bigint",
"cuprate-common",
@ -2237,12 +2218,6 @@ version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "virtue"
version = "0.0.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9dcc60c0624df774c82a0ef104151231d37da4962957d691c011c852b2473314"
[[package]]
name = "wait-timeout"
version = "0.2.0"

View file

@ -35,7 +35,7 @@ opt-level = 3
[workspace.dependencies]
async-trait = { version = "0.1.74" }
bincode = { version = "2.0.0-rc.3" }
borsh = { version = "1.2.1" }
bytes = { version = "1.5.0" }
clap = { version = "4.4.7" }
chrono = { version = "0.4.31" }

View file

@ -21,7 +21,7 @@ binaries = [
"dep:serde",
"dep:monero-epee-bin-serde",
"dep:monero-wire",
"dep:bincode",
"dep:borsh",
"dep:dirs",
"dep:clap"
]
@ -57,7 +57,7 @@ monero-epee-bin-serde = { workspace = true , optional = true}
serde_json = {version = "1", optional = true}
serde = {version = "1", optional = true, features = ["derive"]}
tracing-subscriber = {version = "0.3", optional = true}
bincode = {version = "2.0.0-rc.3", optional = true}
borsh = { workspace = true, optional = true}
dirs = {version="5.0", optional = true}
clap = { version = "4.4.8", optional = true, features = ["derive"] }
# here to help cargo to pick a version - remove me

View file

@ -7,7 +7,7 @@ use std::{
sync::Arc,
};
use bincode::{Decode, Encode};
use borsh::{BorshDeserialize, BorshSerialize};
use monero_serai::transaction::{Input, Timelock, Transaction};
use tracing_subscriber::fmt::MakeWriter;
@ -18,7 +18,7 @@ use crate::transactions::TransactionVerificationData;
/// Because we are using a RPC interface with a node we need to keep track
/// of certain data that the node doesn't hold or give us like the number
/// of outputs at a certain time.
#[derive(Debug, Default, Clone, Encode, Decode)]
#[derive(Debug, Default, Clone, BorshSerialize, BorshDeserialize)]
pub struct ScanningCache {
// network: u8,
numb_outs: HashMap<u64, usize>,
@ -37,7 +37,7 @@ impl ScanningCache {
.create(true)
.open(file)?;
let mut writer = BufWriter::new(file.make_writer());
bincode::encode_into_std_write(self, &mut writer, bincode::config::standard())?;
borsh::to_writer(&mut writer, &self)?;
writer.flush()?;
Ok(())
}
@ -45,7 +45,7 @@ impl ScanningCache {
pub fn load(file: &Path) -> Result<ScanningCache, tower::BoxError> {
let mut file = std::fs::OpenOptions::new().read(true).open(file)?;
bincode::decode_from_std_read(&mut file, bincode::config::standard()).map_err(Into::into)
Ok(borsh::from_reader(&mut file)?)
}
pub fn add_new_block_data(