node: Update local routing table on announce
This commit is contained in:
parent
9177e67de6
commit
69ac8be8fd
|
|
@ -0,0 +1,24 @@
|
|||
|
||||
To create your first radicle project, navigate to a git repository, and run
|
||||
the `init` command:
|
||||
|
||||
```
|
||||
$ rad init --name heartwood --description "Radicle Heartwood Protocol & Stack" --no-confirm
|
||||
|
||||
Initializing local 🌱 project in .
|
||||
|
||||
ok Project heartwood created
|
||||
{
|
||||
"name": "heartwood",
|
||||
"description": "Radicle Heartwood Protocol & Stack",
|
||||
"defaultBranch": "master"
|
||||
}
|
||||
ok Announcing refs..
|
||||
|
||||
Your project id is rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji. You can show it any time by running:
|
||||
rad .
|
||||
|
||||
To publish your project to the network, run:
|
||||
rad push
|
||||
|
||||
```
|
||||
|
|
@ -14,7 +14,6 @@ ok Project heartwood created
|
|||
"defaultBranch": "master"
|
||||
}
|
||||
|
||||
|
||||
Your project id is rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji. You can show it any time by running:
|
||||
rad .
|
||||
|
||||
|
|
|
|||
|
|
@ -212,10 +212,7 @@ pub fn init(options: Options, profile: &profile::Profile) -> anyhow::Result<()>
|
|||
));
|
||||
spinner.finish();
|
||||
|
||||
if interactive.no() {
|
||||
term::blob(json::to_string_pretty(&proj)?);
|
||||
term::blank();
|
||||
}
|
||||
term::blob(json::to_string_pretty(&proj)?);
|
||||
|
||||
if options.set_upstream || git::branch_remote(&repo, proj.default_branch()).is_err() {
|
||||
// Setup eg. `master` -> `rad/master`
|
||||
|
|
|
|||
|
|
@ -172,3 +172,40 @@ fn rad_clone() {
|
|||
|
||||
test("examples/rad-clone.md", working, Some(&bob.home), []).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rad_init_announce_refs() {
|
||||
logger::init(log::Level::Debug);
|
||||
|
||||
let mut environment = Environment::new();
|
||||
let alice = environment.node("alice");
|
||||
let bob = environment.node("bob");
|
||||
let working = environment.tmp().join("working");
|
||||
|
||||
let alice = alice.spawn(Config::default());
|
||||
let mut bob = bob.spawn(Config::default());
|
||||
|
||||
bob.connect(&alice);
|
||||
|
||||
fixtures::repository(working.join("alice"));
|
||||
|
||||
// Alice initializes a repo after her node has started, and after bob has connected to it.
|
||||
test(
|
||||
"examples/rad-init-announce-refs.md",
|
||||
&working.join("alice"),
|
||||
Some(&alice.home),
|
||||
[],
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
// Wait for bob to get any updates to the routing table.
|
||||
bob.converge([&alice]);
|
||||
|
||||
test(
|
||||
"examples/rad-clone.md",
|
||||
working.join("bob"),
|
||||
Some(&bob.home),
|
||||
[],
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -166,9 +166,6 @@ impl TestFormula {
|
|||
};
|
||||
log::debug!(target: "test", "Running `{}` in `{}`..", cmd.display(), self.cwd.display());
|
||||
|
||||
if !cmd.exists() {
|
||||
log::error!(target: "test", "Command {} does not exist..", cmd.display());
|
||||
}
|
||||
if !self.cwd.exists() {
|
||||
log::error!(target: "test", "Directory {} does not exist..", self.cwd.display());
|
||||
}
|
||||
|
|
@ -187,6 +184,9 @@ impl TestFormula {
|
|||
assert.stdout_matches(&assertion.expected).success();
|
||||
}
|
||||
Err(err) => {
|
||||
if err.kind() == io::ErrorKind::NotFound {
|
||||
log::error!(target: "test", "Command `{}` does not exist..", cmd.display());
|
||||
}
|
||||
return Err(io::Error::new(
|
||||
err.kind(),
|
||||
format!("{err}: `{}`", cmd.display()),
|
||||
|
|
|
|||
|
|
@ -1001,6 +1001,11 @@ where
|
|||
let peers = self.sessions.negotiated().map(|(_, p)| p);
|
||||
let timestamp = self.clock.as_secs();
|
||||
|
||||
// Make sure our local routing table is up to date with new repositories.
|
||||
if let Err(e) = self.routing.insert(id, self.node_id(), timestamp) {
|
||||
log::error!(target: "service", "Failed to update routing table with repository {id}: {e}");
|
||||
}
|
||||
|
||||
if remote.refs.len() > Refs::max() {
|
||||
error!(
|
||||
target: "service",
|
||||
|
|
|
|||
Loading…
Reference in New Issue