Skip to content

Commit

Permalink
feat: disable anchoring via env var (#3281)
Browse files Browse the repository at this point in the history
* feat: disable anchoring via env var

* chore: remove log
  • Loading branch information
smrz2001 authored Oct 1, 2024
1 parent 6491d12 commit 8616ca3
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/core/src/state-management/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,9 @@ export class Repository {
async applyCommit(streamId: StreamID, commit: any, opts: UpdateOpts): Promise<RunningState> {
this.logger.verbose(`Repository apply commit to stream ${streamId.toString()}`)

this.anchorService.assertCASAccessible()
if (process.env.CERAMIC_DISABLE_ANCHORING !== 'true') {
this.anchorService.assertCASAccessible()
}

const state$ = await this.load(streamId)
this.logger.verbose(`Repository loaded state for stream ${streamId.toString()}`)
Expand Down Expand Up @@ -678,6 +680,9 @@ export class Repository {
if (state$.value.anchorStatus == AnchorStatus.ANCHORED) {
return
}
if (process.env.CERAMIC_DISABLE_ANCHORING === 'true') {
return
}

const anchorEvent = await this.anchorService.requestAnchor(state$.id, state$.tip)
// Don't wait on handling the anchor event, let that happen in the background.
Expand Down Expand Up @@ -923,8 +928,9 @@ export class Repository {
genesis: any,
opts: CreateOpts = {}
): Promise<RunningState> {
this.anchorService.assertCASAccessible()

if (process.env.CERAMIC_DISABLE_ANCHORING !== 'true') {
this.anchorService.assertCASAccessible()
}
// TODO: WS1-1494 validate genesis commit before storing
const genesisCid = await this.dispatcher.storeInitEvent(genesis, type)
const streamId = new StreamID(type, genesisCid)
Expand Down

0 comments on commit 8616ca3

Please sign in to comment.