fix: change usize to u64 for compatibility

This commit is contained in:
Magamedrasul Ibragimov 2022-12-09 16:35:21 +03:00
parent 14d58fdf45
commit 8c4abe6fa1
1 changed files with 3 additions and 3 deletions

View File

@ -3,10 +3,10 @@ use std::cmp::max;
use std::marker::PhantomData;
// db[DEPTH_KEY] = depth
const DEPTH_KEY: DBKey = (usize::MAX - 1).to_be_bytes();
const DEPTH_KEY: DBKey = (u64::MAX - 1).to_be_bytes();
// db[NEXT_INDEX_KEY] = next_index;
const NEXT_INDEX_KEY: DBKey = usize::MAX.to_be_bytes();
const NEXT_INDEX_KEY: DBKey = u64::MAX.to_be_bytes();
// Denotes keys (depth, index) in Merkle Tree. Can be converted to DBKey
// TODO! Think about using hashing for that
@ -14,7 +14,7 @@ const NEXT_INDEX_KEY: DBKey = usize::MAX.to_be_bytes();
struct Key(usize, usize);
impl From<Key> for DBKey {
fn from(key: Key) -> Self {
let cantor_pairing = (key.0 + key.1) * (key.0 + key.1 + 1) / 2 + key.1;
let cantor_pairing = ((key.0 + key.1) * (key.0 + key.1 + 1) / 2 + key.1) as u64;
cantor_pairing.to_be_bytes()
}
}