iuna

iuna - experimental devnet protocol
git clone https://iuna.jhx.app/git/iuna.git
Log | Files | Refs | README | LICENSE

types.rs (4559B)


      1 use std::collections::BTreeMap;
      2 
      3 use serde::{Deserialize, Serialize};
      4 
      5 use crate::domain::{
      6     Amount, BlindedReveal, BlindedTransaction, Block, ChainSnapshot, ChainStatus, PreparedBlock,
      7     RevealBundle, StratumMineTemplate, Transaction, Wallet,
      8 };
      9 
     10 #[derive(Clone, Debug)]
     11 pub struct NodeConfig {
     12     pub wallet: Wallet,
     13     pub genesis_allocations: BTreeMap<String, Amount>,
     14     pub vdf_rounds: u64,
     15     pub burn_per_block: Amount,
     16     pub burn_fee: Amount,
     17     pub pow_mining_workers: u8,
     18     pub recovery_vdf_top_rank_percent: u8,
     19 }
     20 
     21 #[derive(Clone, Copy, Debug, Eq, PartialEq)]
     22 pub struct FeeEstimate {
     23     pub bytes: usize,
     24     pub fee: Amount,
     25 }
     26 
     27 #[derive(Clone, Debug, Eq, PartialEq)]
     28 pub struct ExternalMineJob {
     29     pub template: StratumMineTemplate,
     30 }
     31 
     32 #[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
     33 #[serde(tag = "type", rename_all = "snake_case")]
     34 pub enum GossipEnvelope {
     35     Hello(ProtocolHello),
     36     PeerStatus {
     37         height: u64,
     38         tip_hash: String,
     39         #[serde(default)]
     40         time_ms: u64,
     41     },
     42     ChainSnapshotRequest,
     43     BlockRangeRequest {
     44         from_height: u64,
     45         limit: usize,
     46     },
     47     BlockRequest {
     48         hashes: Vec<String>,
     49     },
     50     Inventory {
     51         blocks: Vec<BlockInventory>,
     52     },
     53     BlindedTransaction(BlindedTransaction),
     54     BlindedTransactions {
     55         transactions: Vec<BlindedTransaction>,
     56     },
     57     MineAction(Transaction),
     58     MineActions {
     59         transactions: Vec<Transaction>,
     60     },
     61     BlindedReveal(BlindedReveal),
     62     BlindedReveals {
     63         reveals: Vec<BlindedReveal>,
     64     },
     65     RevealBundle(RevealBundle),
     66     RevealBundles {
     67         bundles: Vec<RevealBundle>,
     68     },
     69     Block(Block),
     70     Blocks {
     71         blocks: Vec<Block>,
     72     },
     73     ChainSnapshot(ChainSnapshot),
     74     PeerAnnouncement {
     75         address: String,
     76         #[serde(default)]
     77         node_id: Option<String>,
     78     },
     79     PeerVerificationChallenge {
     80         address: String,
     81         nonce: String,
     82     },
     83     PeerVerificationResponse {
     84         address: String,
     85         nonce: String,
     86         node_id: String,
     87         signature: String,
     88     },
     89     PeerList {
     90         peers: Vec<String>,
     91     },
     92 }
     93 
     94 #[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
     95 pub struct ProtocolHello {
     96     pub protocol_version: u32,
     97     pub network_id: String,
     98     pub genesis_hash: String,
     99     pub listen_addr: Option<String>,
    100     #[serde(default)]
    101     pub node_id: Option<String>,
    102     pub height: u64,
    103     pub tip_hash: String,
    104     #[serde(default)]
    105     pub time_ms: u64,
    106 }
    107 
    108 #[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
    109 pub struct BlockInventory {
    110     pub height: u64,
    111     pub hash: String,
    112 }
    113 
    114 #[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
    115 pub struct NodeStatus {
    116     pub app_version: String,
    117     pub wallet_address: String,
    118     pub wallet_balance: Amount,
    119     pub wallet_locked: bool,
    120     pub launch_profile: LaunchProfileStatus,
    121     pub mining: MiningStatus,
    122     pub stratum: StratumStatus,
    123     pub chain: ChainStatus,
    124 }
    125 
    126 #[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
    127 pub struct LaunchProfileStatus {
    128     pub profile_id: String,
    129     pub profile_hash: String,
    130     pub ticket_maturity_delay_heights: u64,
    131     pub ticket_expiry_window_heights: u64,
    132     pub mine_difficulty_bits: u32,
    133 }
    134 
    135 #[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
    136 pub struct MiningStatus {
    137     pub automatic: bool,
    138     pub pow_mining_enabled: bool,
    139     pub pow_mining_workers: u8,
    140     pub max_pow_mining_workers: u8,
    141     pub burn_per_block: Amount,
    142     pub automatic_burn_fee: Amount,
    143     pub automatic_pow_mine_fee: Amount,
    144     pub last_auto_pow_mine_anchor: Option<String>,
    145     pub last_auto_pow_mine_status: Option<String>,
    146     pub vdf_rounds: u64,
    147     pub vdf_target_block_ms: u64,
    148     pub current_leader: Option<String>,
    149     pub wallet_is_current_leader: bool,
    150     pub last_auto_burn_height: Option<u64>,
    151     pub recovery_vdf_top_rank_percent: u8,
    152 }
    153 
    154 #[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
    155 pub struct StratumStatus {
    156     pub enabled: bool,
    157     pub listen_addr: Option<String>,
    158 }
    159 
    160 #[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
    161 pub struct AutoMineOutcome {
    162     pub pow_mined: Option<Transaction>,
    163     pub burned: Option<Transaction>,
    164     pub block: Option<Block>,
    165     pub skipped_reason: Option<String>,
    166 }
    167 
    168 #[derive(Clone, Debug)]
    169 pub struct AutoMinePlan {
    170     pub pow_mined: Option<Transaction>,
    171     pub burned: Option<Transaction>,
    172     pub work: Option<PreparedBlock>,
    173     pub skipped_reason: Option<String>,
    174 }