fix out of boudns
This commit is contained in:
@@ -11,7 +11,7 @@ pub fn parse_received_datum(
|
||||
datum_length: usize,
|
||||
) -> Option<([u8; 32], MerkleNode)> {
|
||||
let hash_name: [u8; 32] = recevied_datum[..32].try_into().expect("error");
|
||||
let value = &recevied_datum[32..datum_length];
|
||||
let value = &recevied_datum[32..recevied_datum.len()];
|
||||
let value_slice = value.to_vec();
|
||||
println!("valueslice: {:?}, {}", value_slice, value_slice.len());
|
||||
let datum_type = value_slice[0];
|
||||
@@ -49,12 +49,22 @@ pub fn parse_received_datum(
|
||||
}
|
||||
}
|
||||
BIG => {
|
||||
let mut bigdir_entries: Vec<NodeHash> = Vec::new();
|
||||
let mut offset = 1 as usize;
|
||||
for i in 0..((value_slice.len() - 1) / 32) as u8 {
|
||||
offset = (1 + 32 * i as usize) as usize;
|
||||
println!("offset:{}, i:{}", offset, i);
|
||||
let hash = &value_slice[offset..offset + 32];
|
||||
|
||||
// envoyer un datum request
|
||||
bigdir_entries.push(hash.try_into().expect("incorrect size"));
|
||||
}
|
||||
|
||||
println!("its a BIG bro");
|
||||
let chlidren: Vec<NodeHash> = Vec::new();
|
||||
Some((
|
||||
hash_name,
|
||||
MerkleNode::Big(crate::BigNode {
|
||||
children_hashes: chlidren,
|
||||
children_hashes: bigdir_entries,
|
||||
}),
|
||||
))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user