Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions commands/blob/abort.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ type AbortOK = commands.Unit
//
// Served by the upload service (subject = the space). A parked blob has no
// registration or acceptance to look the storage node up by, so the service
// recovers it from the Cause receipt chain and forwards a `/blob/reject`
// (Cause itself is not forwarded — it is routing metadata, meaningless to
// the node). A missing or unknown Cause fails with MissingCause. Blobs the
// recovers it from the receipt chain of the Add task, and forwards a
// `/blob/reject` of the allocation the add made. A missing or unknown Add
// fails with MissingCause. Blobs the
// space has accepted are released via `/blob/remove` instead; if the node
// refuses the translated reject with BlobAccepted, the service surfaces that
// named failure in the abort receipt. The abort mutates no upload-service
Expand All @@ -32,9 +32,8 @@ type AbortOK = commands.Unit
var Abort = binding.Bind[*AbortArguments, *AbortOK](command.MustParse("/blob/abort"))

// MissingCauseErrorName is the stable receipt-failure name when an abort's
// Cause is missing or does not resolve to a known `/blob/add` task —
// without it the upload service cannot recover which storage node holds the
// parked blob.
// Add is missing or does not resolve to a known `/blob/add` task — without it
// the upload service cannot recover which storage node holds the parked blob.
const MissingCauseErrorName = "MissingCause"

var ErrMissingCause = errors.New(MissingCauseErrorName, "abort requires the cause of the /blob/add task that parked the blob")
var ErrMissingCause = errors.New(MissingCauseErrorName, "abort requires the /blob/add task that parked the blob")
24 changes: 11 additions & 13 deletions commands/blob/abort_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,12 @@ import (

// Round-trips AbortArguments through cbor.
func TestAbortArgumentsRoundTrip(t *testing.T) {
in := blob.AbortArguments{
Digest: testutil.RandomMultihash(t),
Cause: testutil.RandomCID(t),
}
in := blob.AbortArguments{Add: testutil.RandomCID(t)}
var buf bytes.Buffer
require.NoError(t, in.MarshalCBOR(&buf))
var out blob.AbortArguments
require.NoError(t, out.UnmarshalCBOR(&buf))
require.Equal(t, in.Digest, out.Digest)
require.Equal(t, in.Cause, out.Cause)
require.Equal(t, in, out)
}

// Round-trips ReleaseArguments through cbor.
Expand All @@ -41,16 +37,18 @@ func TestReleaseArgumentsRoundTrip(t *testing.T) {
require.Equal(t, in.Cause, out.Cause)
}

// Round-trips RejectArguments through cbor.
// Round-trips RejectArguments through cbor and dag-json.
func TestRejectArgumentsRoundTrip(t *testing.T) {
in := blob.RejectArguments{
Space: testutil.RandomDID(t),
Digest: testutil.RandomMultihash(t),
}
in := blob.RejectArguments{Allocation: testutil.RandomCID(t)}
var buf bytes.Buffer
require.NoError(t, in.MarshalCBOR(&buf))
var out blob.RejectArguments
require.NoError(t, out.UnmarshalCBOR(&buf))
require.Equal(t, in.Space, out.Space)
require.Equal(t, in.Digest, out.Digest)
require.Equal(t, in, out)

var js bytes.Buffer
require.NoError(t, in.MarshalDagJSON(&js))
var outJS blob.RejectArguments
require.NoError(t, outJS.UnmarshalDagJSON(&js))
require.Equal(t, in, outJS)
}
10 changes: 10 additions & 0 deletions commands/blob/accept.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,17 @@ package blob

import (
"github.com/fil-forge/ucantone/binding"
"github.com/fil-forge/ucantone/errors"
"github.com/fil-forge/ucantone/ucan/command"
)

var Accept = binding.Bind[*AcceptArguments, *AcceptOK](command.MustParse("/blob/accept"))

// BlobDigestMismatchErrorName is the stable receipt-failure name when the
// digest the storage node computed for the received data differs from the
// digest in the accept arguments or, when they name only a digest code, the
// digest in the `/http/put` receipt.
const BlobDigestMismatchErrorName = "BlobDigestMismatch"

// ErrBlobDigestMismatch is the failure for a digest mismatch.
var ErrBlobDigestMismatch = errors.New(BlobDigestMismatchErrorName, "received data does not hash to the reported digest")
Loading
Loading