CRDTSnapshotNode
Defined in: packages/core/src/snapshot-node.ts:15
A snapshot node represents a compacted point in the Merkle-DAG change history.
Instead of replaying individual change nodes from the beginning, a peer can load the snapshot state and then apply only post-snapshot changes.
Type Parameters
Section titled “Type Parameters”ChangesType
Section titled “ChangesType”ChangesType
The serialized CRDT type used for both incremental changes
and full-state snapshots. The state field contains a snapshot produced by
CRDTProvider.getSnapshot(). When the snapshot format differs from incremental
changes, it is applied via CRDTProvider.applySnapshot(); otherwise it falls
back to remoteChange().
For Yjs this is Uint8Array (from encodeStateAsUpdateV2); for Automerge
this is BinaryChange[] (wrapping Automerge.save() output).
Properties
Section titled “Properties”compactedCount
Section titled “compactedCount”compactedCount:
number
Defined in: packages/core/src/snapshot-node.ts:35
Number of change nodes compacted into this snapshot. A replica that cannot merge snapshots prefers the higher count among snapshots that do not include one another.
includes?
Section titled “includes?”
optionalincludes?: readonlystring[]
Defined in: packages/core/src/snapshot-node.ts:45
Identities of earlier snapshots whose state this snapshot includes, newest first: the snapshot its creator held, the snapshots it merged, and those they included, at most 32. An identity is the hex SHA-256 of a snapshot’s signature payload. A replica replaces its snapshot only with one that lists it; otherwise it applies the other state too and, as a writer, snapshots the merged state. Absent means none.
lastChangeNodeCID
Section titled “lastChangeNodeCID”lastChangeNodeCID:
string
Defined in: packages/core/src/snapshot-node.ts:28
CID of the most recent change node included in this snapshot. All change nodes up to (and including) this CID are represented by the snapshot state.
signature
Section titled “signature”signature:
Uint8Array
Defined in: packages/core/src/snapshot-node.ts:52
Signature of the snapshot creator over the payload that
buildSnapshotSignaturePayload() builds from the document path and the
other fields. Verified by trying every authorized writer key.
state:
ChangesType
Defined in: packages/core/src/snapshot-node.ts:22
Full serialized CRDT state at this point.
Produced by CRDTProvider.getSnapshot(doc). With a provider that has an
actorBinding, the state carries the manifest of its actors’
registrations, which actorBinding.detach() separates.
timestamp
Section titled “timestamp”timestamp:
number
Defined in: packages/core/src/snapshot-node.ts:57
Timestamp of snapshot creation (milliseconds since epoch).