Skip to content

CompactionConfig

Defined in: packages/core/src/compaction-config.ts:7

Configuration for history compaction behavior.

Compaction creates snapshot nodes in the Merkle-DAG that summarize the full CRDT state, allowing peers to skip replaying the full change history.

enabled: boolean

Defined in: packages/core/src/compaction-config.ts:9

Enable automatic compaction; when false, only manual document.snapshot() is available.


gcAfterPrune: boolean

Defined in: packages/core/src/compaction-config.ts:33

After pruning the in-memory sync tree, delete the orphaned blocks from the Helia blockstore. Opt-in because deletion is destructive: once a block is gone, peers that lazy-load it via PeerborneDocument.loadChangeBlock or that re-broadcast the change will not be able to fetch the data locally.

Only blocks that are no longer reachable from the in-memory sync tree (and are not the snapshot boundary CID) are deleted, so accidentally re-attached ACL nodes are safe. CIDs remain in the in-memory _hashes set so duplicate incoming sync messages are still deduplicated.

Has no effect when pruneAfterSnapshot is false.


keepRecentNodes: number

Defined in: packages/core/src/compaction-config.ts:36

Keep at least N recent change nodes after pruning so slightly-behind peers can catch up.


minChangesBeforeSnapshot: number

Defined in: packages/core/src/compaction-config.ts:15

Minimum document changes before the first snapshot, to avoid premature snapshots.


pruneAfterSnapshot: boolean

Defined in: packages/core/src/compaction-config.ts:18

Prune old nodes from the in-memory sync tree after a snapshot. ACL nodes are always preserved.


snapshotInterval: number

Defined in: packages/core/src/compaction-config.ts:12

Create a snapshot every N document changes (ACL changes do not count).