mirror of
https://github.com/serai-dex/serai.git
synced 2025-02-02 03:06:31 +00:00
Slight merkle improvements
This commit is contained in:
parent
4d17b922fe
commit
90f67b5e54
1 changed files with 2 additions and 6 deletions
|
@ -9,7 +9,7 @@ pub(crate) fn merkle(hash_args: &[[u8; 32]]) -> [u8; 32] {
|
|||
let zero = [0; 32];
|
||||
let mut interim;
|
||||
while hashes.len() > 1 {
|
||||
interim = Vec::with_capacity(hashes.len() / 2);
|
||||
interim = Vec::with_capacity((hashes.len() + 1) / 2);
|
||||
|
||||
let mut i = 0;
|
||||
while i < hashes.len() {
|
||||
|
@ -33,9 +33,5 @@ pub(crate) fn merkle(hash_args: &[[u8; 32]]) -> [u8; 32] {
|
|||
hashes = interim;
|
||||
}
|
||||
|
||||
let mut res = zero;
|
||||
if let Some(hash) = hashes.get(0) {
|
||||
res.copy_from_slice(hash.as_ref());
|
||||
}
|
||||
res
|
||||
hashes.get(0).copied().map(Into::into).unwrap_or(zero)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue