From a0c9ed2acebfa68ff29095ca5ba2029281d50c0f Mon Sep 17 00:00:00 2001 From: Niko Storni Date: Tue, 23 Feb 2021 15:23:46 +0100 Subject: [PATCH] make it simpler --- peer/http3/store.go | 9 +++------ peer/store.go | 9 +++------ shared/errors.go | 6 ++++++ store/cloudfront_ro.go | 6 +++--- store/store.go | 3 --- 5 files changed, 15 insertions(+), 18 deletions(-) create mode 100644 shared/errors.go diff --git a/peer/http3/store.go b/peer/http3/store.go index f842437..8a5c812 100644 --- a/peer/http3/store.go +++ b/peer/http3/store.go @@ -13,9 +13,6 @@ import ( "github.com/lucas-clemente/quic-go/http3" ) -//ErrNotImplemented is a standard error when a store that implements the store interface does not implement a method -var ErrNotImplemented = errors.Base("this store does not implement this method") - // Store is a blob store that gets blobs from a peer. // It satisfies the store.BlobStore interface but cannot put or delete blobs. type Store struct { @@ -84,17 +81,17 @@ func (p *Store) Get(hash string) (stream.Blob, shared.BlobTrace, error) { // Put is not supported func (p *Store) Put(hash string, blob stream.Blob) error { - return errors.Err(ErrNotImplemented) + return errors.Err(shared.ErrNotImplemented) } // PutSD is not supported func (p *Store) PutSD(hash string, blob stream.Blob) error { - return errors.Err(ErrNotImplemented) + return errors.Err(shared.ErrNotImplemented) } // Delete is not supported func (p *Store) Delete(hash string) error { - return errors.Err(ErrNotImplemented) + return errors.Err(shared.ErrNotImplemented) } // Delete is not supported diff --git a/peer/store.go b/peer/store.go index 6bf3b38..3068794 100644 --- a/peer/store.go +++ b/peer/store.go @@ -8,9 +8,6 @@ import ( "github.com/lbryio/reflector.go/shared" ) -//ErrNotImplemented is a standard error when a store that implements the store interface does not implement a method -var ErrNotImplemented = errors.Base("this store does not implement this method") - // Store is a blob store that gets blobs from a peer. // It satisfies the store.BlobStore interface but cannot put or delete blobs. type Store struct { @@ -59,17 +56,17 @@ func (p *Store) Get(hash string) (stream.Blob, shared.BlobTrace, error) { // Put is not supported func (p *Store) Put(hash string, blob stream.Blob) error { - return errors.Err(ErrNotImplemented) + return errors.Err(shared.ErrNotImplemented) } // PutSD is not supported func (p *Store) PutSD(hash string, blob stream.Blob) error { - return errors.Err(ErrNotImplemented) + return errors.Err(shared.ErrNotImplemented) } // Delete is not supported func (p *Store) Delete(hash string) error { - return errors.Err(ErrNotImplemented) + return errors.Err(shared.ErrNotImplemented) } // Delete is not supported diff --git a/shared/errors.go b/shared/errors.go new file mode 100644 index 0000000..f103394 --- /dev/null +++ b/shared/errors.go @@ -0,0 +1,6 @@ +package shared + +import "github.com/lbryio/lbry.go/v2/extras/errors" + +//ErrNotImplemented is a standard error when a store that implements the store interface does not implement a method +var ErrNotImplemented = errors.Base("this store does not implement this method") diff --git a/store/cloudfront_ro.go b/store/cloudfront_ro.go index fcc8ed0..757174c 100644 --- a/store/cloudfront_ro.go +++ b/store/cloudfront_ro.go @@ -93,15 +93,15 @@ func (c *CloudFrontROStore) cfRequest(method, hash string) (int, io.ReadCloser, } func (c *CloudFrontROStore) Put(_ string, _ stream.Blob) error { - return errors.Err(ErrNotImplemented) + return errors.Err(shared.ErrNotImplemented) } func (c *CloudFrontROStore) PutSD(_ string, _ stream.Blob) error { - return errors.Err(ErrNotImplemented) + return errors.Err(shared.ErrNotImplemented) } func (c *CloudFrontROStore) Delete(_ string) error { - return errors.Err(ErrNotImplemented) + return errors.Err(shared.ErrNotImplemented) } // Shutdown shuts down the store gracefully diff --git a/store/store.go b/store/store.go index 3a2fc6f..bd9223b 100644 --- a/store/store.go +++ b/store/store.go @@ -40,6 +40,3 @@ type lister interface { //ErrBlobNotFound is a standard error when a blob is not found in the store. var ErrBlobNotFound = errors.Base("blob not found") - -//ErrNotImplemented is a standard error when a store that implements this interface does not implement a method -var ErrNotImplemented = errors.Base("this store does not implement this method")