Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: implement per-worker aliasing [NET-352] #1449

Merged
merged 9 commits into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,13 @@ opt-level = 1

# Enable high optimizations for dependencies, but not for our code:
[profile.dev.package."*"]
inherits = "release"
opt-level = 3
codegen-units = 256

[profile.dev.package.clap]
debug-assertions = false

[profile.release]
strip = true
lto = true
lto = false
codegen-units = 1 # Reduce number of codegen units to increase optimizations
12 changes: 6 additions & 6 deletions aquamarine/src/plumber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl<RT: AquaRuntime, F: ParticleFunctionStatic> Plumber<RT, F> {
.actors
.entry((particle.id.clone(), scope_peer_id))
.or_insert_with(|| {
let params = ParticleParams::clone_from(&particle);
let params = ParticleParams::clone_from(&particle, scope_peer_id);
let functions = Functions::new(params, builtins.clone());
Actor::new(&particle, functions, scope_peer_id)
});
Expand Down Expand Up @@ -139,11 +139,11 @@ impl<RT: AquaRuntime, F: ParticleFunctionStatic> Plumber<RT, F> {
for actor in self.actors.values_mut() {
if let Poll::Ready(result) = actor.poll_completed(cx) {
interpretation_stats.push(result.stats);
let (local_peers, remote_peers): (Vec<_>, Vec<_>) = result
.effects
.next_peers
.into_iter()
.partition(|p| key_manager.is_scope_peer_id(*p));
let (local_peers, remote_peers): (Vec<_>, Vec<_>) =
result.effects.next_peers.into_iter().partition(|p| {
key_manager.is_scope_peer_id(*p)
|| p.eq(&self.key_manager.get_host_peer_id())
});

if !remote_peers.is_empty() {
remote_effects.push(RoutingEffects {
Expand Down
28 changes: 28 additions & 0 deletions crates/libp2p/src/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,34 @@ pub mod peerid_serializer {
}
}

pub mod peerid_serializer_opt {
use libp2p::PeerId;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::str::FromStr;

pub fn serialize<S>(value: &Option<PeerId>, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
value.map(|p| p.to_base58()).serialize(serializer)
}

pub fn deserialize<'de, D>(deserializer: D) -> Result<Option<PeerId>, D::Error>
where
D: Deserializer<'de>,
{
let opt: Option<String> = Option::deserialize(deserializer)?;
match opt {
None => Ok(None),
Some(str) => PeerId::from_str(&str)
.map_err(|e| {
serde::de::Error::custom(format!("peer id deserialization failed for {e:?}"))
})
.map(Some),
}
}
}

#[cfg(test)]
mod tests {
use crate::RandomPeerId;
Expand Down
Loading