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

Forwardport/gossip arc setting explicit #51

Closed
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions crates/hc-pilot/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ fn main() {
wan_network_config,
holochain_dir: conductor_dir,
admin_port: args.admin_port,
gossip_arc_clamp: None,
},
))
.setup(|app| {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub fn run() {
)
.plugin(tauri_plugin_holochain::init(
vec_to_locked(vec![]).expect("Can't build passphrase"),
HolochainPluginConfig::new(holochain_dir(), wan_network_config())
HolochainPluginConfig::new(holochain_dir(), wan_network_config(), None)
))
.setup(|app| {
let handle = app.handle().clone();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn run() {
)
.plugin(tauri_plugin_holochain::init(
vec_to_locked(vec![]).expect("Can't build passphrase"),
HolochainPluginConfig::new(holochain_dir(), wan_network_config())
HolochainPluginConfig::new(holochain_dir(), wan_network_config(), None)
))
.setup(|app| {
let handle = app.handle().clone();
Expand Down
6 changes: 0 additions & 6 deletions crates/tauri-plugin-holochain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,3 @@ async-trait = "0.1"
[build-dependencies]
tauri-plugin = { version = "2.0.0", features = ["build"] }

[features]
default = ["gossip_arc_normal"]

gossip_arc_empty = []
gossip_arc_full = []
gossip_arc_normal = []
15 changes: 0 additions & 15 deletions crates/tauri-plugin-holochain/src/features.rs

This file was deleted.

26 changes: 5 additions & 21 deletions crates/tauri-plugin-holochain/src/launch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use holochain_client::AdminWebsocket;
use crate::{
filesystem::FileSystem,
launch::signal::{can_connect_to_signal_server, run_local_signal_service},
HolochainPluginConfig, HolochainRuntime,
GossipArcClamp, HolochainPluginConfig, HolochainRuntime,
};

mod mdns;
Expand All @@ -20,25 +20,6 @@ use mdns::spawn_mdns_bootstrap;

pub const DEVICE_SEED_LAIR_KEYSTORE_TAG: &'static str = "DEVICE_SEED";

#[cfg(feature = "gossip_arc_empty")]
fn override_gossip_arc_clamping() -> Option<String> {
Some(String::from("empty"))
}

#[cfg(feature = "gossip_arc_full")]
fn override_gossip_arc_clamping() -> Option<String> {
Some(String::from("full"))
}

#[cfg(feature = "gossip_arc_normal")]
fn override_gossip_arc_clamping() -> Option<String> {
if cfg!(mobile) {
Some(String::from("empty"))
} else {
None
}
}

// pub static RUNNING_HOLOCHAIN: RwLock<Option<RunningHolochainInfo>> = RwLock::const_new(None);

/// Launch the holochain conductor in the background
Expand Down Expand Up @@ -83,7 +64,10 @@ pub async fn launch_holochain_runtime(
filesystem.keystore_dir().into(),
wan_network_config,
local_signal_url,
override_gossip_arc_clamping(),
config.gossip_arc_clamp.map(|n| match n {
GossipArcClamp::Full => "full".to_string(),
GossipArcClamp::Empty => "empty".to_string(),
}),
);

let keystore =
Expand Down
22 changes: 20 additions & 2 deletions crates/tauri-plugin-holochain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ use url2::Url2;
mod commands;
mod config;
mod error;
mod features;
mod filesystem;
mod http_server;
mod lair_signer;
Expand Down Expand Up @@ -520,6 +519,11 @@ pub struct WANNetworkConfig {
pub ice_servers_urls: Vec<Url2>,
}

pub enum GossipArcClamp {
Full,
Empty,
}

pub struct HolochainPluginConfig {
/// The directory where the holochain files and databases will be stored in
pub holochain_dir: PathBuf,
Expand All @@ -528,14 +532,28 @@ pub struct HolochainPluginConfig {
pub wan_network_config: Option<WANNetworkConfig>,
/// Force the conductor to run at this admin port
pub admin_port: Option<u16>,
/// Force the conductor to always have a "full", or "empty" Gossip Arc for all DNAs.
/// The Gossip Arc is the subsection of the DHT that you aim to store and serve to others.
///
/// A Full Gossip Arc means that your peer will always try to hold the full DHT state,
/// and serve it to others.
///
/// An Empty Gossip Arc means that your peer will always go to the network to fetch DHT data,
/// unless they authored it.
pub gossip_arc_clamp: Option<GossipArcClamp>,
}

impl HolochainPluginConfig {
pub fn new(holochain_dir: PathBuf, wan_network_config: Option<WANNetworkConfig>) -> Self {
pub fn new(
holochain_dir: PathBuf,
wan_network_config: Option<WANNetworkConfig>,
gossip_arc_clamp: Option<GossipArcClamp>,
) -> Self {
HolochainPluginConfig {
holochain_dir,
wan_network_config,
admin_port: None,
gossip_arc_clamp,
}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/end-user-happ/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub fn run() {
)
.plugin(tauri_plugin_holochain::async_init(
vec_to_locked(vec![]).expect("Can't build passphrase"),
HolochainPluginConfig::new(holochain_dir(), wan_network_config())
HolochainPluginConfig::new(holochain_dir(), wan_network_config(), None)
))
.setup(|app| {
let handle = app.handle().clone();
Expand Down
2 changes: 1 addition & 1 deletion examples/holochain-runtime/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub fn run() {
)
.plugin(tauri_plugin_holochain::init(
vec_to_locked(vec![]).expect("Can't build passphrase"),
HolochainPluginConfig::new(holochain_dir(), wan_network_config())
HolochainPluginConfig::new(holochain_dir(), wan_network_config(), None)
))
.setup(|app| {
let handle = app.handle().clone();
Expand Down