MCPcopy Create free account
hub / github.com/ddimaria/rust-blockchain-tutorial / new_transaction

Function new_transaction

chain/src/blockchain.rs:297–314  ·  view source on GitHub ↗
(
        to: Account,
        blockchain: Arc<Mutex<BlockChain>>,
    )

Source from the content-addressed store, hash-verified

295 }
296
297 pub(crate) async fn new_transaction(
298 to: Account,
299 blockchain: Arc<Mutex<BlockChain>>,
300 ) -> Transaction {
301 let nonce = blockchain
302 .lock()
303 .await
304 .accounts
305 .get_account(&ACCOUNT_1)
306 .unwrap_or(AccountData::new(None))
307 .nonce
308 + 1;
309
310 let transaction =
311 Transaction::new(*ACCOUNT_1, Some(to), U256::from(10), Some(nonce), None).unwrap();
312
313 transaction
314 }
315
316 pub(crate) async fn process_transactions(blockchain: Arc<Mutex<BlockChain>>) {
317 blockchain

Callers 5

creates_and_gets_a_blockFunction · 0.70
sends_a_transactionFunction · 0.70
send_a_raw_transactionFunction · 0.70
sends_a_transactionFunction · 0.70

Calls 1

get_accountMethod · 0.80

Tested by

no test coverage detected