Merge pull request #2243 from filecoin-project/feat/buf-has-caching
check underlying datastore for objects before putting to bufbstore
This commit is contained in:
commit
9d56dabb31
@ -108,6 +108,15 @@ func (bs *BufferedBS) GetSize(c cid.Cid) (int, error) {
|
||||
}
|
||||
|
||||
func (bs *BufferedBS) Put(blk block.Block) error {
|
||||
has, err := bs.read.Has(blk.Cid())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if has {
|
||||
return nil
|
||||
}
|
||||
|
||||
return bs.write.Put(blk)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user