Commit bc4a13fd authored by Jeromy's avatar Jeromy Committed by Juan Batiz-Benet

blockstore.ErrNotFound, and proper wantlist sorting

parent 9a4a84b7
...@@ -6,14 +6,16 @@ import ( ...@@ -6,14 +6,16 @@ import (
"errors" "errors"
ds "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore" ds "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash" mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
blocks "github.com/jbenet/go-ipfs/blocks" blocks "github.com/jbenet/go-ipfs/blocks"
u "github.com/jbenet/go-ipfs/util" u "github.com/jbenet/go-ipfs/util"
) )
var ValueTypeMismatch = errors.New("The retrieved value is not a Block") var ValueTypeMismatch = errors.New("The retrieved value is not a Block")
var ErrNotFound = errors.New("blockstore: block not found")
// Blockstore wraps a ThreadSafeDatastore // Blockstore wraps a ThreadSafeDatastore
type Blockstore interface { type Blockstore interface {
DeleteBlock(u.Key) error DeleteBlock(u.Key) error
...@@ -34,6 +36,9 @@ type blockstore struct { ...@@ -34,6 +36,9 @@ type blockstore struct {
func (bs *blockstore) Get(k u.Key) (*blocks.Block, error) { func (bs *blockstore) Get(k u.Key) (*blocks.Block, error) {
maybeData, err := bs.datastore.Get(k.DsKey()) maybeData, err := bs.datastore.Get(k.DsKey())
if err == ds.ErrNotFound {
return nil, ErrNotFound
}
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment