Skip to content

Commit

Permalink
Merge pull request #2439 from maqi/initialize_records_by_bucket_prope…
Browse files Browse the repository at this point in the history
…rly_main

      populate records_by_bucket during restart
  • Loading branch information
jacderida authored Nov 13, 2024
2 parents 5aa7088 + 3145bc2 commit dbf2d20
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 9 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

*When editing this file, please respect a line length of 100.*

## 2024-11-13

### Network

#### Fixed

- During a restart, the node builds a cache of locally restored records,
which is used to improve the speed of the relevant records calculation.
The restored records were not being added to the cache.
This has now been corrected.

## 2024-11-12

### Network
Expand Down
2 changes: 1 addition & 1 deletion 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 autonomi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ rand = "0.8.5"
rmp-serde = "1.1.1"
self_encryption = "~0.30.0"
serde = { version = "1.0.133", features = ["derive", "rc"] }
sn_networking = { path = "../sn_networking", version = "0.19.3" }
sn_networking = { path = "../sn_networking", version = "0.19.4" }
sn_peers_acquisition = { path = "../sn_peers_acquisition", version = "0.5.7" }
sn_protocol = { version = "0.17.15", path = "../sn_protocol" }
sn_registers = { path = "../sn_registers", version = "0.4.3" }
Expand Down
2 changes: 1 addition & 1 deletion nat-detection/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ libp2p = { version = "0.54.1", features = [
"upnp",
] }
sn_build_info = { path = "../sn_build_info", version = "0.1.19" }
sn_networking = { path = "../sn_networking", version = "0.19.3" }
sn_networking = { path = "../sn_networking", version = "0.19.4" }
sn_protocol = { path = "../sn_protocol", version = "0.17.15" }
tokio = { version = "1.32.0", features = ["full"] }
tracing = { version = "~0.1.26" }
Expand Down
2 changes: 1 addition & 1 deletion release-cycle-info
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
release-year: 2024
release-month: 11
release-cycle: 1
release-cycle-counter: 4
release-cycle-counter: 5
2 changes: 1 addition & 1 deletion sn_build_info/src/release_info.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub const RELEASE_YEAR: &str = "2024";
pub const RELEASE_MONTH: &str = "11";
pub const RELEASE_CYCLE: &str = "1";
pub const RELEASE_CYCLE_COUNTER: &str = "4";
pub const RELEASE_CYCLE_COUNTER: &str = "5";
2 changes: 1 addition & 1 deletion sn_networking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license = "GPL-3.0"
name = "sn_networking"
readme = "README.md"
repository = "https://github.com/maidsafe/safe_network"
version = "0.19.3"
version = "0.19.4"

[features]
default = []
Expand Down
16 changes: 14 additions & 2 deletions sn_networking/src/record_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,13 +371,25 @@ impl NodeRecordStore {
};

let records = Self::update_records_from_an_existing_store(&config, &encryption_details);
let local_address = NetworkAddress::from_peer(local_id);

// Initialize records_by_bucket
let mut records_by_bucket: HashMap<u32, HashSet<Key>> = HashMap::new();
for (key, (addr, _record_type)) in records.iter() {
let distance = local_address.distance(addr);
let bucket = distance.ilog2().unwrap_or_default();
records_by_bucket
.entry(bucket)
.or_default()
.insert(key.clone());
}

let cache_size = config.records_cache_size;
let mut record_store = NodeRecordStore {
local_address: NetworkAddress::from_peer(local_id),
local_address,
config,
records,
records_by_bucket: HashMap::new(),
records_by_bucket,
records_cache: RecordCache::new(cache_size),
network_event_sender,
local_swarm_cmd_sender: swarm_cmd_sender,
Expand Down
2 changes: 1 addition & 1 deletion sn_node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ serde = { version = "1.0.133", features = ["derive", "rc"] }
sn_build_info = { path = "../sn_build_info", version = "0.1.19" }
sn_peers_acquisition = { path = "../sn_peers_acquisition", version = "0.5.7" }
sn_logging = { path = "../sn_logging", version = "0.2.40" }
sn_networking = { path = "../sn_networking", version = "0.19.3" }
sn_networking = { path = "../sn_networking", version = "0.19.4" }
sn_protocol = { path = "../sn_protocol", version = "0.17.15" }
sn_registers = { path = "../sn_registers", version = "0.4.3" }
sn_transfers = { path = "../sn_transfers", version = "0.20.3" }
Expand Down

0 comments on commit dbf2d20

Please sign in to comment.