Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
node: Don't re-queue fetch that is already queued
cloudhead committed 2 years ago
commit ef1ed621d78fe72b100b783026d3d6616d532107
parent e19c773a86acbdb931213d21b15249dec26454c3
1 file changed +18 -3
modified radicle-node/src/service.rs
@@ -281,6 +281,16 @@ struct QueuedFetch {
    channel: Option<chan::Sender<FetchResult>>,
}

+
impl PartialEq for QueuedFetch {
+
    fn eq(&self, other: &Self) -> bool {
+
        self.rid == other.rid
+
            && self.from == other.from
+
            && self.refs_at == other.refs_at
+
            && self.channel.is_none()
+
            && other.channel.is_none()
+
    }
+
}
+

/// Holds all node stores.
#[derive(Debug)]
pub struct Stores<D>(D);
@@ -907,13 +917,18 @@ where
                        fetching.subscribe(c);
                    }
                } else {
-
                    debug!(target: "service", "Queueing fetch for {rid} with {from}..");
-
                    self.queue.push_back(QueuedFetch {
+
                    let fetch = QueuedFetch {
                        rid,
                        refs_at,
                        from,
                        channel,
-
                    });
+
                    };
+
                    if self.queue.contains(&fetch) {
+
                        debug!(target: "service", "Fetch for {rid} with {from} is already queued..");
+
                    } else {
+
                        debug!(target: "service", "Queueing fetch for {rid} with {from}..");
+
                        self.queue.push_back(fetch);
+
                    }
                }
            }
            Err(TryFetchError::SessionCapacityReached) => {