Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
node: wire up connect command
Fintan Halpenny committed 3 years ago
commit f322305f86ed4a8288f86f861313c51afab80e91
parent 1f837c65723eb6afbcdb6f0be3ac882e6586d27a
2 files changed +13 -3
modified radicle-node/src/control.rs
@@ -90,7 +90,12 @@ fn command<H: Handle<Error = runtime::HandleError>>(

    match cmd.name {
        CommandName::Connect => {
-
            todo!();
+
            let (nid, addr) = parse::args(cmd)?;
+
            if let Err(e) = handle.connect(nid, addr) {
+
                return Err(CommandError::Runtime(e));
+
            } else {
+
                CommandResult::Okay { updated: true }.to_writer(writer)?;
+
            }
        }
        CommandName::Fetch => {
            let (rid, nid): (Id, NodeId) = parse::args(cmd)?;
modified radicle/src/node.rs
@@ -479,8 +479,13 @@ impl Handle for Node {
        matches!(result, CommandResult::Okay { .. })
    }

-
    fn connect(&mut self, _node: NodeId, _addr: Address) -> Result<(), Error> {
-
        todo!()
+
    fn connect(&mut self, nid: NodeId, addr: Address) -> Result<(), Error> {
+
        self.call::<_, CommandResult>(CommandName::Connect, [nid.to_human(), addr.to_string()])?
+
            .next()
+
            .ok_or(Error::EmptyResponse {
+
                cmd: CommandName::Connect,
+
            })??;
+
        Ok(())
    }

    fn seeds(&mut self, id: Id) -> Result<Seeds, Error> {