Repository navigation
feat: add SpecFromDigest constructor - #83
Merged
Merged
Conversation
SpecFromDigest(digest, size) specifies a blob by its digest, pairing with SpecFromDigestCode(code, size). Callers that have a digest and a size no longer build a Blob just to pass it to SpecFromBlob, which now delegates to it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Copilot review overview
馃煝 Approval recommended
The implementation is correct and tested; only a non-blocking documentation update remains.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Adds a direct BlobSpec constructor from a digest and size while preserving existing encoding behavior.
Changes:
- Introduces
SpecFromDigest. - Delegates
SpecFromBlobto the new constructor. - Tests equivalence between both constructors.
| File | Description |
|---|---|
commands/鈥媌lob/鈥媍odec.go |
Adds and integrates the constructor. |
commands/鈥媌lob/鈥媠pec_test.go |
Tests constructor behavior and compatibility. |
馃挕 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| // SpecFromDigest returns the spec of a blob of size bytes whose digest is | ||
| // known. Its digest code is the digest's own; a digest that is not a multihash | ||
| // has code 0. | ||
| func SpecFromDigest(digest multihash.Multihash, size uint64) BlobSpec { |
Contributor
There was a problem hiding this comment.
Added SpecFromDigest to the BlobSpec constructor documentation in commit 28089c5.
Co-authored-by: alanshaw <152863+alanshaw@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Adds
blob.SpecFromDigest(digest, size), which specifies a blob by its digest. It pairs withSpecFromDigestCode(code, size), which specifies one by the hash function that will compute its digest.SpecFromBlobstays, for code that already holds aBlob, and now delegates toSpecFromDigest. Encoding is unchanged.About 40 call sites across Piri, Sprue, Ingot and guppy build a
Blobinline just to pass it in; they'll switch once this merges.馃 Generated with Claude Code