Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NDNts-aux snapshot v1.1 #10

Merged
merged 19 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/adaptors/yjs-ndn-adaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ export class NdnSvsAdaptor {
public syncAgent: SyncAgent,
public readonly doc: Y.Doc,
public readonly topic: string,
public readonly snapshotTopic: string = 'snapshot',
public readonly snapshotFrequency: number = 10,
useBundler: boolean = false,
public readonly snapshotInterval: number = 100,
public readonly snapshotTopic: string = 'snapshot',
) {
syncAgent.register('update', topic, (content) => this.handleSyncUpdate(content));
syncAgent.register('blob', snapshotTopic, (content) => this.handleSnapshotUpdate(content));
Expand Down Expand Up @@ -116,7 +116,7 @@ export class NdnSvsAdaptor {
count += seq;
}

if (count % this.snapshotFrequency == 0) {
if (count % this.snapshotInterval == 0) {
const encodedSV = Encoder.encode(stateVector);

// NOTE: The following code depend on snapshot naming convention to work.
Expand All @@ -130,7 +130,7 @@ export class NdnSvsAdaptor {
const content = Y.encodeStateAsUpdate(this.doc);
// its already in UInt8Array (binary), transporting currently without any additional encoding.
// use syncAgent's blob and publish mechanism
await this.syncAgent.publishBlob('snapshot', content, snapshotName, true);
await this.syncAgent.publishBlob(this.snapshotTopic, content, snapshotName, true);

// NOTE: The following code depend on snapshot naming convention to work.
// Verify this part if there's a change in naming convention.
Expand Down
2 changes: 2 additions & 0 deletions src/workspace/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class Workspace implements AsyncDisposable {
createNewDoc?: () => Promise<void>;
useBundler?: boolean;
groupKeyBits?: Uint8Array;
snapshotInterval?: number;
}) {
// Always init a new one, and then load.
if (opts.createNewDoc) {
Expand All @@ -54,6 +55,7 @@ export class Workspace implements AsyncDisposable {
opts.rootDoc,
'doc',
opts.useBundler ?? false,
opts.snapshotInterval ?? 100,
);
const yjsSnapshotMgr = new YjsStateManager(
() => encodeSyncState(syncAgent!.getUpdateSyncSV()),
Expand Down