diff --git a/radicle-fetch/src/lib.rs b/radicle-fetch/src/lib.rs index 41b07d54..376e2bb2 100644 --- a/radicle-fetch/src/lib.rs +++ b/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) diff --git a/radicle-fetch/src/state.rs b/radicle-fetch/src/state.rs index 6495d9c9..218bcc95 100644 --- a/radicle-fetch/src/state.rs +++ b/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