Skip to content

Commit

Permalink
fix: pop updates from front of queues instead of back
Browse files Browse the repository at this point in the history
This way if peers are being announced faster than can be upserted, the insert order will be maintained. Was supposed to be like this since the beginning, not sure how it got switched around.
  • Loading branch information
Roardom committed Jul 10, 2024
1 parent 0a54edd commit de32468
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/scheduler/announce_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl Queue {
pub fn take_batch(&mut self) -> Queue {
let len = self.len();

Queue(self.split_off(len - min(Queue::announce_limit(), len)))
Queue(self.drain(0..min(Queue::announce_limit(), len)).collect())
}

/// Merge a announce update batch into this announce update batch
Expand Down
2 changes: 1 addition & 1 deletion src/scheduler/history_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl Queue {
pub fn take_batch(&mut self) -> Queue {
let len = self.len();

Queue(self.split_off(len - min(Queue::history_limit(), len)))
Queue(self.drain(0..min(Queue::history_limit(), len)).collect())
}

/// Merge a history update batch into this history update batch
Expand Down
2 changes: 1 addition & 1 deletion src/scheduler/peer_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl Queue {
pub fn take_batch(&mut self) -> Queue {
let len = self.len();

Queue(self.split_off(len - min(Queue::peer_limit(), len)))
Queue(self.drain(0..min(Queue::peer_limit(), len)).collect())
}

/// Merge a peer update batch into this peer update batch
Expand Down
2 changes: 1 addition & 1 deletion src/scheduler/torrent_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl Queue {
pub fn take_batch(&mut self) -> Queue {
let len = self.len();

Queue(self.split_off(len - min(Queue::torrent_limit(), len)))
Queue(self.drain(0..min(Queue::torrent_limit(), len)).collect())
}

/// Merge a torrent update batch into this torrent update batch
Expand Down
2 changes: 1 addition & 1 deletion src/scheduler/user_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl Queue {
pub fn take_batch(&mut self) -> Queue {
let len = self.len();

Queue(self.split_off(len - min(Queue::user_limit(), len)))
Queue(self.drain(0..min(Queue::user_limit(), len)).collect())
}

/// Merge a torrent update batch into this torrent update batch
Expand Down

0 comments on commit de32468

Please sign in to comment.