@@ -35,7 +35,7 @@ pub struct BlockTimeStamp(pub i64);
3535pub struct PreviousBlockHash ( pub Vec < u8 > ) ;
3636
3737/// unique identifier of the ledger type.
38- /// In general, this is the way to strictly bound and specify block_data of the ledger for the specific ledger_type.
38+ /// In general, this is the way to strictly bound and specify ` block_data` of the ledger for the specific ` ledger_type` .
3939#[ derive( Debug , Clone , PartialEq ) ]
4040pub struct LedgerType ( pub Uuid ) ;
4141
@@ -106,7 +106,7 @@ pub type DecodedBlockGenesis = (
106106/// Encoded whole block including block header, cbor encoded block data and signatures.
107107pub type EncodedBlock = Vec < u8 > ;
108108
109- /// Encoded genesis block, see genesis_to_prev_hash
109+ /// Encoded genesis block, see ` genesis_to_prev_hash`
110110pub type EncodedGenesisBlock = Vec < u8 > ;
111111
112112/// Choice of hash function:
@@ -140,7 +140,7 @@ pub fn encode_block(
140140 . 0
141141 . iter ( )
142142 . map ( |sk| {
143- let mut sk: SigningKey = SigningKey :: from_bytes ( & sk) ;
143+ let mut sk: SigningKey = SigningKey :: from_bytes ( sk) ;
144144 sk. sign ( & data_to_sign) . to_bytes ( )
145145 } )
146146 . collect ( ) ;
@@ -150,11 +150,11 @@ pub fn encode_block(
150150
151151 encoder. bytes ( & block_data. 0 ) ?;
152152
153- for sig in signatures. iter ( ) {
153+ for sig in & signatures {
154154 encoder. bytes ( sig) ?;
155155 }
156156
157- let block_data_with_sigs = encoder. writer ( ) . to_vec ( ) ;
157+ let block_data_with_sigs = encoder. writer ( ) . clone ( ) ;
158158 // block hdr + block data + sigs
159159 let encoded_block = [ block_hdr_cbor, block_data_with_sigs] . concat ( ) ;
160160
@@ -217,21 +217,21 @@ pub fn encode_block_header(
217217 encoder. bytes ( & chain_id. 0 . to_bytes ( ) ) ?;
218218 encoder. bytes ( & height. 0 . to_be_bytes ( ) ) ?;
219219 encoder. bytes ( & ts. 0 . to_be_bytes ( ) ) ?;
220- encoder. bytes ( & prev_block_hash. 0 . as_slice ( ) ) ?;
220+ encoder. bytes ( prev_block_hash. 0 . as_slice ( ) ) ?;
221221 encoder. bytes ( ledger_type. 0 . as_bytes ( ) ) ?;
222222 encoder. bytes ( & pid. 0 . to_bytes ( ) ) ?;
223223
224224 // marks how many validators for decoding side.
225225 encoder. bytes ( & validator. 0 . len ( ) . to_be_bytes ( ) ) ?;
226- for validator in validator. 0 . iter ( ) {
226+ for validator in & validator. 0 {
227227 encoder. bytes ( & validator. 0 ) ?;
228228 }
229229
230230 if let Some ( meta) = metadata {
231231 encoder. bytes ( & meta. 0 ) ?;
232232 }
233233
234- Ok ( encoder. writer ( ) . to_vec ( ) )
234+ Ok ( encoder. writer ( ) . clone ( ) )
235235}
236236
237237/// Decode block header
@@ -343,12 +343,12 @@ pub fn encode_genesis(
343343
344344 // marks how many validators for decoding side.
345345 encoder. bytes ( & validator. 0 . len ( ) . to_be_bytes ( ) ) ?;
346- for validator in validator. 0 . iter ( ) {
346+ for validator in & validator. 0 {
347347 encoder. bytes ( & validator. 0 ) ?;
348348 }
349349
350350 // Get hash of the genesis_to_prev_hash bytes i.e hash of itself
351- let genesis_prev_bytes = encoder. writer ( ) . to_vec ( ) ;
351+ let genesis_prev_bytes = encoder. writer ( ) . clone ( ) ;
352352
353353 // Size of encoded contents which is hashed
354354 encoder. bytes ( & genesis_prev_bytes. len ( ) . to_be_bytes ( ) ) ?;
@@ -360,9 +360,9 @@ pub fn encode_genesis(
360360
361361 // prev_block_id for the Genesis block MUST be a hash of the genesis_to_prev_hash bytes
362362 // last 64 bytes (depending on given hash function) of encoding are the hash of the genesis contents
363- encoder. bytes ( & genesis_prev_hash. as_slice ( ) ) ?;
363+ encoder. bytes ( genesis_prev_hash. as_slice ( ) ) ?;
364364
365- Ok ( encoder. writer ( ) . to_vec ( ) )
365+ Ok ( encoder. writer ( ) . clone ( ) )
366366}
367367
368368/// Decode genesis
@@ -494,7 +494,7 @@ mod tests {
494494
495495 let chain_id = ChainId ( Ulid :: new ( ) ) ;
496496 let block_height = Height ( 5 ) ;
497- let block_ts = BlockTimeStamp ( 1728474515 ) ;
497+ let block_ts = BlockTimeStamp ( 1_728_474_515 ) ;
498498 let prev_block_height = PreviousBlockHash ( vec ! [ 0 ; 64 ] ) ;
499499 let ledger_type = LedgerType ( Uuid :: new_v4 ( ) ) ;
500500 let purpose_id = PurposeId ( Ulid :: new ( ) ) ;
@@ -538,7 +538,7 @@ mod tests {
538538
539539 let chain_id = ChainId ( Ulid :: new ( ) ) ;
540540 let block_height = Height ( 5 ) ;
541- let block_ts = BlockTimeStamp ( 1728474515 ) ;
541+ let block_ts = BlockTimeStamp ( 1_728_474_515 ) ;
542542 let prev_block_height = PreviousBlockHash ( vec ! [ 0 ; 64 ] ) ;
543543 let ledger_type = LedgerType ( Uuid :: new_v4 ( ) ) ;
544544 let purpose_id = PurposeId ( Ulid :: new ( ) ) ;
0 commit comments