MCPcopy Create free account
hub / github.com/QMHTMY/RustBook / new

Method new

code/chapter09/blockchain/blockchain4/core/src/transaction.rs:17–33  ·  view source on GitHub ↗
(from: String, to: String,
               amount: u64, fee: u64,
               nonce: u64, sign: String)

Source from the content-addressed store, hash-verified

15
16impl Transaction {
17 pub fn new(from: String, to: String,
18 amount: u64, fee: u64,
19 nonce: u64, sign: String) -> Self
20 {
21 let mut tx = Transaction {
22 nonce,
23 amount,
24 fee,
25 from,
26 to,
27 sign,
28 hash:"".to_string(),
29 };
30 tx.set_hash();
31
32 tx
33 }
34
35 pub fn set_hash(&mut self) {
36 let txs_ser = serialize(&self);

Callers

nothing calls this directly

Calls 2

to_stringMethod · 0.45
set_hashMethod · 0.45

Tested by

no test coverage detected