1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
pub mod mux;
pub mod protocols;
use std::io;
pub trait Protocol {
fn protocol_id(&self) -> u16;
fn result(&self) -> Result<String, String>;
fn role(&self) -> Agency;
fn agency(&self) -> Agency;
fn state(&self) -> String;
fn send_data(&mut self) -> Option<Vec<u8>>;
fn receive_data(&mut self, data: Vec<u8>);
}
#[derive(Debug, PartialEq, Copy, Clone)]
pub enum Agency {
Client,
Server,
None,
}
pub trait BlockStore {
fn save_block(&mut self, pending_blocks: &mut Vec<BlockHeader>, network_magic: u32) -> io::Result<()>;
fn load_blocks(&mut self) -> Option<Vec<(i64, Vec<u8>)>>;
}
#[derive(Debug, Clone)]
pub struct BlockHeader {
pub block_number: i64,
pub slot_number: i64,
pub hash: Vec<u8>,
pub prev_hash: Vec<u8>,
pub node_vkey: Vec<u8>,
pub node_vrf_vkey: Vec<u8>,
pub eta_vrf_0: Vec<u8>,
pub eta_vrf_1: Vec<u8>,
pub leader_vrf_0: Vec<u8>,
pub leader_vrf_1: Vec<u8>,
pub block_size: i64,
pub block_body_hash: Vec<u8>,
pub pool_opcert: Vec<u8>,
pub unknown_0: i64,
pub unknown_1: i64,
pub unknown_2: Vec<u8>,
pub protocol_major_version: i64,
pub protocol_minor_version: i64,
}