Skip to content

feat: port blobindex package from go-libstoracha#14

Open
alanshaw wants to merge 7 commits into
mainfrom
ash/feat/add-blobindex
Open

feat: port blobindex package from go-libstoracha#14
alanshaw wants to merge 7 commits into
mainfrom
ash/feat/add-blobindex

Conversation

@alanshaw
Copy link
Copy Markdown
Member

I'm not super happy that go-car pulls in boxo, maybe I'll write a simple CAR reader/writer for Go at some point.

@alanshaw alanshaw requested review from Peeja and frrist May 13, 2026 12:30
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR ports a blobindex package into libforge, adding an in-memory sharded DAG index representation plus CAR-based archive/extract support using a CBOR/DAG-JSON datamodel (with generated codecs).

Changes:

  • Add blobindex APIs (ShardedDagIndex, MapShardedDagIndex) and multihash-keyed map helpers.
  • Implement CAR decoding/encoding for sharded DAG indexes (Extract, Archive) with deterministic output ordering.
  • Introduce the blobindex/datamodel schema + generated CBOR/DAG-JSON codecs and add round-trip/determinism tests.

Reviewed changes

Copilot reviewed 7 out of 12 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
go.mod Adds new direct/indirect dependencies needed for CAR + block/CID handling.
go.sum Updates dependency lockfile for the newly introduced modules.
blobindex/types.go Defines core blobindex interfaces/types (e.g., ShardedDagIndex, Range).
blobindex/multihashmap.go Adds constructor helper for multihash-keyed maps.
blobindex/shardeddagindex.go Implements CAR extract/archive + in-memory sharded DAG index implementation.
blobindex/shardeddagindex_test.go Adds round-trip and determinism coverage for archive/extract behavior.
blobindex/datamodel/shardeddagindex.go Defines the CBOR/DAG-JSON data model structs for the index format.
blobindex/datamodel/gen/main.go Adds generator entrypoint for CBOR/DAG-JSON encoder/decoder generation.
blobindex/datamodel/cbor_gen.maps.go Generated CBOR map encoders/decoders for the datamodel.
blobindex/datamodel/cbor_gen.tuples.go Generated CBOR tuple encoders/decoders for the datamodel.
blobindex/datamodel/json_gen.maps.go Generated DAG-JSON map encoders/decoders for the datamodel.
blobindex/datamodel/json_gen.tuples.go Generated DAG-JSON tuple encoders/decoders for the datamodel.
Files not reviewed (4)
  • blobindex/datamodel/cbor_gen.maps.go: Language not supported
  • blobindex/datamodel/cbor_gen.tuples.go: Language not supported
  • blobindex/datamodel/json_gen.maps.go: Language not supported
  • blobindex/datamodel/json_gen.tuples.go: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +179 to +183
b := buf.Bytes()
l, err := cid.V1Builder{Codec: cid.DagCBOR, MhType: mh.SHA2_256}.Sum(b)
if err != nil {
return nil, err
}
Comment thread blobindex/types.go Outdated
Comment on lines +30 to +34
// BlobIndexModel is the golang structure for encoding a shard of CIDs in a block
type BlobIndexModel struct {
Digest multihash.Multihash
Slices []BlobSliceModel
}
slices.SortFunc(list, func(a, b E) int {
decodedA := decodeds.Get(getDigest(a))
decodedB := decodeds.Get(getDigest(b))
return bytes.Compare(decodedA.Digest, decodedB.Digest)
Comment thread blobindex/shardeddagindex.go Outdated
Comment on lines +127 to +132
return fmt.Errorf(fmt.Sprintf("unknown format: %s", reason), args...)
}

// NewDecodeFailureError returns an error for a decode failure.
func NewDecodeFailureError(reason string, args ...any) error {
return fmt.Errorf(fmt.Sprintf("decode failure: %s", reason), args...)
Comment thread blobindex/shardeddagindex.go Outdated
alanshaw and others added 3 commits May 13, 2026 17:03
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants