Skip to content

Commit

Permalink
@atproto/sync: avoid parsing commits with no relevant ops (bluesky-so…
Browse files Browse the repository at this point in the history
…cial#2906)

* avoid parsing commits with no relevant ops

* changeset
  • Loading branch information
dholms authored Oct 24, 2024
1 parent 8f2b80a commit d605577
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/thirty-llamas-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@atproto/sync": patch
---

avoid parsing commits with no relevant ops
10 changes: 7 additions & 3 deletions packages/sync/src/firehose/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,19 @@ export const parseCommitAuthenticated = async (
forceKeyRefresh = false,
): Promise<CommitEvt[]> => {
const did = evt.repo
const key = await idResolver.did.resolveAtprotoKey(did, forceKeyRefresh)
const claims = maybeFilterOps(evt.ops, filterCollections).map((op) => {
const ops = maybeFilterOps(evt.ops, filterCollections)
if (ops.length === 0) {
return []
}
const claims = ops.map((op) => {
const { collection, rkey } = parseDataKey(op.path)
return {
collection,
rkey,
cid: op.action === 'delete' ? null : op.cid,
}
})
const key = await idResolver.did.resolveAtprotoKey(did, forceKeyRefresh)
const verifiedCids: Record<string, CID | null> = {}
try {
const results = await verifyProofs(evt.blocks, claims, did, key)
Expand All @@ -200,7 +204,7 @@ export const parseCommitAuthenticated = async (
}
throw err
}
const verifiedOps: RepoOp[] = evt.ops.filter((op) => {
const verifiedOps: RepoOp[] = ops.filter((op) => {
if (op.action === 'delete') {
return verifiedCids[op.path] === null
} else {
Expand Down

0 comments on commit d605577

Please sign in to comment.