mirror of
https://github.com/0glabs/0g-storage-node.git
synced 2024-11-20 15:05:19 +00:00
range root should also add back missing padded data
This commit is contained in:
parent
7e19cd7e94
commit
522900ec32
@ -491,16 +491,15 @@ impl FlowDBStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if expected_index == batch_index {
|
} else {
|
||||||
|
while batch_index > expected_index {
|
||||||
|
// Fill the gap with empty leaves.
|
||||||
|
root_list.push((1, empty_root));
|
||||||
|
expected_index += 1;
|
||||||
|
}
|
||||||
range_root = Some(BatchRoot::Multiple((subtree_depth, root)));
|
range_root = Some(BatchRoot::Multiple((subtree_depth, root)));
|
||||||
root_list.push((subtree_depth, root));
|
root_list.push((subtree_depth, root));
|
||||||
expected_index += 1 << (subtree_depth - 1);
|
expected_index += 1 << (subtree_depth - 1);
|
||||||
} else {
|
|
||||||
bail!(
|
|
||||||
"unexpected range root: expected={} get={}",
|
|
||||||
expected_index,
|
|
||||||
batch_index
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let extra_node_list = self.get_mpt_node_list()?;
|
let extra_node_list = self.get_mpt_node_list()?;
|
||||||
|
@ -50,7 +50,7 @@ const PAD_MAX_SIZE: usize = 1 << 20;
|
|||||||
|
|
||||||
pub struct UpdateFlowMessage {
|
pub struct UpdateFlowMessage {
|
||||||
pub root_map: BTreeMap<usize, (H256, usize)>,
|
pub root_map: BTreeMap<usize, (H256, usize)>,
|
||||||
pub pad_data: Vec<u8>,
|
pub pad_data: usize,
|
||||||
pub tx_start_flow_index: u64,
|
pub tx_start_flow_index: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -760,7 +760,7 @@ impl LogManager {
|
|||||||
|
|
||||||
fn start_receiver(&mut self, rx: mpsc::Receiver<UpdateFlowMessage>) {
|
fn start_receiver(&mut self, rx: mpsc::Receiver<UpdateFlowMessage>) {
|
||||||
let flow_store = self.flow_store.clone();
|
let flow_store = self.flow_store.clone();
|
||||||
thread::spawn(move || -> Result<(), anyhow::Error> {
|
let handle = thread::spawn(move || -> Result<(), anyhow::Error> {
|
||||||
loop {
|
loop {
|
||||||
match rx.recv() {
|
match rx.recv() {
|
||||||
std::result::Result::Ok(data) => {
|
std::result::Result::Ok(data) => {
|
||||||
@ -771,7 +771,7 @@ impl LogManager {
|
|||||||
// subtrees with data known.
|
// subtrees with data known.
|
||||||
flow_store
|
flow_store
|
||||||
.append_entries(ChunkArray {
|
.append_entries(ChunkArray {
|
||||||
data: data.pad_data,
|
data: vec![0; data.pad_data],
|
||||||
start_index: data.tx_start_flow_index,
|
start_index: data.tx_start_flow_index,
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@ -782,6 +782,8 @@ impl LogManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// Wait for the spawned thread to finish
|
||||||
|
let _ = handle.join().expect("Thread panicked");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gen_proof(&self, flow_index: u64, maybe_root: Option<DataRoot>) -> Result<FlowProof> {
|
fn gen_proof(&self, flow_index: u64, maybe_root: Option<DataRoot>) -> Result<FlowProof> {
|
||||||
@ -974,7 +976,7 @@ impl LogManager {
|
|||||||
if is_full_empty {
|
if is_full_empty {
|
||||||
self.sender.send(UpdateFlowMessage {
|
self.sender.send(UpdateFlowMessage {
|
||||||
root_map,
|
root_map,
|
||||||
pad_data: pad_data.to_vec(),
|
pad_data: pad_data.len(),
|
||||||
tx_start_flow_index,
|
tx_start_flow_index,
|
||||||
})?;
|
})?;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user