Skip to content

Ready for universal CI #187

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

Merged
merged 4 commits into from
Aug 5, 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
2 changes: 1 addition & 1 deletion allocator/allocator.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (a *Allocator) ReleasePeerMemory(p peer.ID) error {
a.peerStatusQueue.Remove(status.Index())
delete(a.peerStatuses, p)
for _, pendingAllocation := range status.pendingAllocations {
pendingAllocation.response <- errors.New("Peer has been deallocated")
pendingAllocation.response <- errors.New("peer has been deallocated")
}
a.totalAllocatedAllPeers -= status.totalAllocated
a.processPendingAllocations()
Expand Down
6 changes: 3 additions & 3 deletions allocator/allocator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ func TestAllocator(t *testing.T) {
case <-allocated:
default:

pending = append(pending, pendingResultWithChan{pendingResult{p: op.p, amount: op.amount}, allocated}) //nolint:gosimple
pending = append(pending, pendingResultWithChan{pendingResult(op), allocated}) //nolint:gosimple
}
case releasePeer:
err := allocator.ReleasePeerMemory(op.p)
Expand Down Expand Up @@ -382,8 +382,8 @@ type releasePeer struct {
}

type pendingResult struct {
p peer.ID
amount uint64
p peer.ID //nolint:structcheck
amount uint64 //nolint:structcheck
Copy link
Contributor

Choose a reason for hiding this comment

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

what warning is this preventing? as far as I know our unified CI only enforces vet and staticcheck, so structcheck should not be a part of any of this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it gets the CURRENT CI to pass :P

Copy link
Contributor

Choose a reason for hiding this comment

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

🤦 need to rush to remove golangci-lint, then :P

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll remove the nolint comment in the PR where we switch over.

}

type pendingResultWithChan struct {
Expand Down
5 changes: 2 additions & 3 deletions benchmarks/testinstance/testinstance.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"time"

"github.com/ipfs/go-datastore"
ds "github.com/ipfs/go-datastore"
"github.com/ipfs/go-datastore/delayed"
ds_sync "github.com/ipfs/go-datastore/sync"
Expand Down Expand Up @@ -116,7 +115,7 @@ type Instance struct {
BlockStore blockstore.Blockstore
Adapter gsnet.GraphSyncNetwork
blockstoreDelay delay.D
ds datastore.Batching
ds ds.Batching
}

// Close closes the associated datastore
Expand Down Expand Up @@ -144,7 +143,7 @@ func NewInstance(ctx context.Context, net tn.Network, p tnet.Identity, gsOptions
bsdelay := delay.Fixed(0)

adapter := net.Adapter(p)
var dstore datastore.Batching
var dstore ds.Batching
var err error
if diskBasedDatastore {
defopts := badgerds.DefaultOptions
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ require (
github.com/ipfs/go-peertaskqueue v0.2.0
github.com/ipfs/go-unixfs v0.2.4
github.com/ipld/go-codec-dagpb v1.2.0
github.com/ipld/go-ipld-prime v0.9.1-0.20210324083106-dc342a9917db
github.com/ipld/go-ipld-prime v0.10.1-0.20210804101110-e44329e855d8
github.com/jbenet/go-random v0.0.0-20190219211222-123a90aedc0c
github.com/libp2p/go-buffer-pool v0.0.2
github.com/libp2p/go-libp2p v0.13.0
Expand Down
7 changes: 2 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ github.com/ipfs/go-verifcid v0.0.1/go.mod h1:5Hrva5KBeIog4A+UpqlaIU+DEstipcJYQQZ
github.com/ipld/go-codec-dagpb v1.2.0 h1:2umV7ud8HBMkRuJgd8gXw95cLhwmcYrihS3cQEy9zpI=
github.com/ipld/go-codec-dagpb v1.2.0/go.mod h1:6nBN7X7h8EOsEejZGqC7tej5drsdBAXbMHyBT+Fne5s=
github.com/ipld/go-ipld-prime v0.9.0/go.mod h1:KvBLMr4PX1gWptgkzRjVZCrLmSGcZCb/jioOQwCqZN8=
github.com/ipld/go-ipld-prime v0.9.1-0.20210324083106-dc342a9917db h1:kFwGn8rXa/Z31ev1OFNQsYeNKNCdifnTPl/NvPy5L38=
github.com/ipld/go-ipld-prime v0.9.1-0.20210324083106-dc342a9917db/go.mod h1:KvBLMr4PX1gWptgkzRjVZCrLmSGcZCb/jioOQwCqZN8=
github.com/ipld/go-ipld-prime v0.10.1-0.20210804101110-e44329e855d8 h1:67Jy9THQr4quY3X0ges9vGUBW+MKGclOkC4kcv8OtRY=
github.com/ipld/go-ipld-prime v0.10.1-0.20210804101110-e44329e855d8/go.mod h1:+WIAkokurHmZ/KwzDOMUuoeJgaRQktHtEaLglS3ZeV8=
github.com/jackpal/gateway v1.0.5/go.mod h1:lTpwd4ACLXmpyiCTRtfiNyVnUmqT9RivzCDQetPfnjA=
github.com/jackpal/go-nat-pmp v1.0.1/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc=
github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus=
Expand Down Expand Up @@ -498,7 +498,6 @@ github.com/minio/sha256-simd v0.0.0-20190131020904-2d45a736cd16/go.mod h1:2FMWW+
github.com/minio/sha256-simd v0.0.0-20190328051042-05b4dd3047e5/go.mod h1:2FMWW+8GMoPweT6+pI63m9YE3Lmw4J71hV56Chs1E/U=
github.com/minio/sha256-simd v0.1.0/go.mod h1:2FMWW+8GMoPweT6+pI63m9YE3Lmw4J71hV56Chs1E/U=
github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM=
github.com/minio/sha256-simd v0.1.1 h1:5QHSlgo3nt5yKOJrC7W8w7X+NFl8cMPZm96iu8kKUJU=
github.com/minio/sha256-simd v0.1.1/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM=
github.com/minio/sha256-simd v1.0.0 h1:v1ta+49hkWZyvaKwrQB8elexRqm6Y0aMLjCNsrYxo6g=
github.com/minio/sha256-simd v1.0.0/go.mod h1:OuYzVNI5vcoYIAmbIvHPl3N3jUzVedXbKy5RFepssQM=
Expand Down Expand Up @@ -549,7 +548,6 @@ github.com/multiformats/go-multihash v0.0.5/go.mod h1:lt/HCbqlQwlPBz7lv0sQCdtfcM
github.com/multiformats/go-multihash v0.0.8/go.mod h1:YSLudS+Pi8NHE7o6tb3D8vrpKa63epEDmG8nTduyAew=
github.com/multiformats/go-multihash v0.0.10/go.mod h1:YSLudS+Pi8NHE7o6tb3D8vrpKa63epEDmG8nTduyAew=
github.com/multiformats/go-multihash v0.0.13/go.mod h1:VdAWLKTwram9oKAatUcLxBNUjdtcVwxObEQBtRfuyjc=
github.com/multiformats/go-multihash v0.0.14 h1:QoBceQYQQtNUuf6s7wHxnE2c8bhbMqhfGzNI032se/I=
github.com/multiformats/go-multihash v0.0.14/go.mod h1:VdAWLKTwram9oKAatUcLxBNUjdtcVwxObEQBtRfuyjc=
github.com/multiformats/go-multihash v0.0.15 h1:hWOPdrNqDjwHDx82vsYGSDZNyktOJJ2dzZJzFkOV1jM=
github.com/multiformats/go-multihash v0.0.15/go.mod h1:D6aZrWNLFTV/ynMpKsNtB40mJzmCl4jb1alC0OvHiHg=
Expand Down Expand Up @@ -753,7 +751,6 @@ golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210309074719-68d13333faf2 h1:46ULzRKLh1CwgRq2dC5SlBzEqqNCi8rreOZnNrbqcIY=
golang.org/x/sys v0.0.0-20210309074719-68d13333faf2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down
12 changes: 6 additions & 6 deletions graphsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,42 +48,42 @@ const (
type RequestContextCancelledErr struct{}

func (e RequestContextCancelledErr) Error() string {
return "Request Context Cancelled"
return "request context cancelled"
}

// RequestFailedBusyErr is an error message received on the error channel when the peer is busy
type RequestFailedBusyErr struct{}

func (e RequestFailedBusyErr) Error() string {
return "Request Failed - Peer Is Busy"
return "request failed - peer is busy"
}

// RequestFailedContentNotFoundErr is an error message received on the error channel when the content is not found
type RequestFailedContentNotFoundErr struct{}

func (e RequestFailedContentNotFoundErr) Error() string {
return "Request Failed - Content Not Found"
return "request failed - content not found"
}

// RequestFailedLegalErr is an error message received on the error channel when the request fails for legal reasons
type RequestFailedLegalErr struct{}

func (e RequestFailedLegalErr) Error() string {
return "Request Failed - For Legal Reasons"
return "request failed - for legal reasons"
}

// RequestFailedUnknownErr is an error message received on the error channel when the request fails for unknown reasons
type RequestFailedUnknownErr struct{}

func (e RequestFailedUnknownErr) Error() string {
return "Request Failed - Unknown Reason"
return "request failed - unknown reason"
}

// RequestCancelledErr is an error message received on the error channel that indicates the responder cancelled a request
type RequestCancelledErr struct{}

func (e RequestCancelledErr) Error() string {
return "Request Failed - Responder Cancelled"
return "request failed - responder cancelled"
}

var (
Expand Down
8 changes: 3 additions & 5 deletions impl/graphsync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
cidlink "github.com/ipld/go-ipld-prime/linking/cid"
basicnode "github.com/ipld/go-ipld-prime/node/basic"
"github.com/ipld/go-ipld-prime/traversal/selector"
ipldselector "github.com/ipld/go-ipld-prime/traversal/selector"
"github.com/ipld/go-ipld-prime/traversal/selector/builder"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/peer"
Expand All @@ -41,7 +40,6 @@ import (

"github.com/ipfs/go-graphsync"
"github.com/ipfs/go-graphsync/cidset"
"github.com/ipfs/go-graphsync/ipldutil"
gsmsg "github.com/ipfs/go-graphsync/message"
gsnet "github.com/ipfs/go-graphsync/network"
"github.com/ipfs/go-graphsync/storeutil"
Expand Down Expand Up @@ -79,7 +77,7 @@ func TestMakeRequestToNetwork(t *testing.T) {
receivedRequest := receivedRequests[0]
receivedSpec := receivedRequest.Selector()
require.Equal(t, blockChain.Selector(), receivedSpec, "did not transmit selector spec correctly")
_, err := ipldutil.ParseSelector(receivedSpec)
_, err := selector.ParseSelector(receivedSpec)
require.NoError(t, err, "did not receive parsible selector on other side")

returnedData, found := receivedRequest.Extension(td.extensionName)
Expand Down Expand Up @@ -271,7 +269,7 @@ func TestGraphsyncRoundTripPartial(t *testing.T) {

for err := range errChan {
// verify the error is received for leaf beta node being missing
require.EqualError(t, err, fmt.Sprintf("Remote Peer Is Missing Block: %s", tree.LeafBetaLnk.String()))
require.EqualError(t, err, fmt.Sprintf("remote peer is missing block: %s", tree.LeafBetaLnk.String()))
}
require.Equal(t, tree.LeafAlphaBlock.RawData(), td.blockStore1[tree.LeafAlphaLnk])
require.Equal(t, tree.MiddleListBlock.RawData(), td.blockStore1[tree.MiddleListNodeLnk])
Expand Down Expand Up @@ -909,7 +907,7 @@ func TestUnixFSFetch(t *testing.T) {
// create a selector for the whole UnixFS dag
ssb := builder.NewSelectorSpecBuilder(basicnode.Prototype.Any)

allSelector := ssb.ExploreRecursive(ipldselector.RecursionLimitNone(),
allSelector := ssb.ExploreRecursive(selector.RecursionLimitNone(),
ssb.ExploreAll(ssb.ExploreRecursiveEdge())).Node()

// execute the traversal
Expand Down
6 changes: 0 additions & 6 deletions ipldutil/ipldutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
_ "github.com/ipld/go-ipld-prime/codec/raw"
cidlink "github.com/ipld/go-ipld-prime/linking/cid"
basicnode "github.com/ipld/go-ipld-prime/node/basic"
"github.com/ipld/go-ipld-prime/traversal/selector"
ipldselector "github.com/ipld/go-ipld-prime/traversal/selector"
)

var defaultChooser = func(lnk ipld.Link, lctx ipld.LinkContext) (ipld.NodePrototype, error) {
Expand Down Expand Up @@ -38,7 +36,3 @@ func DecodeNode(encoded []byte) (ipld.Node, error) {
}
return nb.Build(), nil
}

func ParseSelector(selector ipld.Node) (selector.Selector, error) {
return ipldselector.ParseSelector(selector)
}
2 changes: 1 addition & 1 deletion ipldutil/traverser.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var defaultVisitor traversal.AdvVisitFn = func(traversal.Progress, ipld.Node, tr
type ContextCancelError struct{}

func (cp ContextCancelError) Error() string {
return "Context cancelled"
return "context cancelled"
}

// TraversalBuilder defines parameters for an iterative traversal
Expand Down
6 changes: 3 additions & 3 deletions ipldutil/traverser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ func TestTraverser(t *testing.T) {
}.Start(ctx)
checkTraverseSequence(ctx, t, traverser, []blocks.Block{
testdata.RootBlock,
testdata.LeafAlphaBlock,
testdata.MiddleMapBlock,
testdata.LeafAlphaBlock,
testdata.MiddleListBlock,
testdata.LeafAlphaBlock,
testdata.LeafAlphaBlock,
testdata.LeafBetaBlock,
testdata.LeafAlphaBlock,
testdata.MiddleMapBlock,
testdata.LeafAlphaBlock,
testdata.LeafAlphaBlock,
})
})

Expand Down
2 changes: 1 addition & 1 deletion messagequeue/messagequeue.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func (mq *MessageQueue) signalWork() {
}
}

var errEmptyMessage = errors.New("Empty Message")
var errEmptyMessage = errors.New("empty Message")

func (mq *MessageQueue) extractOutgoingMessage() (gsmsg.GraphSyncMessage, *messagePublisher, error) {
// grab outgoing message
Expand Down
12 changes: 6 additions & 6 deletions requestmanager/asyncloader/asyncloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (al *AsyncLoader) Shutdown() {
// RegisterPersistenceOption registers a new loader/storer option for processing requests
func (al *AsyncLoader) RegisterPersistenceOption(name string, lsys ipld.LinkSystem) error {
if name == "" {
return errors.New("Persistence option must have a name")
return errors.New("persistence option must have a name")
}
response := make(chan error, 1)
err := al.sendSyncMessage(&registerPersistenceOptionMessage{name, lsys, response}, response)
Expand All @@ -84,7 +84,7 @@ func (al *AsyncLoader) RegisterPersistenceOption(name string, lsys ipld.LinkSyst
// UnregisterPersistenceOption unregisters an existing loader/storer option for processing requests
func (al *AsyncLoader) UnregisterPersistenceOption(name string) error {
if name == "" {
return errors.New("Persistence option must have a name")
return errors.New("persistence option must have a name")
}
response := make(chan error, 1)
err := al.sendSyncMessage(&unregisterPersistenceOptionMessage{name, response}, response)
Expand Down Expand Up @@ -142,12 +142,12 @@ func (al *AsyncLoader) CleanupRequest(requestID graphsync.RequestID) {
func (al *AsyncLoader) sendSyncMessage(message loaderMessage, response chan error) error {
select {
case <-al.ctx.Done():
return errors.New("Context Closed")
return errors.New("context closed")
case al.incomingMessages <- message:
}
select {
case <-al.ctx.Done():
return errors.New("Context Closed")
return errors.New("context closed")
case err := <-response:
return err
}
Expand Down Expand Up @@ -271,7 +271,7 @@ func (rpom *registerPersistenceOptionMessage) handle(al *AsyncLoader) {
func (upom *unregisterPersistenceOptionMessage) unregister(al *AsyncLoader) error {
_, ok := al.alternateQueues[upom.name]
if !ok {
return errors.New("Unknown persistence option")
return errors.New("unknown persistence option")
}
for _, requestQueue := range al.requestQueues {
if upom.name == requestQueue {
Expand All @@ -294,7 +294,7 @@ func (srm *startRequestMessage) startRequest(al *AsyncLoader) error {
if srm.persistenceOption != "" {
_, ok := al.alternateQueues[srm.persistenceOption]
if !ok {
return errors.New("Unknown persistence option")
return errors.New("unknown persistence option")
}
al.requestQueues[srm.requestID] = srm.persistenceOption
}
Expand Down
4 changes: 2 additions & 2 deletions requestmanager/asyncloader/asyncloader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func TestRegisterUnregister(t *testing.T) {

requestID1 := graphsync.RequestID(rand.Int31())
err := asyncLoader.StartRequest(requestID1, "other")
require.EqualError(t, err, "Unknown persistence option")
require.EqualError(t, err, "unknown persistence option")

err = asyncLoader.RegisterPersistenceOption("other", otherSt.lsys)
require.NoError(t, err)
Expand All @@ -215,7 +215,7 @@ func TestRegisterUnregister(t *testing.T) {

requestID3 := graphsync.RequestID(rand.Int31())
err = asyncLoader.StartRequest(requestID3, "other")
require.EqualError(t, err, "Unknown persistence option")
require.EqualError(t, err, "unknown persistence option")
})
}
func TestRequestSplittingLoadLocallyFromBlockstore(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion requestmanager/asyncloader/responsecache/responsecache.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,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, fmt.Errorf("remote peer is missing block: %s", link.String())
}
data, _ := rc.unverifiedBlockStore.VerifyBlock(link)
return data, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (ubs *UnverifiedBlockStore) PruneBlock(link ipld.Link) {
func (ubs *UnverifiedBlockStore) VerifyBlock(lnk ipld.Link) ([]byte, error) {
data, ok := ubs.inMemoryBlocks[lnk]
if !ok {
return nil, fmt.Errorf("Block not found")
return nil, fmt.Errorf("block not found")
}
delete(ubs.inMemoryBlocks, lnk)
buffer, committer, err := ubs.storer(ipld.LinkContext{})
Expand Down
15 changes: 8 additions & 7 deletions requestmanager/requestmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
logging "github.com/ipfs/go-log"
"github.com/ipld/go-ipld-prime"
cidlink "github.com/ipld/go-ipld-prime/linking/cid"
"github.com/ipld/go-ipld-prime/traversal/selector"
"github.com/libp2p/go-libp2p-core/peer"

"github.com/ipfs/go-graphsync"
Expand Down Expand Up @@ -147,16 +148,16 @@ type newRequestMessage struct {
func (rm *RequestManager) SendRequest(ctx context.Context,
p peer.ID,
root ipld.Link,
selector ipld.Node,
selectorNode ipld.Node,
extensions ...graphsync.ExtensionData) (<-chan graphsync.ResponseProgress, <-chan error) {
if _, err := ipldutil.ParseSelector(selector); err != nil {
return rm.singleErrorResponse(fmt.Errorf("Invalid Selector Spec"))
if _, err := selector.ParseSelector(selectorNode); err != nil {
return rm.singleErrorResponse(fmt.Errorf("invalid selector spec"))
}

inProgressRequestChan := make(chan inProgressRequest)

select {
case rm.messages <- &newRequestMessage{p, root, selector, extensions, inProgressRequestChan}:
case rm.messages <- &newRequestMessage{p, root, selectorNode, extensions, inProgressRequestChan}:
case <-rm.ctx.Done():
return rm.emptyResponse()
case <-ctx.Done():
Expand Down Expand Up @@ -268,12 +269,12 @@ func (rm *RequestManager) PauseRequest(requestID graphsync.RequestID) error {
func (rm *RequestManager) sendSyncMessage(message requestManagerMessage, response chan error) error {
select {
case <-rm.ctx.Done():
return errors.New("Context Cancelled")
return errors.New("context cancelled")
case rm.messages <- message:
}
select {
case <-rm.ctx.Done():
return errors.New("Context Cancelled")
return errors.New("context cancelled")
case err := <-response:
return err
}
Expand Down Expand Up @@ -516,7 +517,7 @@ func (rm *RequestManager) validateRequest(requestID graphsync.RequestID, p peer.
if err != nil {
return gsmsg.GraphSyncRequest{}, hooks.RequestResult{}, err
}
_, err = ipldutil.ParseSelector(selectorSpec)
_, err = selector.ParseSelector(selectorSpec)
if err != nil {
return gsmsg.GraphSyncRequest{}, hooks.RequestResult{}, err
}
Expand Down
4 changes: 2 additions & 2 deletions responsemanager/responsemanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,12 @@ func (rm *ResponseManager) CancelResponse(p peer.ID, requestID graphsync.Request
func (rm *ResponseManager) sendSyncMessage(message responseManagerMessage, response chan error) error {
select {
case <-rm.ctx.Done():
return errors.New("Context Cancelled")
return errors.New("context cancelled")
case rm.messages <- message:
}
select {
case <-rm.ctx.Done():
return errors.New("Context Cancelled")
return errors.New("context cancelled")
case err := <-response:
return err
}
Expand Down
Loading