aboutsummaryrefslogtreecommitdiffstats
path: root/src/schema.rs
diff options
context:
space:
mode:
authorYigit Sever2021-04-14 00:34:39 +0300
committerYigit Sever2021-04-14 00:34:39 +0300
commitfc9aa0c69b11f6ec93255b984839e0c2418a63cf (patch)
treece51fc4cbf82ec1e375d5cf33a54c4ba4d0b1bbe /src/schema.rs
parentec6bcf166032d0820716189308020c2b2d1faa67 (diff)
downloadgradecoin-fc9aa0c69b11f6ec93255b984839e0c2418a63cf.tar.gz
gradecoin-fc9aa0c69b11f6ec93255b984839e0c2418a63cf.tar.bz2
gradecoin-fc9aa0c69b11f6ec93255b984839e0c2418a63cf.zip
Add empty block test
Diffstat (limited to 'src/schema.rs')
-rw-r--r--src/schema.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/schema.rs b/src/schema.rs
index b07744a..6719722 100644
--- a/src/schema.rs
+++ b/src/schema.rs
@@ -92,6 +92,7 @@ pub struct Transaction {
92/// 92///
93#[derive(Serialize, Deserialize, Debug)] 93#[derive(Serialize, Deserialize, Debug)]
94pub struct Block { 94pub struct Block {
95 #[serde(skip_serializing_if = "Vec::is_empty")]
95 pub transaction_list: Vec<PublicKeySignature>, 96 pub transaction_list: Vec<PublicKeySignature>,
96 pub nonce: u32, 97 pub nonce: u32,
97 pub timestamp: NaiveDateTime, 98 pub timestamp: NaiveDateTime,
@@ -101,6 +102,7 @@ pub struct Block {
101/// For prototyping and letting serde handle everything json 102/// For prototyping and letting serde handle everything json
102#[derive(Serialize, Deserialize, Debug)] 103#[derive(Serialize, Deserialize, Debug)]
103pub struct NakedBlock { 104pub struct NakedBlock {
105 #[serde(skip_serializing_if = "Vec::is_empty", default)]
104 pub transaction_list: Vec<PublicKeySignature>, 106 pub transaction_list: Vec<PublicKeySignature>,
105 pub nonce: u32, 107 pub nonce: u32,
106 pub timestamp: NaiveDateTime, 108 pub timestamp: NaiveDateTime,
@@ -110,10 +112,10 @@ impl Block {
110 /// Genesis block 112 /// Genesis block
111 pub fn new() -> Block { 113 pub fn new() -> Block {
112 Block { 114 Block {
113 transaction_list: vec![], 115 transaction_list: vec!["gradecoin_bank".to_owned()],
114 nonce: 0, 116 nonce: 0,
115 timestamp: NaiveDate::from_ymd(2021, 04, 11).and_hms(20, 45, 00), 117 timestamp: NaiveDate::from_ymd(2021, 04, 11).and_hms(20, 45, 00),
116 hash: String::from(""), 118 hash: String::from("not_actually_mined"),
117 } 119 }
118 } 120 }
119} 121}