Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
fetch: always fetch canonical rad/id
Fintan Halpenny committed 2 years ago
commit 119d48bbbca6c5b1001b85cf1c986934a6721009
parent f7b53139f48cbee3a0799b82043b1aec675fbb58
2 files changed +15 -13
modified radicle-fetch/src/lib.rs
@@ -59,11 +59,12 @@ where
    if local == remote {
        return Err(Error::ReplicateSelf);
    }
-
    let state = FetchState::default();
    let handshake = handle
        .transport
        .handshake()
        .map_err(|err| Error::Handshake { err })?;
+
    let state = FetchState::default();
+

    // N.b. ensure that we ignore the local peer's key.
    handle.blocked.extend([local]);
    state
@@ -90,18 +91,7 @@ where
        .transport
        .handshake()
        .map_err(|err| Error::Handshake { err })?;
-
    let mut state = FetchState::default();
-
    state
-
        .run_stage(
-
            handle,
-
            &handshake,
-
            &stage::CanonicalId {
-
                remote,
-
                limit: limit.special,
-
            },
-
        )
-
        .map_err(|e| Error::from(state::error::Protocol::from(e)))?;
-

+
    let state = FetchState::default();
    state
        .run(handle, &handshake, limit, remote, None)
        .map_err(Error::Protocol)
modified radicle-fetch/src/state.rs
@@ -378,6 +378,18 @@ impl FetchState {
    where
        S: transport::ConnectionStream,
    {
+
        // N.b. we always fetch the `rad/id` since our delegate set
+
        // might be further ahead than theirs, e.g. we are the
+
        // deciding vote on adding a delegate.
+
        self.run_stage(
+
            handle,
+
            &handshake,
+
            &stage::CanonicalId {
+
                remote,
+
                limit: limit.special,
+
            },
+
        )?;
+

        // N.b. The error case here should not happen. In the case of
        // a `clone` we have asked for refs/rad/id and ensured it was
        // fetched. In the case of `pull` the repository should have