node: Handle `fetched` differently if initiated

This commit is contained in:
Alexis Sellier 2023-01-30 13:22:33 +01:00
parent 3aa105afda
commit 498a5c4e4a
No known key found for this signature in database
4 changed files with 48 additions and 41 deletions

View File

@ -512,12 +512,13 @@ where
let remote = result.remote; let remote = result.remote;
let rid = result.rid; let rid = result.rid;
let namespaces = result.namespaces; let namespaces = result.namespaces;
let initiated = result.initiated;
if initiated {
log::debug!( log::debug!(
target: "service", target: "service",
"Fetched {rid} {remote} (error={:?})", result.result.as_ref().err() "Fetched {rid} {remote} (error={:?})", result.result.as_ref().err()
); );
let result = match result.result { let result = match result.result {
Ok(updated) => { Ok(updated) => {
self.reactor.event(Event::RefsFetched { self.reactor.event(Event::RefsFetched {
@ -546,6 +547,7 @@ where
if results if results
.send(FetchResult { .send(FetchResult {
rid, rid,
initiated,
remote, remote,
namespaces, namespaces,
result, result,
@ -560,6 +562,7 @@ where
} else { } else {
log::debug!(target: "service", "No fetch requests found for {rid}.."); log::debug!(target: "service", "No fetch requests found for {rid}..");
} }
}
if let Some(session) = self.sessions.get_mut(&remote) { if let Some(session) = self.sessions.get_mut(&remote) {
if let session::State::Connected { protocol, .. } = &mut session.state { if let session::State::Connected { protocol, .. } = &mut session.state {

View File

@ -621,6 +621,7 @@ impl<S: WriteStorage + 'static, G: Signer> Simulation<S, G> {
remote: fetch.remote, remote: fetch.remote,
input: Input::Fetched(Arc::new(FetchResult { input: Input::Fetched(Arc::new(FetchResult {
rid: fetch.repo, rid: fetch.repo,
initiated: fetch.initiated,
remote: fetch.remote, remote: fetch.remote,
namespaces: fetch.namespaces, namespaces: fetch.namespaces,
result: Err(FetchError::Io(io::ErrorKind::Other.into())), result: Err(FetchError::Io(io::ErrorKind::Other.into())),
@ -635,6 +636,7 @@ impl<S: WriteStorage + 'static, G: Signer> Simulation<S, G> {
remote: fetch.remote, remote: fetch.remote,
input: Input::Fetched(Arc::new(FetchResult { input: Input::Fetched(Arc::new(FetchResult {
rid: fetch.repo, rid: fetch.repo,
initiated: fetch.initiated,
remote: fetch.remote, remote: fetch.remote,
namespaces: fetch.namespaces, namespaces: fetch.namespaces,
result: Ok(vec![]), result: Ok(vec![]),

View File

@ -81,6 +81,7 @@ impl<G: Signer + EcSign + 'static> Worker<G> {
rid: fetch.repo, rid: fetch.repo,
remote: fetch.remote, remote: fetch.remote,
namespaces: fetch.namespaces, namespaces: fetch.namespaces,
initiated: fetch.initiated,
result, result,
}; };
log::debug!(target: "worker", "Sending response back to service.."); log::debug!(target: "worker", "Sending response back to service..");

View File

@ -61,6 +61,7 @@ impl From<net::SocketAddr> for Address {
pub struct FetchResult { pub struct FetchResult {
pub rid: Id, pub rid: Id,
pub remote: NodeId, pub remote: NodeId,
pub initiated: bool,
pub namespaces: Namespaces, pub namespaces: Namespaces,
pub result: Result<Vec<RefUpdate>, FetchError>, pub result: Result<Vec<RefUpdate>, FetchError>,
} }