only store the blobs in the underlying storage if LFUDA accepted them

This commit is contained in:
Niko Storni 2020-11-25 19:24:32 +01:00
parent ff13d7b2f7
commit 0b565852b8

View file

@ -66,11 +66,14 @@ func (l *LFUDAStore) Get(hash string) (stream.Blob, error) {
// Put stores the blob. Following LFUDA rules it's not guaranteed that a SET will store the value!!!
func (l *LFUDAStore) Put(hash string, blob stream.Blob) error {
err := l.store.Put(hash, blob)
if err != nil {
return err
}
l.lfuda.Set(hash, fakeTrue)
has, _ := l.Has(hash)
if has {
err := l.store.Put(hash, blob)
if err != nil {
return err
}
}
return nil
}