@fluidframework/container-loader 2.0.0-rc.4.0.5 → 2.0.0-rc.5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/api-extractor/api-extractor-lint-bundle.json +5 -0
- package/api-extractor/api-extractor-lint-legacy.cjs.json +5 -0
- package/api-extractor/api-extractor-lint-legacy.esm.json +5 -0
- package/api-extractor/api-extractor-lint-public.cjs.json +5 -0
- package/api-extractor/api-extractor-lint-public.esm.json +5 -0
- package/api-extractor.json +1 -1
- package/api-report/{container-loader.api.md → container-loader.alpha.api.md} +60 -17
- package/api-report/container-loader.beta.api.md +44 -0
- package/api-report/container-loader.public.api.md +44 -0
- package/biome.jsonc +4 -0
- package/dist/attachment.d.ts +1 -1
- package/dist/attachment.d.ts.map +1 -1
- package/dist/attachment.js.map +1 -1
- package/dist/audience.d.ts +3 -2
- package/dist/audience.d.ts.map +1 -1
- package/dist/audience.js.map +1 -1
- package/dist/catchUpMonitor.d.ts.map +1 -1
- package/dist/catchUpMonitor.js.map +1 -1
- package/dist/connectionManager.d.ts +4 -3
- package/dist/connectionManager.d.ts.map +1 -1
- package/dist/connectionManager.js +7 -8
- package/dist/connectionManager.js.map +1 -1
- package/dist/connectionStateHandler.d.ts +1 -1
- package/dist/connectionStateHandler.d.ts.map +1 -1
- package/dist/connectionStateHandler.js +8 -4
- package/dist/connectionStateHandler.js.map +1 -1
- package/dist/container.d.ts +3 -2
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +78 -80
- package/dist/container.js.map +1 -1
- package/dist/containerContext.d.ts +2 -2
- package/dist/containerContext.d.ts.map +1 -1
- package/dist/containerContext.js.map +1 -1
- package/dist/containerStorageAdapter.d.ts +5 -4
- package/dist/containerStorageAdapter.d.ts.map +1 -1
- package/dist/containerStorageAdapter.js +24 -8
- package/dist/containerStorageAdapter.js.map +1 -1
- package/dist/contracts.d.ts +2 -2
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js.map +1 -1
- package/dist/debugLogger.d.ts.map +1 -1
- package/dist/debugLogger.js.map +1 -1
- package/dist/deltaManager.d.ts +6 -5
- package/dist/deltaManager.d.ts.map +1 -1
- package/dist/deltaManager.js +15 -16
- package/dist/deltaManager.js.map +1 -1
- package/dist/deltaQueue.d.ts.map +1 -1
- package/dist/deltaQueue.js.map +1 -1
- package/dist/disposal.js.map +1 -1
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/legacy.d.ts +5 -0
- package/dist/loadPaused.js.map +1 -1
- package/dist/loader.d.ts +1 -1
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js.map +1 -1
- package/dist/location-redirection-utilities/resolveWithLocationRedirection.js.map +1 -1
- package/dist/memoryBlobStorage.d.ts.map +1 -1
- package/dist/memoryBlobStorage.js +4 -3
- package/dist/memoryBlobStorage.js.map +1 -1
- package/dist/noopHeuristic.d.ts +1 -1
- package/dist/noopHeuristic.d.ts.map +1 -1
- package/dist/noopHeuristic.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/protocol/index.d.ts +7 -0
- package/dist/protocol/index.d.ts.map +1 -0
- package/dist/protocol/index.js +12 -0
- package/dist/protocol/index.js.map +1 -0
- package/dist/protocol/protocol.d.ts +52 -0
- package/dist/protocol/protocol.d.ts.map +1 -0
- package/dist/protocol/protocol.js +112 -0
- package/dist/protocol/protocol.js.map +1 -0
- package/dist/protocol/quorum.d.ts +185 -0
- package/dist/protocol/quorum.d.ts.map +1 -0
- package/dist/protocol/quorum.js +419 -0
- package/dist/protocol/quorum.js.map +1 -0
- package/dist/protocol.d.ts +4 -4
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +6 -6
- package/dist/protocol.js.map +1 -1
- package/dist/protocolTreeDocumentStorageService.d.ts +16 -9
- package/dist/protocolTreeDocumentStorageService.d.ts.map +1 -1
- package/dist/protocolTreeDocumentStorageService.js +18 -9
- package/dist/protocolTreeDocumentStorageService.js.map +1 -1
- package/dist/quorum.d.ts +1 -1
- package/dist/quorum.d.ts.map +1 -1
- package/dist/quorum.js.map +1 -1
- package/dist/retriableDocumentStorageService.d.ts +2 -2
- package/dist/retriableDocumentStorageService.d.ts.map +1 -1
- package/dist/retriableDocumentStorageService.js +3 -1
- package/dist/retriableDocumentStorageService.js.map +1 -1
- package/dist/serializedStateManager.d.ts +5 -5
- package/dist/serializedStateManager.d.ts.map +1 -1
- package/dist/serializedStateManager.js +16 -12
- package/dist/serializedStateManager.js.map +1 -1
- package/dist/utils.d.ts +2 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +7 -7
- package/dist/utils.js.map +1 -1
- package/lib/attachment.d.ts +1 -1
- package/lib/attachment.d.ts.map +1 -1
- package/lib/attachment.js.map +1 -1
- package/lib/audience.d.ts +3 -2
- package/lib/audience.d.ts.map +1 -1
- package/lib/audience.js.map +1 -1
- package/lib/catchUpMonitor.d.ts.map +1 -1
- package/lib/catchUpMonitor.js.map +1 -1
- package/lib/connectionManager.d.ts +4 -3
- package/lib/connectionManager.d.ts.map +1 -1
- package/lib/connectionManager.js +6 -7
- package/lib/connectionManager.js.map +1 -1
- package/lib/connectionStateHandler.d.ts +1 -1
- package/lib/connectionStateHandler.d.ts.map +1 -1
- package/lib/connectionStateHandler.js +8 -4
- package/lib/connectionStateHandler.js.map +1 -1
- package/lib/container.d.ts +3 -2
- package/lib/container.d.ts.map +1 -1
- package/lib/container.js +20 -22
- package/lib/container.js.map +1 -1
- package/lib/containerContext.d.ts +2 -2
- package/lib/containerContext.d.ts.map +1 -1
- package/lib/containerContext.js.map +1 -1
- package/lib/containerStorageAdapter.d.ts +5 -4
- package/lib/containerStorageAdapter.d.ts.map +1 -1
- package/lib/containerStorageAdapter.js +24 -8
- package/lib/containerStorageAdapter.js.map +1 -1
- package/lib/contracts.d.ts +2 -2
- package/lib/contracts.d.ts.map +1 -1
- package/lib/contracts.js.map +1 -1
- package/lib/debugLogger.d.ts.map +1 -1
- package/lib/debugLogger.js.map +1 -1
- package/lib/deltaManager.d.ts +6 -5
- package/lib/deltaManager.d.ts.map +1 -1
- package/lib/deltaManager.js +8 -9
- package/lib/deltaManager.js.map +1 -1
- package/lib/deltaQueue.d.ts.map +1 -1
- package/lib/deltaQueue.js.map +1 -1
- package/lib/disposal.js.map +1 -1
- package/lib/error.d.ts.map +1 -1
- package/lib/error.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/legacy.d.ts +5 -0
- package/lib/loadPaused.js.map +1 -1
- package/lib/loader.d.ts +1 -1
- package/lib/loader.d.ts.map +1 -1
- package/lib/loader.js.map +1 -1
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.js.map +1 -1
- package/lib/memoryBlobStorage.d.ts.map +1 -1
- package/lib/memoryBlobStorage.js +4 -3
- package/lib/memoryBlobStorage.js.map +1 -1
- package/lib/noopHeuristic.d.ts +1 -1
- package/lib/noopHeuristic.d.ts.map +1 -1
- package/lib/noopHeuristic.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/protocol/index.d.ts +7 -0
- package/lib/protocol/index.d.ts.map +1 -0
- package/lib/protocol/index.js +7 -0
- package/lib/protocol/index.js.map +1 -0
- package/lib/protocol/protocol.d.ts +52 -0
- package/lib/protocol/protocol.d.ts.map +1 -0
- package/lib/protocol/protocol.js +108 -0
- package/lib/protocol/protocol.js.map +1 -0
- package/lib/protocol/quorum.d.ts +185 -0
- package/lib/protocol/quorum.d.ts.map +1 -0
- package/lib/protocol/quorum.js +410 -0
- package/lib/protocol/quorum.js.map +1 -0
- package/lib/protocol.d.ts +4 -4
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +2 -2
- package/lib/protocol.js.map +1 -1
- package/lib/protocolTreeDocumentStorageService.d.ts +16 -9
- package/lib/protocolTreeDocumentStorageService.d.ts.map +1 -1
- package/lib/protocolTreeDocumentStorageService.js +18 -9
- package/lib/protocolTreeDocumentStorageService.js.map +1 -1
- package/lib/quorum.d.ts +1 -1
- package/lib/quorum.d.ts.map +1 -1
- package/lib/quorum.js.map +1 -1
- package/lib/retriableDocumentStorageService.d.ts +2 -2
- package/lib/retriableDocumentStorageService.d.ts.map +1 -1
- package/lib/retriableDocumentStorageService.js +3 -1
- package/lib/retriableDocumentStorageService.js.map +1 -1
- package/lib/serializedStateManager.d.ts +5 -5
- package/lib/serializedStateManager.d.ts.map +1 -1
- package/lib/serializedStateManager.js +17 -13
- package/lib/serializedStateManager.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/lib/utils.d.ts +2 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +3 -3
- package/lib/utils.js.map +1 -1
- package/package.json +32 -31
- package/src/attachment.ts +8 -5
- package/src/audience.ts +4 -7
- package/src/catchUpMonitor.ts +4 -2
- package/src/connectionManager.ts +27 -24
- package/src/connectionStateHandler.ts +11 -10
- package/src/container.ts +64 -72
- package/src/containerContext.ts +5 -5
- package/src/containerStorageAdapter.ts +37 -22
- package/src/contracts.ts +4 -5
- package/src/debugLogger.ts +2 -3
- package/src/deltaManager.ts +13 -18
- package/src/deltaQueue.ts +4 -1
- package/src/error.ts +4 -1
- package/src/index.ts +7 -0
- package/src/loadPaused.ts +1 -1
- package/src/loader.ts +1 -1
- package/src/memoryBlobStorage.ts +6 -4
- package/src/noopHeuristic.ts +1 -1
- package/src/packageVersion.ts +1 -1
- package/src/protocol/README.md +10 -0
- package/src/protocol/index.ts +16 -0
- package/src/protocol/protocol.ts +185 -0
- package/src/protocol/quorum.ts +577 -0
- package/src/protocol.ts +6 -9
- package/src/protocolTreeDocumentStorageService.ts +30 -13
- package/src/quorum.ts +1 -1
- package/src/retriableDocumentStorageService.ts +6 -7
- package/src/serializedStateManager.ts +33 -34
- package/src/utils.ts +16 -10
- package/tsconfig.json +2 -0
- package/tsdoc.json +4 -0
package/src/loader.ts
CHANGED
|
@@ -19,13 +19,13 @@ import {
|
|
|
19
19
|
IRequest,
|
|
20
20
|
ITelemetryBaseLogger,
|
|
21
21
|
} from "@fluidframework/core-interfaces";
|
|
22
|
+
import { IClientDetails } from "@fluidframework/driver-definitions";
|
|
22
23
|
import {
|
|
23
24
|
IDocumentServiceFactory,
|
|
24
25
|
IDocumentStorageService,
|
|
25
26
|
IResolvedUrl,
|
|
26
27
|
IUrlResolver,
|
|
27
28
|
} from "@fluidframework/driver-definitions/internal";
|
|
28
|
-
import { IClientDetails } from "@fluidframework/protocol-definitions";
|
|
29
29
|
import {
|
|
30
30
|
ITelemetryLoggerExt,
|
|
31
31
|
MonitoringContext,
|
package/src/memoryBlobStorage.ts
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { ICreateBlobResponse } from "@fluidframework/protocol-definitions";
|
|
7
6
|
import { bufferToString, stringToBuffer } from "@fluid-internal/client-utils";
|
|
8
7
|
import { assert, isObject } from "@fluidframework/core-utils/internal";
|
|
8
|
+
import type { ICreateBlobResponse } from "@fluidframework/driver-definitions/internal";
|
|
9
|
+
|
|
9
10
|
// eslint-disable-next-line import/no-deprecated
|
|
10
11
|
import type { IDetachedBlobStorage } from "./loader.js";
|
|
11
12
|
|
|
@@ -25,7 +26,8 @@ function isMemoryDetachedBlobStorage(
|
|
|
25
26
|
return (
|
|
26
27
|
isObject(detachedStorage) &&
|
|
27
28
|
MemoryDetachedBlobStorageIdentifier in detachedStorage &&
|
|
28
|
-
detachedStorage[MemoryDetachedBlobStorageIdentifier] ===
|
|
29
|
+
detachedStorage[MemoryDetachedBlobStorageIdentifier] ===
|
|
30
|
+
MemoryDetachedBlobStorageIdentifier
|
|
29
31
|
);
|
|
30
32
|
}
|
|
31
33
|
|
|
@@ -49,9 +51,9 @@ export function tryInitializeMemoryDetachedBlobStorage(
|
|
|
49
51
|
);
|
|
50
52
|
}
|
|
51
53
|
|
|
52
|
-
assert(detachedStorage.size === 0,
|
|
54
|
+
assert(detachedStorage.size === 0, 0x99e /* Blob storage already initialized */);
|
|
53
55
|
const maybeAttachmentBlobs = JSON.parse(attachmentBlobs);
|
|
54
|
-
assert(Array.isArray(maybeAttachmentBlobs),
|
|
56
|
+
assert(Array.isArray(maybeAttachmentBlobs), 0x99f /* Invalid attachmentBlobs */);
|
|
55
57
|
|
|
56
58
|
detachedStorage.initialize(maybeAttachmentBlobs);
|
|
57
59
|
}
|
package/src/noopHeuristic.ts
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
import { TypedEventEmitter } from "@fluid-internal/client-utils";
|
|
7
7
|
import { IEvent } from "@fluidframework/core-interfaces";
|
|
8
8
|
import { assert, Timer } from "@fluidframework/core-utils/internal";
|
|
9
|
+
import { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
|
|
9
10
|
import { isRuntimeMessage } from "@fluidframework/driver-utils/internal";
|
|
10
|
-
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
11
11
|
|
|
12
12
|
const defaultNoopTimeFrequency = 2000;
|
|
13
13
|
const defaultNoopCountFrequency = 50;
|
package/src/packageVersion.ts
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# @fluidframework/container-loader/src/protocol
|
|
2
|
+
|
|
3
|
+
These files should be aligned with the service side definitions contained here:
|
|
4
|
+
|
|
5
|
+
server/routerlicious/packages/protocol-base
|
|
6
|
+
|
|
7
|
+
## Notes
|
|
8
|
+
|
|
9
|
+
The file names in this directory align with those in server/protocol-base to facilitate
|
|
10
|
+
copying/synchronization in the future, if desireable.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export {
|
|
7
|
+
IProtocolHandler as IBaseProtocolHandler,
|
|
8
|
+
ProtocolOpHandler,
|
|
9
|
+
IScribeProtocolState,
|
|
10
|
+
} from "./protocol.js";
|
|
11
|
+
export {
|
|
12
|
+
IQuorumSnapshot,
|
|
13
|
+
Quorum,
|
|
14
|
+
QuorumClientsSnapshot,
|
|
15
|
+
QuorumProposalsSnapshot,
|
|
16
|
+
} from "./quorum.js";
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { ISequencedClient } from "@fluidframework/driver-definitions";
|
|
7
|
+
import { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
|
|
8
|
+
import {
|
|
9
|
+
IDocumentAttributes,
|
|
10
|
+
IClientJoin,
|
|
11
|
+
ICommittedProposal,
|
|
12
|
+
IProcessMessageResult,
|
|
13
|
+
IProposal,
|
|
14
|
+
IQuorum,
|
|
15
|
+
ISequencedDocumentSystemMessage,
|
|
16
|
+
ISequencedProposal,
|
|
17
|
+
MessageType,
|
|
18
|
+
} from "@fluidframework/driver-definitions/internal";
|
|
19
|
+
|
|
20
|
+
import { IQuorumSnapshot, Quorum } from "./quorum.js";
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @alpha
|
|
24
|
+
*/
|
|
25
|
+
export interface IScribeProtocolState {
|
|
26
|
+
sequenceNumber: number;
|
|
27
|
+
minimumSequenceNumber: number;
|
|
28
|
+
members: [string, ISequencedClient][];
|
|
29
|
+
proposals: [number, ISequencedProposal, string[]][];
|
|
30
|
+
values: [string, ICommittedProposal][];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @alpha
|
|
35
|
+
*/
|
|
36
|
+
export interface IProtocolHandler {
|
|
37
|
+
readonly quorum: IQuorum;
|
|
38
|
+
readonly attributes: IDocumentAttributes;
|
|
39
|
+
|
|
40
|
+
setConnectionState(connected: boolean, clientId: string | undefined);
|
|
41
|
+
snapshot(): IQuorumSnapshot;
|
|
42
|
+
|
|
43
|
+
close(): void;
|
|
44
|
+
processMessage(message: ISequencedDocumentMessage, local: boolean): IProcessMessageResult;
|
|
45
|
+
getProtocolState(): IScribeProtocolState;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Handles protocol specific ops.
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
|
+
export class ProtocolOpHandler implements IProtocolHandler {
|
|
53
|
+
private readonly _quorum: Quorum;
|
|
54
|
+
public get quorum(): Quorum {
|
|
55
|
+
return this._quorum;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
constructor(
|
|
59
|
+
public minimumSequenceNumber: number,
|
|
60
|
+
public sequenceNumber: number,
|
|
61
|
+
members: [string, ISequencedClient][],
|
|
62
|
+
proposals: [number, ISequencedProposal, string[]][],
|
|
63
|
+
values: [string, ICommittedProposal][],
|
|
64
|
+
sendProposal: (key: string, value: any) => number,
|
|
65
|
+
) {
|
|
66
|
+
this._quorum = new Quorum(members, proposals, values, sendProposal);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public get attributes(): IDocumentAttributes {
|
|
70
|
+
return {
|
|
71
|
+
minimumSequenceNumber: this.minimumSequenceNumber,
|
|
72
|
+
sequenceNumber: this.sequenceNumber,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
setConnectionState(connected: boolean, clientId: string | undefined) {
|
|
77
|
+
this._quorum.setConnectionState(connected, clientId);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
snapshot(): IQuorumSnapshot {
|
|
81
|
+
return this._quorum.snapshot();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public close() {
|
|
85
|
+
this._quorum.close();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
public processMessage(
|
|
89
|
+
message: ISequencedDocumentMessage,
|
|
90
|
+
local: boolean,
|
|
91
|
+
): IProcessMessageResult {
|
|
92
|
+
// verify it's moving sequentially
|
|
93
|
+
if (message.sequenceNumber !== this.sequenceNumber + 1) {
|
|
94
|
+
throw new Error(
|
|
95
|
+
`Protocol state is not moving sequentially. ` +
|
|
96
|
+
`Current is ${this.sequenceNumber}. Next is ${message.sequenceNumber}`,
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Update tracked sequence numbers
|
|
101
|
+
this.sequenceNumber = message.sequenceNumber;
|
|
102
|
+
this.minimumSequenceNumber = message.minimumSequenceNumber;
|
|
103
|
+
|
|
104
|
+
let immediateNoOp = false;
|
|
105
|
+
|
|
106
|
+
/* eslint-disable no-case-declarations */
|
|
107
|
+
|
|
108
|
+
switch (message.type) {
|
|
109
|
+
case MessageType.ClientJoin:
|
|
110
|
+
const systemJoinMessage = message as ISequencedDocumentSystemMessage;
|
|
111
|
+
const join = JSON.parse(systemJoinMessage.data) as IClientJoin;
|
|
112
|
+
const member: ISequencedClient = {
|
|
113
|
+
client: join.detail,
|
|
114
|
+
sequenceNumber: systemJoinMessage.sequenceNumber,
|
|
115
|
+
};
|
|
116
|
+
this._quorum.addMember(join.clientId, member);
|
|
117
|
+
break;
|
|
118
|
+
|
|
119
|
+
case MessageType.ClientLeave:
|
|
120
|
+
const systemLeaveMessage = message as ISequencedDocumentSystemMessage;
|
|
121
|
+
const clientId = JSON.parse(systemLeaveMessage.data) as string;
|
|
122
|
+
this._quorum.removeMember(clientId);
|
|
123
|
+
break;
|
|
124
|
+
|
|
125
|
+
case MessageType.Propose:
|
|
126
|
+
// back-compat: ADO #1385: This should become unconditional eventually.
|
|
127
|
+
// Can be done only after Container.processRemoteMessage() stops parsing content!
|
|
128
|
+
if (typeof message.contents === "string") {
|
|
129
|
+
message.contents = JSON.parse(message.contents);
|
|
130
|
+
}
|
|
131
|
+
const proposal = message.contents as IProposal;
|
|
132
|
+
this._quorum.addProposal(
|
|
133
|
+
proposal.key,
|
|
134
|
+
proposal.value,
|
|
135
|
+
message.sequenceNumber,
|
|
136
|
+
local,
|
|
137
|
+
message.clientSequenceNumber,
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
// On a quorum proposal, immediately send a response to expedite the approval.
|
|
141
|
+
immediateNoOp = true;
|
|
142
|
+
break;
|
|
143
|
+
|
|
144
|
+
default:
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/* eslint-enable no-case-declarations */
|
|
148
|
+
|
|
149
|
+
// Notify the quorum of the MSN from the message. We rely on it to handle duplicate values but may
|
|
150
|
+
// want to move that logic to this class.
|
|
151
|
+
this._quorum.updateMinimumSequenceNumber(message);
|
|
152
|
+
|
|
153
|
+
return { immediateNoOp };
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Gets the scribe protocol state
|
|
158
|
+
* @param scrubUserData - whether to remove all user data from the quorum members. CAUTION: this will corrupt the quorum if used in a summary.
|
|
159
|
+
*/
|
|
160
|
+
public getProtocolState(scrubUserData = false): IScribeProtocolState {
|
|
161
|
+
// return a new object every time
|
|
162
|
+
// this ensures future state changes will not affect outside callers
|
|
163
|
+
const snapshot = this._quorum.snapshot();
|
|
164
|
+
|
|
165
|
+
if (scrubUserData) {
|
|
166
|
+
// In place, remove any identifying client information
|
|
167
|
+
snapshot.members = snapshot.members.map(([id, sequencedClient]) => [
|
|
168
|
+
id,
|
|
169
|
+
{
|
|
170
|
+
...sequencedClient,
|
|
171
|
+
client: {
|
|
172
|
+
...sequencedClient.client,
|
|
173
|
+
user: { id: "" },
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
]);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return {
|
|
180
|
+
sequenceNumber: this.sequenceNumber,
|
|
181
|
+
minimumSequenceNumber: this.minimumSequenceNumber,
|
|
182
|
+
...snapshot,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
}
|