Skip to content

Commit

Permalink
Improve workspace. Do not destroy the storage.
Browse files Browse the repository at this point in the history
  • Loading branch information
zjkmxy committed Jan 23, 2024
1 parent 5b9bd23 commit 96f7b38
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 34 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ucla-irl/ndnts-aux",
"version": "1.0.5",
"version": "1.0.7",
"description": "NDNts Auxiliary Package for Web and Deno",
"scripts": {
"test": "deno test",
Expand All @@ -23,7 +23,7 @@
"jose": "^5.2.0",
"tslib": "^2.6.2",
"uuid": "^9.0.1",
"yjs": "^13.6.10"
"yjs": "^13.6.11"
},
"devDependencies": {
"@ndn/endpoint": "https://ndnts-nightly.ndn.today/endpoint.tgz",
Expand Down
58 changes: 29 additions & 29 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/sync-agent/deliveries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ export class AtLeastOnceDelivery extends SyncDelivery {
override async handleSyncUpdate(update: SyncUpdate<Name>) {
const prefix = getNamespace().baseName(update.id, this.syncPrefix);
let lastHandled = update.loSeqNum - 1;
// Modify NDNts's segmented object fetching pipeline to fetch sequences.
// See: https://github.com/zjkmxy/ndn-cc-v3/blob/2128cd8614d8116f7d9dfb17f86f71fbac258739/src/lib/backend/main.ts#L88-L106
for (let i = update.loSeqNum; i <= update.hiSeqNum; i++) {
const name = prefix.append(SequenceNum.create(i));
try {
Expand Down
4 changes: 2 additions & 2 deletions src/sync-agent/sync-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,13 @@ export class SyncAgent {
wire = await this.persistStorage.get(key);
}
if (wire === undefined) {
console.warn(`A remote peer is fetching a non-existing object: ${intName.toString()}`);
// console.warn(`A remote peer is fetching a non-existing object: ${intName.toString()}`);
return undefined;
}
try {
const data = Decoder.decode(wire, Data);
if (isLatestOnly && !data.name.equals(intName)) {
console.log(`A status with not existing version is requested: ${intName.toString()}`);
// console.log(`A status with not existing version is requested: ${intName.toString()}`);
return undefined;
}
return data;
Expand Down
6 changes: 5 additions & 1 deletion src/workspace/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,14 @@ export class Workspace {
);
}

public fireUpdate() {
this.syncAgent.fire();
}

public destroy() {
this.syncAgent.ready = false;
this.yjsSnapshotMgr.destroy();
this.syncAgent.destroy();
this.persistStore.close();
// persistStore is not created by workspace
}
}

0 comments on commit 96f7b38

Please sign in to comment.