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 rid = result.rid;
let namespaces = result.namespaces;
let initiated = result.initiated;
if initiated {
log::debug!(
target: "service",
"Fetched {rid} {remote} (error={:?})", result.result.as_ref().err()
);
let result = match result.result {
Ok(updated) => {
self.reactor.event(Event::RefsFetched {
@ -546,6 +547,7 @@ where
if results
.send(FetchResult {
rid,
initiated,
remote,
namespaces,
result,
@ -560,6 +562,7 @@ where
} else {
log::debug!(target: "service", "No fetch requests found for {rid}..");
}
}
if let Some(session) = self.sessions.get_mut(&remote) {
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,
input: Input::Fetched(Arc::new(FetchResult {
rid: fetch.repo,
initiated: fetch.initiated,
remote: fetch.remote,
namespaces: fetch.namespaces,
result: Err(FetchError::Io(io::ErrorKind::Other.into())),
@ -635,6 +636,7 @@ impl<S: WriteStorage + 'static, G: Signer> Simulation<S, G> {
remote: fetch.remote,
input: Input::Fetched(Arc::new(FetchResult {
rid: fetch.repo,
initiated: fetch.initiated,
remote: fetch.remote,
namespaces: fetch.namespaces,
result: Ok(vec![]),

View File

@ -81,6 +81,7 @@ impl<G: Signer + EcSign + 'static> Worker<G> {
rid: fetch.repo,
remote: fetch.remote,
namespaces: fetch.namespaces,
initiated: fetch.initiated,
result,
};
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 rid: Id,
pub remote: NodeId,
pub initiated: bool,
pub namespaces: Namespaces,
pub result: Result<Vec<RefUpdate>, FetchError>,
}