mirror of
https://github.com/0glabs/0g-storage-node.git
synced 2024-11-20 15:05:19 +00:00
nit.
This commit is contained in:
parent
ff9810e1ca
commit
deaf224d0f
@ -6,13 +6,13 @@ mod serde;
|
||||
use ::serde::{Deserialize, Serialize};
|
||||
use std::cmp::min;
|
||||
|
||||
use anyhow::{bail, Result};
|
||||
use anyhow::Result;
|
||||
use ethereum_types::H256;
|
||||
use ssz_derive::{Decode, Encode};
|
||||
|
||||
use crate::log_store::log_manager::data_to_merkle_leaves;
|
||||
use crate::try_option;
|
||||
use append_merkle::MerkleTreeRead;
|
||||
use append_merkle::{Algorithm, MerkleTreeRead, Sha3Algorithm};
|
||||
use shared_types::{ChunkArray, DataRoot, Merkle};
|
||||
use tracing::trace;
|
||||
use zgs_spec::{
|
||||
@ -244,15 +244,6 @@ impl EntryBatch {
|
||||
for subtree in self.data.get_subtree_list() {
|
||||
trace!(?subtree, "get subtree, leaves={}", merkle.leaves());
|
||||
if subtree.start_sector != merkle.leaves() {
|
||||
println!(
|
||||
"start_sector={} leaves={}",
|
||||
subtree.start_sector,
|
||||
merkle.leaves()
|
||||
);
|
||||
let subtree_size = 1 << (subtree.subtree_height - 1);
|
||||
if subtree.start_sector % subtree_size != 0 {
|
||||
bail!("error");
|
||||
}
|
||||
let leaf_data = try_option!(
|
||||
self.get_unsealed_data(merkle.leaves(), subtree.start_sector - merkle.leaves())
|
||||
);
|
||||
@ -267,13 +258,13 @@ impl EntryBatch {
|
||||
merkle.append_list(data_to_merkle_leaves(&leaf_data).expect("aligned"));
|
||||
}
|
||||
// TODO(zz): Optimize.
|
||||
// for index in 0..merkle.leaves() {
|
||||
// if merkle.leaf_at(index)?.is_none() {
|
||||
// if let Some(leaf_data) = self.get_unsealed_data(index, 1) {
|
||||
// merkle.fill_leaf(index, Sha3Algorithm::leaf(&leaf_data));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
for index in 0..merkle.leaves() {
|
||||
if merkle.leaf_at(index)?.is_none() {
|
||||
if let Some(leaf_data) = self.get_unsealed_data(index, 1) {
|
||||
merkle.fill_leaf(index, Sha3Algorithm::leaf(&leaf_data));
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(Some(merkle))
|
||||
}
|
||||
}
|
||||
@ -281,9 +272,6 @@ impl EntryBatch {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{EntryBatch, SealAnswer};
|
||||
use crate::log_store::load_chunk::chunk_data::EntryBatchData::Incomplete;
|
||||
use crate::log_store::load_chunk::chunk_data::{IncompleteData, PartialBatch, Subtree};
|
||||
use append_merkle::MerkleTreeRead;
|
||||
use ethereum_types::H256;
|
||||
use zgs_spec::{
|
||||
BYTES_PER_SEAL, BYTES_PER_SECTOR, SEALS_PER_LOAD, SECTORS_PER_LOAD, SECTORS_PER_SEAL,
|
||||
|
Loading…
Reference in New Issue
Block a user