Changed and refactored block and transaction structures. Moved signature from transaction scope to block.

This commit is contained in:
Revertron
2021-03-02 18:11:17 +01:00
parent d5a19c92c3
commit 92ebefce91
11 changed files with 206 additions and 215 deletions
+20
View File
@@ -16,6 +16,8 @@ use serde::de::{Error as DeError, Visitor};
#[allow(unused_imports)]
use log::{trace, debug, info, warn, error};
use crate::hash_is_good;
use std::cmp::Ordering;
use num_bigint::BigUint;
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Keystore {
@@ -160,6 +162,24 @@ impl PartialEq for Bytes {
}
}
impl Eq for Bytes {}
impl PartialOrd for Bytes {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
let self_hash_int = BigUint::from_bytes_be(&self.data);
let other_hash_int = BigUint::from_bytes_be(&other.data);
Some(self_hash_int.cmp(&other_hash_int))
}
}
impl Ord for Bytes {
fn cmp(&self, other: &Self) -> Ordering {
let self_hash_int = BigUint::from_bytes_be(&self.data);
let other_hash_int = BigUint::from_bytes_be(&other.data);
self_hash_int.cmp(&other_hash_int)
}
}
impl fmt::Debug for Bytes {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt.write_str(&crate::utils::to_hex(&self.data))