node: wire up connect command
The connect command was unimplemented for both Node and the control socket. This wires up the connect functionality in both places. Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com> X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
parent
1f837c6572
commit
f322305f86
|
|
@ -90,7 +90,12 @@ fn command<H: Handle<Error = runtime::HandleError>>(
|
||||||
|
|
||||||
match cmd.name {
|
match cmd.name {
|
||||||
CommandName::Connect => {
|
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 => {
|
CommandName::Fetch => {
|
||||||
let (rid, nid): (Id, NodeId) = parse::args(cmd)?;
|
let (rid, nid): (Id, NodeId) = parse::args(cmd)?;
|
||||||
|
|
|
||||||
|
|
@ -479,8 +479,13 @@ impl Handle for Node {
|
||||||
matches!(result, CommandResult::Okay { .. })
|
matches!(result, CommandResult::Okay { .. })
|
||||||
}
|
}
|
||||||
|
|
||||||
fn connect(&mut self, _node: NodeId, _addr: Address) -> Result<(), Error> {
|
fn connect(&mut self, nid: NodeId, addr: Address) -> Result<(), Error> {
|
||||||
todo!()
|
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> {
|
fn seeds(&mut self, id: Id) -> Result<Seeds, Error> {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue