From bee6c4568fec727208dea20cec7397c88fc5c935 Mon Sep 17 00:00:00 2001 From: Alexis Sellier Date: Sat, 1 Jun 2024 19:01:01 +0200 Subject: [PATCH] node: Simplify configuration This is a change to the `config.json` file which removes certain options that are best not touched and changes some options to make them easier to work with. 1. We change the default journaling mode to "wal" and remove the config option. 2. We remove the option to set the peer connection "target", as it's not a good idea to set this to a different value, as it affects the network. 3. We combine seeding policy & scope, since there's no need to set the scope when the policy is "block". In that case, we always want to block "all" remotes. The new policy configuration has the following schema: { seedingPolicy: { default: "block" | "allow", scope?: "all" | "followed" } } The "scope" key is not used when "default" is set to "block". 4. We add an `extra` field to the node config for options that are not recognized. We use this to warn the user. --- radicle-httpd/src/api/v1/node.rs | 16 +++++++--------- radicle-httpd/src/api/v1/profile.rs | 11 ++++------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/radicle-httpd/src/api/v1/node.rs b/radicle-httpd/src/api/v1/node.rs index 2e42b587d..3e2382384 100644 --- a/radicle-httpd/src/api/v1/node.rs +++ b/radicle-httpd/src/api/v1/node.rs @@ -8,7 +8,10 @@ use serde_json::json; use radicle::identity::RepoId; use radicle::node::routing::Store; -use radicle::node::{policy, AliasStore, Handle, NodeId, DEFAULT_TIMEOUT}; +use radicle::node::{ + policy::{Policy, SeedPolicy}, + AliasStore, Handle, NodeId, DEFAULT_TIMEOUT, +}; use radicle::Node; use crate::api::error::Error; @@ -84,16 +87,11 @@ async fn node_policies_repos_handler(State(ctx): State) -> impl IntoRes let policies = ctx.profile.policies()?; let mut repos = Vec::new(); - for policy::SeedPolicy { - rid: id, - scope, - policy, - } in policies.seed_policies()? - { + for SeedPolicy { rid: id, policy } in policies.seed_policies()? { repos.push(json!({ "id": id, - "scope": scope, - "policy": policy, + "scope": policy.scope().unwrap_or_default(), + "policy": Policy::from(policy), })); } diff --git a/radicle-httpd/src/api/v1/profile.rs b/radicle-httpd/src/api/v1/profile.rs index 123cbe15c..6b869af1d 100644 --- a/radicle-httpd/src/api/v1/profile.rs +++ b/radicle-httpd/src/api/v1/profile.rs @@ -83,13 +83,9 @@ mod routes { "node": { "alias": "seed", "listen": [], - "peers": { - "type": "dynamic", - "target": 8 - }, + "peers": { "type": "dynamic" }, "connect": [], "externalAddresses": [], - "db": { "journalMode": "rollback" }, "network": "main", "log": "INFO", "relay": "auto", @@ -115,8 +111,9 @@ mod routes { } }, "workers": 8, - "policy": "block", - "scope": "all" + "seedingPolicy": { + "default": "block", + } } }, "home": seed.profile.path()