From 36ed175c81e580d81b8d0d406292549664e5457d Mon Sep 17 00:00:00 2001 From: Eric <5089238+emizzle@users.noreply.github.com> Date: Thu, 2 Nov 2023 17:22:15 +1100 Subject: [PATCH] Add queue pausing and prevention of small availabilities from clearing queue --- design/sales.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/design/sales.md b/design/sales.md index 3fe9d76..dcf08cb 100644 --- a/design/sales.md +++ b/design/sales.md @@ -174,6 +174,7 @@ Slots in the queue should be sorted in the following order: 2. Collateral required (ascending) 3. Time before expiry (descending) 4. Dataset size (ascending) +5. Seen flag 1 While profit cannot yet be calculated correctly as this calculation will involve bandwidth incentives, profit can be estimated as `duration * reward` @@ -208,6 +209,27 @@ mechanism](https://github.com/codex-storage/codex-research/blob/master/design/ma If the host is not allowed to fill the slot, the sales process will exit and the host will process the top slot in the queue. +#### Preventing continual processing when there are small availabilities +If the processed slot cannot continue because there are no availabilities, the +slot should be marked as `seen` and put back into the queue. This flag will +cause the slot to be ordered lower in the heap queue. If, upon processing +a slot, the slot item already has a `seen` flag set, the queue should be +paused. + +This serves to prevent availabilities that are small (in avaialble bytes) from +emptying the queue. + +#### Pausing the queue +When availabilities are modified or removed, and there are no availabilities +left, the queue should be paused. + +A paused queue will wait until it is unpaused before continuing to process items +in the queue. This prevents unnecessarily popping items off the queue. + +#### Unpausing the queue +When availabilities are modified or added, the queue should be unpaused if it +was paused and any slots in the queue should have their `seen` flag cleared. + #### Queue workers Each time an item in the queue is processed, it is assigned to a workers. The number of allowed workers can be specified during queue creation. Specifying a