Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
Implement `Handle::listening`
Alexis Sellier committed 3 years ago
commit 2499317589d61230cc03bb13af701d10862b4375
parent d3523ccf7836aaa1718e3d815f5706077c25ee28
2 files changed +10 -0
modified radicle-node/src/client/handle.rs
@@ -56,6 +56,10 @@ pub struct Handle<W: Waker> {
}

impl<W: Waker> traits::Handle for Handle<W> {
+
    fn listening(&self) -> Result<net::SocketAddr, Error> {
+
        self.listening.recv().map_err(Error::from)
+
    }
+

    /// Retrieve or update the given project from the network.
    fn fetch(&self, id: Id) -> Result<FetchLookup, Error> {
        let (sender, receiver) = chan::bounded(1);
@@ -142,6 +146,8 @@ pub mod traits {
    use super::*;

    pub trait Handle {
+
        /// Wait for the node's listening socket to be bound.
+
        fn listening(&self) -> Result<net::SocketAddr, Error>;
        /// Retrieve or update the project from network.
        fn fetch(&self, id: Id) -> Result<FetchLookup, Error>;
        /// Start tracking the given project. Doesn't do anything if the project is already
modified radicle-node/src/test/handle.rs
@@ -14,6 +14,10 @@ pub struct Handle {
}

impl traits::Handle for Handle {
+
    fn listening(&self) -> Result<std::net::SocketAddr, Error> {
+
        unimplemented!()
+
    }
+

    fn fetch(&self, _id: Id) -> Result<FetchLookup, Error> {
        Ok(FetchLookup::NotFound)
    }