Skip to content

Commit

Permalink
willSort and Store.queryRance sort now by subspace, then path
Browse files Browse the repository at this point in the history
  • Loading branch information
xash committed Nov 14, 2024
1 parent 1be94ee commit acc12cf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -763,12 +763,12 @@ export class Store<

/** Retrieve an asynchronous iterator of entry-payload-authorisation triples from the store for a given [`Range`](https://willowprotocol.org/specs/grouping-entries/index.html#ranges).
*
* Always returns entries in chronological order.
* Returns entries in order by subspace, then path, then timestamp.
*/
async *queryRange(
range: Range3d<SubspaceId>,
/** Whether to return entries newest or oldest first. */
order: "newest" | "oldest",
/** Whether to return entries descending or ascending. */
order: "descending" | "ascending",
): AsyncIterable<
[
Entry<NamespaceId, SubspaceId, PayloadDigest>,
Expand All @@ -783,8 +783,8 @@ export class Store<
maxCount: 0,
maxSize: BigInt(0),
},
"timestamp",
order === "newest" ? true : false,
"subspace",
order === "descending" ? true : false,
)
) {
const payload = await this.payloadDriver.get(entry.payloadDigest);
Expand Down Expand Up @@ -828,7 +828,7 @@ export class Store<
start: entry.timestamp,
end: entry.timestamp + 1n,
},
}, "newest")
}, "descending")
) {
authToken = token;
}
Expand Down
2 changes: 1 addition & 1 deletion src/wgps/reconciliation/announcer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export class Announcer<
entry,
payload,
authToken,
] of announcement.store.queryRange(announcement.range, "oldest")
] of announcement.store.queryRange(announcement.range, "ascending")
) {
const [staticToken, dynamicToken] = this.authorisationTokenScheme
.decomposeAuthToken(authToken);
Expand Down
2 changes: 1 addition & 1 deletion src/wgps/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ export type MsgReconciliationAnnounceEntries<SubspaceId> = Msg<
isEmpty: boolean;
/** A boolean flag to indicate whether the sender wishes to receive a ReconciliationAnnounceEntries message for the same 3dRange in return. */
wantResponse: boolean;
/** Whether the sender promises to send the Entries in the range sorted from oldest to newest. */
/** Whether the sender promises to send the Entries in the range sorted ascendingly by subspace_id first, path second. */
willSort: boolean;
/** An AreaOfInterestHandle, bound by the sender of this message, that fully contains the range. */
senderHandle: bigint;
Expand Down

0 comments on commit acc12cf

Please sign in to comment.