mirror of
https://github.com/0glabs/0g-storage-node.git
synced 2025-11-03 08:07:27 +00:00
remove unnecessary code
This commit is contained in:
parent
b900b9c48d
commit
da3c16a533
@ -259,11 +259,8 @@ impl<E: HashElement, A: Algorithm<E>> AppendMerkleTree<E, A> {
|
|||||||
}
|
}
|
||||||
self.node_manager.start_transaction();
|
self.node_manager.start_transaction();
|
||||||
let start_index = self.leaves();
|
let start_index = self.leaves();
|
||||||
println!("append_subtree_inner");
|
|
||||||
self.append_subtree_inner(subtree_depth, subtree_root)?;
|
self.append_subtree_inner(subtree_depth, subtree_root)?;
|
||||||
println!("recompute");
|
|
||||||
self.recompute_after_append_subtree(start_index, subtree_depth - 1);
|
self.recompute_after_append_subtree(start_index, subtree_depth - 1);
|
||||||
println!("commit");
|
|
||||||
self.node_manager.commit();
|
self.node_manager.commit();
|
||||||
metrics::APPEND_SUBTREE.update_since(start_time);
|
metrics::APPEND_SUBTREE.update_since(start_time);
|
||||||
|
|
||||||
|
|||||||
@ -117,7 +117,7 @@ impl AsMut<[u8]> for OptionalHash {
|
|||||||
|
|
||||||
impl Encode for OptionalHash {
|
impl Encode for OptionalHash {
|
||||||
fn is_ssz_fixed_len() -> bool {
|
fn is_ssz_fixed_len() -> bool {
|
||||||
true
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ssz_fixed_len() -> usize {
|
fn ssz_fixed_len() -> usize {
|
||||||
@ -144,7 +144,7 @@ impl Encode for OptionalHash {
|
|||||||
|
|
||||||
impl Decode for OptionalHash {
|
impl Decode for OptionalHash {
|
||||||
fn is_ssz_fixed_len() -> bool {
|
fn is_ssz_fixed_len() -> bool {
|
||||||
true
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ssz_fixed_len() -> usize {
|
fn ssz_fixed_len() -> usize {
|
||||||
|
|||||||
@ -946,18 +946,12 @@ impl LogManager {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
let start_time = Instant::now();
|
let start_time = Instant::now();
|
||||||
println!(
|
|
||||||
"append_subtree_list: tx_seq={} tx_start_index={} merkle_list={:?}",
|
|
||||||
tx_seq, tx_start_index, merkle_list
|
|
||||||
);
|
|
||||||
|
|
||||||
self.pad_tx(tx_seq, tx_start_index, &mut *merkle)?;
|
self.pad_tx(tx_seq, tx_start_index, &mut *merkle)?;
|
||||||
|
|
||||||
for (subtree_depth, subtree_root) in merkle_list {
|
for (subtree_depth, subtree_root) in merkle_list {
|
||||||
let subtree_size = 1 << (subtree_depth - 1);
|
let subtree_size = 1 << (subtree_depth - 1);
|
||||||
println!("append new subtree to pora_chunks_merkle");
|
|
||||||
if merkle.last_chunk_merkle.leaves() + subtree_size <= PORA_CHUNK_SIZE {
|
if merkle.last_chunk_merkle.leaves() + subtree_size <= PORA_CHUNK_SIZE {
|
||||||
println!("append to last_chunk_");
|
|
||||||
merkle
|
merkle
|
||||||
.last_chunk_merkle
|
.last_chunk_merkle
|
||||||
.append_subtree(subtree_depth, OptionalHash::some(subtree_root))?;
|
.append_subtree(subtree_depth, OptionalHash::some(subtree_root))?;
|
||||||
@ -979,7 +973,6 @@ impl LogManager {
|
|||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
println!("append to pora_chunks_");
|
|
||||||
// `last_chunk_merkle` has been padded here, so a subtree should not be across
|
// `last_chunk_merkle` has been padded here, so a subtree should not be across
|
||||||
// the chunks boundary.
|
// the chunks boundary.
|
||||||
assert_eq!(merkle.last_chunk_merkle.leaves(), 0);
|
assert_eq!(merkle.last_chunk_merkle.leaves(), 0);
|
||||||
@ -990,12 +983,7 @@ impl LogManager {
|
|||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
println!(
|
|
||||||
"after append_subtree_list: tx_seq={} tx_start_index={} last_chunk={}",
|
|
||||||
tx_seq,
|
|
||||||
tx_start_index,
|
|
||||||
merkle.last_chunk_merkle.leaves()
|
|
||||||
);
|
|
||||||
metrics::APPEND_SUBTREE_LIST.update_since(start_time);
|
metrics::APPEND_SUBTREE_LIST.update_since(start_time);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@ -168,7 +168,6 @@ fn test_revert() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_put_tx() {
|
fn test_put_tx() {
|
||||||
for i in 0..12 {
|
for i in 0..12 {
|
||||||
println!("{}", i);
|
|
||||||
let chunk_count = 0xF << i;
|
let chunk_count = 0xF << i;
|
||||||
let mut store = create_store();
|
let mut store = create_store();
|
||||||
put_tx(&mut store, chunk_count, 0);
|
put_tx(&mut store, chunk_count, 0);
|
||||||
@ -201,9 +200,7 @@ fn put_tx(store: &mut LogManager, chunk_count: usize, seq: u64) {
|
|||||||
// TODO: This can come from `tx_merkle`.
|
// TODO: This can come from `tx_merkle`.
|
||||||
merkle_nodes,
|
merkle_nodes,
|
||||||
};
|
};
|
||||||
println!("put tx");
|
|
||||||
store.put_tx(tx.clone()).unwrap();
|
store.put_tx(tx.clone()).unwrap();
|
||||||
println!("put tx done");
|
|
||||||
for start_index in (0..chunk_count).step_by(PORA_CHUNK_SIZE) {
|
for start_index in (0..chunk_count).step_by(PORA_CHUNK_SIZE) {
|
||||||
let end = cmp::min((start_index + PORA_CHUNK_SIZE) * CHUNK_SIZE, data.len());
|
let end = cmp::min((start_index + PORA_CHUNK_SIZE) * CHUNK_SIZE, data.len());
|
||||||
let chunk_array = ChunkArray {
|
let chunk_array = ChunkArray {
|
||||||
@ -212,6 +209,5 @@ fn put_tx(store: &mut LogManager, chunk_count: usize, seq: u64) {
|
|||||||
};
|
};
|
||||||
store.put_chunks(tx.seq, chunk_array.clone()).unwrap();
|
store.put_chunks(tx.seq, chunk_array.clone()).unwrap();
|
||||||
}
|
}
|
||||||
println!("put chunks done");
|
|
||||||
store.finalize_tx(tx.seq).unwrap();
|
store.finalize_tx(tx.seq).unwrap();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user