Skip to content

Commit 8796070

Browse files
committed
fix: skip rewriting CAR blocks that are already stored
1 parent 5b4fc1e commit 8796070

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

internal/db/p2p/car.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,11 @@ func (p *P2P) importCAR(ctx context.Context, carData []byte) (*coreblock.Block,
224224
return nil, p.carImportFailure(reasonNoRoots, written, ErrEmptyCARRoots)
225225
}
226226

227-
bstore := datastore.BlindWriteP2PBlockstoreFrom(p.db.Rootstore(), immutable.None[int]())
227+
// A CAR carries whole document DAGs, and content-addressed field blocks recur across
228+
// documents sharing a field value, so a CAR routinely contains blocks already stored.
229+
// The guarded store skips those instead of rewriting the block and re-stamping a
230+
// to-merge marker on one that already merged.
231+
bstore := datastore.P2PBlockstoreFrom(p.db.Rootstore(), immutable.None[int]())
228232
encStore := datastore.EncstoreFrom(p.db.Rootstore())
229233
var rootBlock *coreblock.Block
230234

0 commit comments

Comments
 (0)