Changed chain id to chain name (it will be a string). Implemented saving blockchain to sqlite DB.

This commit is contained in:
Revertron
2021-01-20 19:23:41 +01:00
parent 70b3a833b9
commit 9e6a01847e
8 changed files with 146 additions and 81 deletions
+12
View File
@@ -31,6 +31,13 @@ impl Transaction {
Transaction { identity, method, data, pub_key, signature: Bytes::zero64() }
}
pub fn from_json(json: &str) -> Option<Self> {
match serde_json::from_str(json) {
Ok(transaction) => Some(transaction),
Err(_) => None
}
}
pub fn set_signature(&mut self, hash: Bytes) {
self.signature = hash;
}
@@ -39,6 +46,11 @@ impl Transaction {
// Let it panic if something is not okay
serde_json::to_vec(&self).unwrap()
}
pub fn to_string(&self) -> String {
// Let it panic if something is not okay
serde_json::to_string(&self).unwrap()
}
}
impl fmt::Debug for Transaction {