@@ -33,6 +33,7 @@ use std::collections::HashMap;
3333use std:: {
3434 cell:: RefCell ,
3535 cmp:: { Ord , Ordering } ,
36+ string:: String ,
3637 sync:: LazyLock ,
3738} ;
3839use thiserror:: Error ;
@@ -226,7 +227,7 @@ struct TileWithBytes {
226227 b : Vec < u8 > ,
227228}
228229
229- /// A fake TileReader that just accumulates the tiles that we'll need for a proof
230+ /// A fake ` TileReader` that just accumulates the tiles that we'll need for a proof
230231#[ derive( Default ) ]
231232struct ProofPreparer ( RefCell < Vec < TlogTile > > ) ;
232233
@@ -241,13 +242,13 @@ impl TileReader for ProofPreparer {
241242 * self . 0 . borrow_mut ( ) = tiles
242243 . iter ( )
243244 . map ( |t| {
244- if t. height ( ) != TlogTile :: HEIGHT {
245+ if t. height ( ) == TlogTile :: HEIGHT {
246+ Ok ( TlogTile :: new ( t. level ( ) , t. level_index ( ) , t. width ( ) , None ) )
247+ } else {
245248 Err ( TlogError :: InvalidInput (
246249 "SimpleTlogTileReader cannot read tiles of height not equal to 8"
247250 . to_string ( ) ,
248251 ) )
249- } else {
250- Ok ( TlogTile :: new ( t. level ( ) , t. level_index ( ) , t. width ( ) , None ) )
251252 }
252253 } )
253254 . collect :: < Result < Vec < _ > , TlogError > > ( ) ?;
@@ -261,7 +262,7 @@ impl TileReader for ProofPreparer {
261262 fn save_tiles ( & self , _tiles : & [ Tile ] , _data : & [ Vec < u8 > ] ) { }
262263}
263264
264- /// A thin wrapper around a map of tlog tile ⇒ bytestring. Implements TileReader
265+ /// A thin wrapper around a map of tlog tile ⇒ bytestring. Implements ` TileReader`
265266/// so we can use it for producing inclusion proofs.
266267struct SimpleTlogTileReader ( HashMap < TlogTile , Vec < u8 > > ) ;
267268
@@ -359,7 +360,7 @@ pub(crate) async fn create_log(
359360 let sth = tree
360361 . sign (
361362 & config. origin ,
362- & extensions. iter ( ) . map ( |e| e . as_str ( ) ) . collect :: < Vec < _ > > ( ) ,
363+ & extensions. iter ( ) . map ( String :: as_str) . collect :: < Vec < _ > > ( ) ,
363364 & dyn_signers,
364365 & mut rand:: thread_rng ( ) ,
365366 )
@@ -538,11 +539,6 @@ impl SequenceState {
538539 } )
539540 }
540541
541- /// Returns the current number of leaves in the tree
542- pub ( crate ) fn num_leaves ( & self ) -> u64 {
543- self . tree . size ( )
544- }
545-
546542 /// Returns the current checkpoint
547543 pub ( crate ) fn checkpoint ( & self ) -> & [ u8 ] {
548544 & self . checkpoint
@@ -983,7 +979,7 @@ async fn sequence_entries<L: LogEntry>(
983979 let new_checkpoint = tree
984980 . sign (
985981 & config. origin ,
986- & extensions. iter ( ) . map ( |e| e . as_str ( ) ) . collect :: < Vec < _ > > ( ) ,
982+ & extensions. iter ( ) . map ( String :: as_str) . collect :: < Vec < _ > > ( ) ,
987983 & dyn_signers,
988984 & mut rand:: thread_rng ( ) ,
989985 )
@@ -1422,7 +1418,7 @@ mod tests {
14221418 fn sequence_one_leaf ( n : u64 ) {
14231419 let mut log = TestLog :: new ( ) ;
14241420 for i in 0 ..n {
1425- let old_tree_hash = log. sequence_state . as_ref ( ) . map ( |s| s. tree . hash ( ) . clone ( ) ) ;
1421+ let old_tree_hash = log. sequence_state . as_ref ( ) . map ( |s| * s. tree . hash ( ) ) ;
14261422
14271423 let res = log. add_certificate ( ) ;
14281424 log. sequence ( ) . unwrap ( ) ;
@@ -1456,7 +1452,7 @@ mod tests {
14561452 tree_size - 1 ,
14571453 old_tree_hash. unwrap ( ) ,
14581454 )
1459- . unwrap ( )
1455+ . unwrap ( ) ;
14601456 }
14611457 }
14621458 // Check that the static CT log is valid
@@ -1476,7 +1472,7 @@ mod tests {
14761472 . unwrap ( )
14771473 . unwrap ( ) ;
14781474 // Extract the correct hash from the tile
1479- let leaf_tile_idx = ( i % TlogTile :: FULL_WIDTH as u64 ) as usize ;
1475+ let leaf_tile_idx = usize :: try_from ( i % u64 :: from ( TlogTile :: FULL_WIDTH ) ) . unwrap ( ) ;
14801476 Hash (
14811477 leaf_tile_data[ HASH_SIZE * leaf_tile_idx..HASH_SIZE * ( leaf_tile_idx + 1 ) ]
14821478 . try_into ( )
0 commit comments