forked from Deuxfleurs/garage
whoops
This commit is contained in:
parent
3f7a496355
commit
1ec49980ec
2 changed files with 11 additions and 2 deletions
|
@ -50,7 +50,7 @@ pub(crate) struct MerkleUpdater {
|
||||||
empty_node_hash: Hash,
|
empty_node_hash: Hash,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
pub struct MerkleNodeKey {
|
pub struct MerkleNodeKey {
|
||||||
// partition: first 16 bits (two bytes) of the partition_key's hash
|
// partition: first 16 bits (two bytes) of the partition_key's hash
|
||||||
pub partition: MerklePartition,
|
pub partition: MerklePartition,
|
||||||
|
@ -283,6 +283,7 @@ impl MerkleUpdater {
|
||||||
k: &MerkleNodeKey,
|
k: &MerkleNodeKey,
|
||||||
v: &MerkleNode,
|
v: &MerkleNode,
|
||||||
) -> ConflictableTransactionResult<Hash, Error> {
|
) -> ConflictableTransactionResult<Hash, Error> {
|
||||||
|
trace!("Put Merkle node: {:?} => {:?}", k, v);
|
||||||
if *v == MerkleNode::Empty {
|
if *v == MerkleNode::Empty {
|
||||||
tx.remove(k.encode())?;
|
tx.remove(k.encode())?;
|
||||||
Ok(self.empty_node_hash)
|
Ok(self.empty_node_hash)
|
||||||
|
|
|
@ -370,6 +370,14 @@ where
|
||||||
must_exit: watch::Receiver<bool>,
|
must_exit: watch::Receiver<bool>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let root_ck = self.get_root_ck(partition.range)?;
|
let root_ck = self.get_root_ck(partition.range)?;
|
||||||
|
if root_ck.is_empty() {
|
||||||
|
debug!(
|
||||||
|
"({}) Sync {:?} with {:?}: partition is empty.",
|
||||||
|
self.data.name, partition, who
|
||||||
|
);
|
||||||
|
return Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
let root_ck_hash = hash_of(&root_ck)?;
|
let root_ck_hash = hash_of(&root_ck)?;
|
||||||
|
|
||||||
// If their root checksum has level > than us, use that as a reference
|
// If their root checksum has level > than us, use that as a reference
|
||||||
|
@ -637,7 +645,7 @@ fn join_ordered<'a, K: Ord + Eq, V1, V2>(
|
||||||
ret.push((&x[i].0, Some(&x[i].1), None));
|
ret.push((&x[i].0, Some(&x[i].1), None));
|
||||||
i += 1;
|
i += 1;
|
||||||
} else if j < y.len() && (i == x.len() || x[i].0 > y[j].0) {
|
} else if j < y.len() && (i == x.len() || x[i].0 > y[j].0) {
|
||||||
ret.push((&x[i].0, None, Some(&y[j].1)));
|
ret.push((&y[j].0, None, Some(&y[j].1)));
|
||||||
j += 1;
|
j += 1;
|
||||||
} else {
|
} else {
|
||||||
unreachable!();
|
unreachable!();
|
||||||
|
|
Loading…
Reference in a new issue