Skip to content

Commit

Permalink
cardano source: add legacy testnet settings (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
ecioppettini committed Dec 5, 2022
1 parent 147bb09 commit e8b2c73
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
27 changes: 27 additions & 0 deletions blockchain-source/src/cardano/configuration.rs
Expand Up @@ -4,6 +4,8 @@ use dcspark_core::{BlockId, SlotNumber};
use std::borrow::Cow;

#[derive(Clone, Debug, serde::Deserialize)]
#[serde(rename_all = "snake_case")]
#[serde(deny_unknown_fields)]
pub struct NetworkConfiguration {
pub chain_info: ChainInfo,
pub relay: (Cow<'static, str>, u16),
Expand All @@ -18,6 +20,7 @@ pub enum ChainInfo {
Mainnet,
Preprod,
Preview,
Testnet,
Custom { protocol_magic: u64, network_id: u8 },
}

Expand All @@ -26,6 +29,7 @@ impl From<ChainInfo> for cardano_sdk::chaininfo::ChainInfo {
match info {
ChainInfo::Mainnet => cardano_sdk::chaininfo::ChainInfo::MAINNET,
ChainInfo::Preprod => cardano_sdk::chaininfo::ChainInfo::PREPROD,
ChainInfo::Testnet => cardano_sdk::chaininfo::ChainInfo::TESTNET,
ChainInfo::Preview => cardano_sdk::chaininfo::ChainInfo {
protocol_magic: Magic(2),
network_id: 0b0000,
Expand Down Expand Up @@ -64,6 +68,29 @@ impl NetworkConfiguration {
}
}

pub fn testnet() -> Self {
Self {
chain_info: ChainInfo::Testnet,
relay: (
Cow::Borrowed("relays-new.cardano-testnet.iohkdev.io."),
3001,
),
from: Point::BlockHeader {
slot_nb: SlotNumber::new(1598400),
hash: BlockId::new(
"02b1c561715da9e540411123a6135ee319b02f60b9a11a603d3305556c04329f",
),
},
genesis_parent: BlockId::new(
"96fceff972c2c06bd3bb5243c39215333be6d56aaf4823073dca31afe5038471",
),
genesis: BlockId::new(
"8f8602837f7c6f8b8867dd1cbc1842cf51a27eaed2c70ef48325d00f8efb320f",
),
shelley_era_config: Era::SHELLEY_TESTNET,
}
}

pub fn preprod() -> Self {
Self {
chain_info: ChainInfo::Preprod,
Expand Down
7 changes: 7 additions & 0 deletions blockchain-source/src/cardano/time.rs
Expand Up @@ -17,6 +17,13 @@ impl Era {
slot_length: 1,
};

pub const SHELLEY_TESTNET: Self = Self {
first_slot: 1598400,
start_epoch: 74,
known_time: 1595967616,
slot_length: 1,
};

pub const SHELLEY_PREPROD: Self = Self {
first_slot: 86400,
start_epoch: 0,
Expand Down

0 comments on commit e8b2c73

Please sign in to comment.