File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -160,9 +160,7 @@ impl Block {
160160
161161 if block_reward != expected_block_reward {
162162 return Err ( anyhow:: anyhow!(
163- "Block reward for coinbase transaction does not match expected block reward: {} != {}" ,
164- block_reward,
165- expected_block_reward
163+ "Block reward for coinbase transaction does not match expected block reward: {block_reward} != {expected_block_reward}"
166164 ) ) ;
167165 }
168166
@@ -264,7 +262,7 @@ mod tests {
264262 } ;
265263
266264 let nonce = header. compute_nonce_naive ( ) . unwrap ( ) ;
267- println ! ( "Found Nonce: {}" , nonce ) ;
265+ println ! ( "Found Nonce: {nonce}" ) ;
268266 header. nonce = nonce;
269267
270268 let hash = header. hash ( ) . unwrap ( ) ;
Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ impl Blockchain {
8383 }
8484
8585 pub fn get_node ( & self , height : u32 ) -> Option < Arc < BlockchainNode > > {
86- self . nodes . get ( & height) . map ( |node| node . clone ( ) )
86+ self . nodes . get ( & height) . cloned ( )
8787 }
8888
8989 pub fn contains_node ( & self , index : & Arc < BlockchainNode > ) -> bool {
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ impl SignatureExt for Signature {
4444 let secp = Secp256k1 :: verification_only ( ) ;
4545 let digest = sha256d ( bytes) ;
4646 let message = Message :: from_digest ( digest) ;
47- secp. verify_ecdsa ( message, & self , & public_key) . is_ok ( )
47+ secp. verify_ecdsa ( message, self , public_key) . is_ok ( )
4848 }
4949}
5050
@@ -75,7 +75,7 @@ struct Sha256dHasher {}
7575impl rs_merkle:: Hasher for Sha256dHasher {
7676 type Hash = [ u8 ; 32 ] ;
7777 fn hash ( data : & [ u8 ] ) -> Self :: Hash {
78- sha256d ( data) . into ( )
78+ sha256d ( data)
7979 }
8080}
8181
Original file line number Diff line number Diff line change @@ -40,11 +40,11 @@ fn hash_string(input: &str, format: ByteDisplay) {
4040 let hash = Sha256 :: digest ( input. as_bytes ( ) ) ;
4141
4242 match format {
43- ByteDisplay :: Hex => println ! ( "Hash (hex): {:#32x}" , hash ) ,
43+ ByteDisplay :: Hex => println ! ( "Hash (hex): {hash :#32x}" ) ,
4444 ByteDisplay :: Base64 => {
4545 let bytes = hash. to_vec ( ) ;
4646 let encoded = base64:: engine:: general_purpose:: STANDARD . encode ( bytes) ;
47- println ! ( "Hash (base64): {}" , encoded ) ;
47+ println ! ( "Hash (base64): {encoded}" ) ;
4848 }
4949 }
5050}
Original file line number Diff line number Diff line change @@ -179,7 +179,7 @@ mod tests {
179179 let keypair_alice = KeyPair :: generate ( ) ;
180180 let address_alice = Address :: from_public_key ( & keypair_alice. public_key ) ;
181181
182- let coinbase_tx = genesis_block. transactions . get ( 0 ) . unwrap ( ) ;
182+ let coinbase_tx = genesis_block. transactions . first ( ) . unwrap ( ) ;
183183
184184 let tx_a_body = TransactionBody {
185185 input : TransactionInput :: Reference ( coinbase_tx. output_reference ( 0 ) . unwrap ( ) ) ,
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ impl std::fmt::Display for TxId {
2424
2525impl std:: fmt:: Debug for TxId {
2626 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
27- write ! ( f, "TxId({})" , self . to_string ( ) )
27+ write ! ( f, "TxId({self })" )
2828 }
2929}
3030
@@ -84,7 +84,7 @@ pub struct SigningInfo {
8484impl SigningInfo {
8585 pub fn sign ( keypair : & KeyPair , bytes : & [ u8 ] ) -> Self {
8686 Self {
87- signature : keypair. sign ( & bytes) ,
87+ signature : keypair. sign ( bytes) ,
8888 public_key : keypair. public_key ,
8989 }
9090 }
@@ -140,10 +140,10 @@ impl Transaction {
140140 } ] ,
141141 } ;
142142
143- body. into_tx ( & keypair)
143+ body. into_tx ( keypair)
144144 }
145145
146- pub fn build_merkle_tree ( transactions : & Vec < Self > ) -> Result < MerkleTree > {
146+ pub fn build_merkle_tree ( transactions : & [ Self ] ) -> Result < MerkleTree > {
147147 let tx_ids = transactions
148148 . iter ( )
149149 . map ( |tx| tx. id ( ) )
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ impl UTXOSet {
1717 let TransactionBody { input, outputs } = & transaction. body ;
1818
1919 if let TransactionInput :: Reference ( reference) = input {
20- let removed = self . outputs . remove ( & reference) ;
20+ let removed = self . outputs . remove ( reference) ;
2121 if removed. is_none ( ) {
2222 return Err ( anyhow:: anyhow!( "Transaction output reference not found" ) ) ;
2323 }
You can’t perform that action at this time.
0 commit comments