Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give missing blocks a named error #227

Merged
merged 1 commit into from
Sep 29, 2021
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
12 changes: 12 additions & 0 deletions graphsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package graphsync
import (
"context"
"errors"
"fmt"

"github.com/ipfs/go-cid"
"github.com/ipld/go-ipld-prime"
Expand Down Expand Up @@ -94,6 +95,17 @@ func (e RequestNotFoundErr) Error() string {
return "request not found"
}

// RemoteMissingBlockErr indicates that the remote peer was missing a block
// in the selector requested. It is a non-terminal error in the error stream
// for a request and does NOT cause a request to fail completely
type RemoteMissingBlockErr struct {
Link ipld.Link
}

func (e RemoteMissingBlockErr) Error() string {
return fmt.Sprintf("remote peer is missing block: %s", e.Link.String())
}

var (
// ErrExtensionAlreadyRegistered means a user extension can be registered only once
ErrExtensionAlreadyRegistered = errors.New("extension already registered")
Expand Down
3 changes: 1 addition & 2 deletions requestmanager/asyncloader/responsecache/responsecache.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package responsecache

import (
"fmt"
"sync"

blocks "github.com/ipfs/go-block-format"
Expand Down Expand Up @@ -59,7 +58,7 @@ func (rc *ResponseCache) AttemptLoad(requestID graphsync.RequestID, link ipld.Li
rc.responseCacheLk.Lock()
defer rc.responseCacheLk.Unlock()
if rc.linkTracker.IsKnownMissingLink(requestID, link) {
return nil, fmt.Errorf("remote peer is missing block: %s", link.String())
return nil, graphsync.RemoteMissingBlockErr{Link: link}
}
data, _ := rc.unverifiedBlockStore.VerifyBlock(link, linkContext)
return data, nil
Expand Down