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:
Łukasz Magiera 2020-07-03 02:51:27 +02:00 committed by GitHub
commit 9d56dabb31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -108,6 +108,15 @@ func (bs *BufferedBS) GetSize(c cid.Cid) (int, error) {
} }
func (bs *BufferedBS) Put(blk block.Block) 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) return bs.write.Put(blk)
} }