Skip to content

Commit

Permalink
add prevData to commit event
Browse files Browse the repository at this point in the history
  • Loading branch information
dholms committed Feb 5, 2025
1 parent 56abefb commit 991f1cb
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lexicons/com/atproto/sync/subscribeRepos.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@
"description": "List of new blobs (by CID) referenced by records in this commit."
}
},
"prevData": {
"type": "cid-link",
"description": "EXPERIMENTAL. The root CID of the MST tree for the previous commit from this repo (indicated by the 'since' revision field in this message). Corresponds to the 'data' field in the repo commit object. NOTE: this field is effectively required for the 'inductive' version of firehose."
},
"time": {
"type": "string",
"format": "datetime",
Expand Down
5 changes: 5 additions & 0 deletions packages/api/src/client/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3827,6 +3827,11 @@ export const schemaDict = {
'List of new blobs (by CID) referenced by records in this commit.',
},
},
prevData: {
type: 'cid-link',
description:
"EXPERIMENTAL. The root CID of the MST tree for the previous commit from this repo (indicated by the 'since' revision field in this message). Corresponds to the 'data' field in the repo commit object. NOTE: this field is effectively required for the 'inductive' version of firehose.",
},
time: {
type: 'string',
format: 'datetime',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export interface Commit {
blocks: Uint8Array
ops: RepoOp[]
blobs: CID[]
/** EXPERIMENTAL. The root CID of the MST tree for the previous commit from this repo (indicated by the 'since' revision field in this message). Corresponds to the 'data' field in the repo commit object. NOTE: this field is effectively required for the 'inductive' version of firehose. */
prevData?: CID
/** Timestamp of when this message was originally broadcast. */
time: string
[k: string]: unknown
Expand Down
5 changes: 5 additions & 0 deletions packages/bsky/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3827,6 +3827,11 @@ export const schemaDict = {
'List of new blobs (by CID) referenced by records in this commit.',
},
},
prevData: {
type: 'cid-link',
description:
"EXPERIMENTAL. The root CID of the MST tree for the previous commit from this repo (indicated by the 'since' revision field in this message). Corresponds to the 'data' field in the repo commit object. NOTE: this field is effectively required for the 'inductive' version of firehose.",
},
time: {
type: 'string',
format: 'datetime',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ export interface Commit {
blocks: Uint8Array
ops: RepoOp[]
blobs: CID[]
/** EXPERIMENTAL. The root CID of the MST tree for the previous commit from this repo (indicated by the 'since' revision field in this message). Corresponds to the 'data' field in the repo commit object. NOTE: this field is effectively required for the 'inductive' version of firehose. */
prevData?: CID
/** Timestamp of when this message was originally broadcast. */
time: string
[k: string]: unknown
Expand Down
5 changes: 5 additions & 0 deletions packages/ozone/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3827,6 +3827,11 @@ export const schemaDict = {
'List of new blobs (by CID) referenced by records in this commit.',
},
},
prevData: {
type: 'cid-link',
description:
"EXPERIMENTAL. The root CID of the MST tree for the previous commit from this repo (indicated by the 'since' revision field in this message). Corresponds to the 'data' field in the repo commit object. NOTE: this field is effectively required for the 'inductive' version of firehose.",
},
time: {
type: 'string',
format: 'datetime',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ export interface Commit {
blocks: Uint8Array
ops: RepoOp[]
blobs: CID[]
/** EXPERIMENTAL. The root CID of the MST tree for the previous commit from this repo (indicated by the 'since' revision field in this message). Corresponds to the 'data' field in the repo commit object. NOTE: this field is effectively required for the 'inductive' version of firehose. */
prevData?: CID
/** Timestamp of when this message was originally broadcast. */
time: string
[k: string]: unknown
Expand Down
3 changes: 3 additions & 0 deletions packages/pds/src/actor-store/repo/transactor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export class RepoTransactor extends RepoReader {
...commit,
ops: commitOpsFromCreates(writes),
blobs: blobCidsFromWrites(writes),
prevData: null,
}
}

Expand Down Expand Up @@ -140,6 +141,7 @@ export class RepoTransactor extends RepoReader {
}

const repo = await Repo.load(this.storage, currRoot.cid)
const prevData = repo.commit.data
const writeOps = writes.map(writeToOp)
const commit = await repo.formatCommit(writeOps, this.signingKey)

Expand All @@ -165,6 +167,7 @@ export class RepoTransactor extends RepoReader {
...commit,
ops: commitOps,
blobs: blobCidsFromWrites(writes),
prevData,
}
}

Expand Down
1 change: 1 addition & 0 deletions packages/pds/src/api/com/atproto/server/activateAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default function (server: Server, ctx: AppContext) {
removedCids: new CidSet(),
ops: [],
blobs: new CidSet(),
prevData: null,
}
})

Expand Down
5 changes: 5 additions & 0 deletions packages/pds/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3827,6 +3827,11 @@ export const schemaDict = {
'List of new blobs (by CID) referenced by records in this commit.',
},
},
prevData: {
type: 'cid-link',
description:
"EXPERIMENTAL. The root CID of the MST tree for the previous commit from this repo (indicated by the 'since' revision field in this message). Corresponds to the 'data' field in the repo commit object. NOTE: this field is effectively required for the 'inductive' version of firehose.",
},
time: {
type: 'string',
format: 'datetime',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ export interface Commit {
blocks: Uint8Array
ops: RepoOp[]
blobs: CID[]
/** EXPERIMENTAL. The root CID of the MST tree for the previous commit from this repo (indicated by the 'since' revision field in this message). Corresponds to the 'data' field in the repo commit object. NOTE: this field is effectively required for the 'inductive' version of firehose. */
prevData?: CID
/** Timestamp of when this message was originally broadcast. */
time: string
[k: string]: unknown
Expand Down
1 change: 1 addition & 0 deletions packages/pds/src/repo/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export type CommitOp = {
export type CommitDataWithOps = CommitData & {
ops: CommitOp[]
blobs: CidSet
prevData: CID | null
}

export type PreparedWrite = PreparedCreate | PreparedUpdate | PreparedDelete
Expand Down
1 change: 1 addition & 0 deletions packages/pds/src/scripts/rebuild-repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export const rebuildRepo = async (ctx: AppContext, args: string[]) => {
removedCids: toDelete,
ops: [],
blobs: new CidSet(),
prevData: null,
}
})
await ctx.accountManager.updateRepoRoot(did, commit.cid, rev)
Expand Down
3 changes: 3 additions & 0 deletions packages/pds/src/sequencer/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const formatSeqCommit = async (
blocks: await blocksToCarFile(commitData.cid, justRoot),
ops: [],
blobs: [],
prevData: commitData.prevData ?? undefined,
}
} else {
evt = {
Expand All @@ -47,6 +48,7 @@ export const formatSeqCommit = async (
blocks: await blocksToCarFile(commitData.cid, blocksToSend),
ops: commitData.ops,
blobs: commitData.blobs.toList(),
prevData: commitData.prevData ?? undefined,
}
}

Expand Down Expand Up @@ -149,6 +151,7 @@ export const commitEvt = z.object({
blocks: schema.bytes,
ops: z.array(commitEvtOp),
blobs: z.array(schema.cid),
prevData: schema.cid.optional(),
})
export type CommitEvt = z.infer<typeof commitEvt>

Expand Down

0 comments on commit 991f1cb

Please sign in to comment.