File tree Expand file tree Collapse file tree 3 files changed +13
-9
lines changed Expand file tree Collapse file tree 3 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -488,7 +488,7 @@ impl BurnchainHeaderHash {
488
488
}
489
489
490
490
pub fn to_bitcoin_hash ( & self ) -> Sha256dHash {
491
- let mut buf = self . 0 . clone ( ) ;
491
+ let mut buf = self . 0 ;
492
492
buf. reverse ( ) ;
493
493
Sha256dHash ( buf)
494
494
}
Original file line number Diff line number Diff line change @@ -157,14 +157,19 @@ impl SortitionHash {
157
157
}
158
158
159
159
/// Convert a SortitionHash into a (little-endian) uint256
160
- #[ allow( clippy:: indexing_slicing) ]
161
160
pub fn to_uint256 ( & self ) -> Uint256 {
162
- let mut tmp = [ 0u64 ; 4 ] ;
163
- for i in 0 ..4 {
164
- let b: & [ u8 ; 8 ] = & self . 0 [ 8 * i..8 * ( i + 1 ) ] . try_into ( ) . unwrap ( ) ;
165
- tmp[ i] = u64:: from_le_bytes ( * b) ;
166
- }
167
- Uint256 ( tmp)
161
+ let ( u64_chunks, [ ] ) = self . 0 . as_chunks :: < 8 > ( ) else {
162
+ panic ! ( "SortitionHash was not evenly divisible by 8" )
163
+ } ;
164
+
165
+ let tmp: Vec < u64 > = u64_chunks
166
+ . iter ( )
167
+ . map ( |chunk| u64:: from_le_bytes ( * chunk) )
168
+ . collect ( ) ;
169
+ Uint256 (
170
+ tmp. try_into ( )
171
+ . expect ( "SortitionHash should have 4 chunks of 8 bytes" ) ,
172
+ )
168
173
}
169
174
}
170
175
Original file line number Diff line number Diff line change @@ -853,7 +853,6 @@ impl Trie {
853
853
storage : & mut TrieStorageConnection < T > ,
854
854
children_root_hash : & TrieHash ,
855
855
) -> Result < TrieHash , Error > {
856
- let hashes = Trie :: get_trie_root_ancestor_hashes_bytes ( storage, children_root_hash) ?;
857
856
let hashes = Trie :: get_trie_root_ancestor_hashes_bytes ( storage, children_root_hash) ?;
858
857
match hashes. as_slice ( ) {
859
858
[ single_hash] => Ok ( * single_hash) ,
You can’t perform that action at this time.
0 commit comments