Method
new
(txs: String, pre_hash: String, bits: u32)
Source from the content-addressed store, hash-verified
| 21 | |
| 22 | impl Block { |
| 23 | pub fn new(txs: String, pre_hash: String, bits: u32) -> Self { |
| 24 | let time = Utc::now().timestamp(); |
| 25 | let txs_ser = serialize(&txs); |
| 26 | let txs_hash = hash_str(&txs_ser); |
| 27 | |
| 28 | let mut block = Block { |
| 29 | header: BlockHeader { |
| 30 | time: time, |
| 31 | txs_hash: txs_hash, |
| 32 | pre_hash: pre_hash, |
| 33 | bits: bits, |
| 34 | nonce: 0, |
| 35 | }, |
| 36 | tranxs: txs, |
| 37 | hash: "".to_string(), |
| 38 | }; |
| 39 | |
| 40 | let pow = ProofOfWork::new(bits); |
| 41 | pow.run(&mut block); |
| 42 | |
| 43 | block |
| 44 | } |
| 45 | } |
Callers
nothing calls this directly
Tested by
no test coverage detected