diff --git a/src/crosscut/args.rs b/src/crosscut/args.rs index 170033f0..9fdba8c8 100644 --- a/src/crosscut/args.rs +++ b/src/crosscut/args.rs @@ -1,6 +1,6 @@ use pallas::network::miniprotocols::{Point, MAINNET_MAGIC, TESTNET_MAGIC}; use serde::{Deserialize, Serialize}; -use std::{fmt::Display, ops::Deref, str::FromStr}; +use std::{ops::Deref, str::FromStr}; use crate::Error; @@ -106,8 +106,37 @@ impl Default for MagicArg { pub enum IntersectConfig { Tip, Origin, - Point(PointArg), - Fallbacks(Vec), + Point(u64, String), + Fallbacks(Vec<(u64, String)>), +} + +impl IntersectConfig { + pub fn get_point(&self) -> Option { + match self { + IntersectConfig::Point(slot, hash) => { + let hash = hex::decode(hash).expect("valid hex hash"); + Some(Point::Specific(*slot, hash)) + } + _ => None, + } + } + + pub fn get_fallbacks(&self) -> Option> { + match self { + IntersectConfig::Fallbacks(all) => { + let mapped = all + .iter() + .map(|(slot, hash)| { + let hash = hex::decode(hash).expect("valid hex hash"); + Point::Specific(*slot, hash) + }) + .collect(); + + Some(mapped) + } + _ => None, + } + } } /// Well-known information about the blockhain network diff --git a/src/sources/utils.rs b/src/sources/utils.rs index 27d3ca5b..f0c64b48 100644 --- a/src/sources/utils.rs +++ b/src/sources/utils.rs @@ -73,13 +73,13 @@ pub fn define_known_points( let tip = find_end_of_chain(chain, channel)?; Ok(Some(vec![tip])) } - crosscut::IntersectConfig::Point(x) => { - let point = x.clone().try_into()?; + crosscut::IntersectConfig::Point(_, _) => { + let point = intersect.get_point().expect("point value"); Ok(Some(vec![point])) } - crosscut::IntersectConfig::Fallbacks(x) => { - let points: Result, _> = x.iter().cloned().map(|x| x.try_into()).collect(); - Ok(Some(points?)) + crosscut::IntersectConfig::Fallbacks(_) => { + let points = intersect.get_fallbacks().expect("fallback values"); + Ok(Some(points)) } } } diff --git a/testdrive/custom/data/dump.rdb b/testdrive/custom/data/dump.rdb new file mode 100644 index 00000000..910b0607 Binary files /dev/null and b/testdrive/custom/data/dump.rdb differ diff --git a/testdrive/custom/docker-compose.yml b/testdrive/custom/docker-compose.yml new file mode 100644 index 00000000..bde396ce --- /dev/null +++ b/testdrive/custom/docker-compose.yml @@ -0,0 +1,9 @@ +version: "3.7" + +services: + redis: + image: redis + volumes: + - ./data:/data + ports: + - "6379:6379" diff --git a/testdrive/custom/start.sh b/testdrive/custom/start.sh new file mode 100755 index 00000000..77031dc5 --- /dev/null +++ b/testdrive/custom/start.sh @@ -0,0 +1 @@ +RUST_LOG=info cargo run --all-features --bin scrolls -- daemon --config ./daemon.toml