Skip to content

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.

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).

compactedCount: number

Defined in: packages/core/src/snapshot-node.ts:32

Number of change nodes compacted into this snapshot. Used to compare snapshots — higher count means more compaction.


lastChangeNodeCID: string

Defined in: packages/core/src/snapshot-node.ts:26

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: Uint8Array

Defined in: packages/core/src/snapshot-node.ts:41

Signature of the snapshot creator. Signs a versioned binary payload: [version(1B), timestamp(8B uint64), compactedCount(4B uint32), cidLen(4B uint32), lastChangeNodeCID(cidLen B), stateLen(4B uint32), stateBytes(stateLen B)]. All integers are big-endian. Verified by trying every authorized writer key.


state: ChangesType

Defined in: packages/core/src/snapshot-node.ts:20

Full serialized CRDT state at this point. Produced by CRDTProvider.getSnapshot(doc).


timestamp: number

Defined in: packages/core/src/snapshot-node.ts:46

Timestamp of snapshot creation (milliseconds since epoch).