Refactored block and transaction structure. Introduced a 'confirmation' entity to avoid block interceptions (at least make them pointless).

This commit is contained in:
Revertron
2021-02-13 23:37:44 +01:00
parent 279b3e87c3
commit 1331f44b0e
9 changed files with 97 additions and 85 deletions
+11 -6
View File
@@ -1,4 +1,4 @@
use crate::{Keystore, Blockchain, Bus};
use crate::{Keystore, Blockchain, Bus, Bytes};
use crate::event::Event;
use std::collections::HashMap;
use serde::{Serialize, Deserialize, Serializer, Deserializer};
@@ -7,9 +7,9 @@ use std::fs::File;
use std::io::Read;
pub struct Context {
pub(crate) settings: Settings,
pub(crate) keystore: Keystore,
pub(crate) blockchain: Blockchain,
pub settings: Settings,
pub keystore: Keystore,
pub blockchain: Blockchain,
pub bus: Bus<Event>,
}
@@ -48,8 +48,8 @@ impl Context {
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Settings {
pub chain_name: String,
pub version_flags: u32,
pub origin: String,
pub version: u32,
pub key_file: String,
pub listen: String,
pub public: bool,
@@ -76,4 +76,9 @@ impl Settings {
Err(..) => None
}
}
pub fn get_origin(&self) -> Bytes {
let origin = crate::from_hex(&self.origin).expect("Wrong origin in settings");
Bytes::from_bytes(origin.as_slice())
}
}