Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
fetch: log handshake error
Fintan Halpenny committed 2 years ago
commit c02ff1e47ef67929ab7f6526ba454e5547d3f180
parent 6efd0d97a5d13a37a7b89160b84f744f8a4f2ac8
1 file changed +13 -8
modified radicle-fetch/src/lib.rs
@@ -9,6 +9,7 @@ mod refs;
mod stage;
mod state;

+
use gix_protocol::handshake;
pub use handle::Handle;
pub use policy::{Allowed, BlockList, Scope};
use radicle::storage::ReadRepository as _;
@@ -62,10 +63,7 @@ where
    if local == remote {
        return Err(Error::ReplicateSelf);
    }
-
    let handshake = handle
-
        .transport
-
        .handshake()
-
        .map_err(|err| Error::Handshake { err })?;
+
    let handshake = perform_handshake(handle)?;
    let state = FetchState::default();

    // N.b. ensure that we ignore the local peer's key.
@@ -99,10 +97,7 @@ where
    if *handle.local() == remote {
        return Err(Error::ReplicateSelf);
    }
-
    let handshake = handle
-
        .transport
-
        .handshake()
-
        .map_err(|err| Error::Handshake { err })?;
+
    let handshake = perform_handshake(handle)?;
    let state = FetchState::default();
    let result = state
        .run(handle, &handshake, limit, remote, None)
@@ -116,3 +111,13 @@ where
    );
    result
}
+

+
fn perform_handshake<S>(handle: &mut Handle<S>) -> Result<handshake::Outcome, Error>
+
where
+
    S: transport::ConnectionStream,
+
{
+
    handle.transport.handshake().map_err(|err| {
+
        log::warn!(target: "fetch", "Failed to perform handshake: {err}");
+
        Error::Handshake { err }
+
    })
+
}