diff options
author | Alex Auvolat <alex@adnab.me> | 2021-04-05 19:55:53 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2021-04-05 19:55:53 +0200 |
commit | 0eb5baea1a8e23fd373685f40aa32a84f794ad49 (patch) | |
tree | 00b5180edcfab392eef203f594edb1332ccfce5d /src/table | |
parent | 7d772737a58b3c8dce147e4704152e2e6471bd90 (diff) | |
download | garage-0eb5baea1a8e23fd373685f40aa32a84f794ad49.tar.gz garage-0eb5baea1a8e23fd373685f40aa32a84f794ad49.zip |
Improve bootstraping: do it regularly; persist peer list
Diffstat (limited to 'src/table')
-rw-r--r-- | src/table/data.rs | 8 | ||||
-rw-r--r-- | src/table/gc.rs | 7 | ||||
-rw-r--r-- | src/table/merkle.rs | 23 |
3 files changed, 30 insertions, 8 deletions
diff --git a/src/table/data.rs b/src/table/data.rs index e07a21d2..542a8481 100644 --- a/src/table/data.rs +++ b/src/table/data.rs @@ -35,7 +35,13 @@ where F: TableSchema, R: TableReplication, { - pub fn new(system: Arc<System>, name: String, instance: F, replication: R, db: &sled::Db) -> Arc<Self> { + pub fn new( + system: Arc<System>, + name: String, + instance: F, + replication: R, + db: &sled::Db, + ) -> Arc<Self> { let store = db .open_tree(&format!("{}:table", name)) .expect("Unable to open DB tree"); diff --git a/src/table/gc.rs b/src/table/gc.rs index a37c052f..e52bf599 100644 --- a/src/table/gc.rs +++ b/src/table/gc.rs @@ -157,7 +157,12 @@ where if errs.is_empty() { Ok(true) } else { - Err(Error::Message(errs.into_iter().map(|x| format!("{}", x)).collect::<Vec<_>>().join(", "))) + Err(Error::Message( + errs.into_iter() + .map(|x| format!("{}", x)) + .collect::<Vec<_>>() + .join(", "), + )) } } diff --git a/src/table/merkle.rs b/src/table/merkle.rs index 3001786f..39b87aa1 100644 --- a/src/table/merkle.rs +++ b/src/table/merkle.rs @@ -200,12 +200,13 @@ where let subnode = self.read_node_txn(tx, &key_sub)?; match subnode { MerkleNode::Empty => { - warn!("({}) Single subnode in tree is empty Merkle node", self.data.name); + warn!( + "({}) Single subnode in tree is empty Merkle node", + self.data.name + ); Some(MerkleNode::Empty) } - MerkleNode::Intermediate(_) => { - Some(MerkleNode::Intermediate(children)) - } + MerkleNode::Intermediate(_) => Some(MerkleNode::Intermediate(children)), x @ MerkleNode::Leaf(_, _) => { tx.remove(key_sub.encode())?; Some(x) @@ -239,14 +240,24 @@ where { let exlf_subkey = key.next_key(&exlf_khash); - let exlf_sub_hash = self.update_item_rec(tx, &exlf_k[..], &exlf_khash, &exlf_subkey, Some(exlf_vhash))?.unwrap(); + let exlf_sub_hash = self + .update_item_rec( + tx, + &exlf_k[..], + &exlf_khash, + &exlf_subkey, + Some(exlf_vhash), + )? + .unwrap(); intermediate_set_child(&mut int, exlf_subkey.prefix[i], exlf_sub_hash); assert_eq!(int.len(), 1); } { let key2 = key.next_key(khash); - let subhash = self.update_item_rec(tx, k, khash, &key2, new_vhash)?.unwrap(); + let subhash = self + .update_item_rec(tx, k, khash, &key2, new_vhash)? + .unwrap(); intermediate_set_child(&mut int, key2.prefix[i], subhash); if exlf_khash.as_slice()[i] == khash.as_slice()[i] { assert_eq!(int.len(), 1); |