Skip to content

Commit

Permalink
Add compaction and fix issues + concurrency tests
Browse files Browse the repository at this point in the history
  • Loading branch information
iduartgomez committed Nov 8, 2023
1 parent 55ab087 commit 92ec60b
Show file tree
Hide file tree
Showing 6 changed files with 392 additions and 85 deletions.
15 changes: 11 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ path = "src/bin/freenet.rs"
anyhow = "1"
asynchronous-codec = "0.6"
async-trait = "0.1"
arrayvec = { workspace = true }
axum = { version = "0.6", default-features = false, features = ["ws", "tower-log", "matched-path", "headers", "query", "http1"] }
bincode = "1"
blake3 = { workspace = true }
Expand All @@ -33,6 +32,7 @@ dashmap = "^5.5"
delegate = "0.10"
directories = "5"
either = { workspace = true , features = ["serde"] }
fs4 = "0.7"
futures = "0.3.21"
libp2p = { version = "0.52.3", features = [
"autonat",
Expand Down
4 changes: 2 additions & 2 deletions crates/core/src/ring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ impl Ring {
live_tx = self
.acquire_new(
ideal_location,
&missing.values().collect::<ArrayVec<_, { 5120 / 80 }>>(),
&missing.values().collect::<Vec<_>>(),
&notifier,
self.max_connections - open_connections,
)
Expand Down Expand Up @@ -738,7 +738,7 @@ impl Ring {
live_tx = self
.acquire_new(
ideal_location,
&missing.values().collect::<ArrayVec<_, { 5120 / 80 }>>(),
&missing.values().collect::<Vec<_>>(),
&notifier,
should_swap.len(),
)
Expand Down
8 changes: 4 additions & 4 deletions crates/core/src/runtime/contract_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl ContractStore {
return result;
}

self.key_to_code_part.get(&key.id()).and_then(|key| {
self.key_to_code_part.get(key.id()).and_then(|key| {
let code_hash = key.value().1;
let path = code_hash.encode();
let key_path = self.contracts_dir.join(path).with_extension("wasm");
Expand Down Expand Up @@ -161,7 +161,7 @@ impl ContractStore {
Self::insert(
&mut self.index_file,
&mut self.key_to_code_part,
key.id(),
*key.id(),
*code_hash,
)?;

Expand All @@ -188,7 +188,7 @@ impl ContractStore {
RuntimeInnerError::UnwrapContract
})?,
};
if let Some((_, (offset, _))) = self.key_to_code_part.remove(&key.id()) {
if let Some((_, (offset, _))) = self.key_to_code_part.remove(key.id()) {
Self::remove(KEY_FILE_PATH.get().expect("infallible"), offset)?;
}
let key_path = self
Expand All @@ -200,7 +200,7 @@ impl ContractStore {
}

pub fn code_hash_from_key(&self, key: &ContractKey) -> Option<CodeHash> {
self.key_to_code_part.get(&key.id()).map(|r| r.value().1)
self.key_to_code_part.get(key.id()).map(|r| r.value().1)
}
}

Expand Down
Loading

0 comments on commit 92ec60b

Please sign in to comment.