@@ -22,6 +22,7 @@ import (
22
22
ipld "github.com/ipfs/go-ipld-format"
23
23
"github.com/ipld/go-ipld-prime/storage/bsadapter"
24
24
25
+ "github.com/sourcenetwork/defradb/datastore/badger/v4"
25
26
"github.com/sourcenetwork/defradb/errors"
26
27
)
27
28
@@ -113,19 +114,17 @@ func (bs *bstore) Put(ctx context.Context, block blocks.Block) error {
113
114
if err == nil && exists {
114
115
return nil // already stored.
115
116
}
116
- return bs .store .Put (ctx , k , block .RawData ())
117
+ err = bs .store .Put (ctx , k , block .RawData ())
118
+ if errors .Is (err , badger .ErrTxnConflict ) {
119
+ return nil // ignore conflicts data is immutable
120
+ }
121
+ return err
117
122
}
118
123
119
124
// PutMany stores multiple blocks to the blockstore.
120
125
func (bs * bstore ) PutMany (ctx context.Context , blocks []blocks.Block ) error {
121
126
for _ , b := range blocks {
122
- k := dshelp .MultihashToDsKey (b .Cid ().Hash ())
123
- exists , err := bs .store .Has (ctx , k )
124
- if err == nil && exists {
125
- continue
126
- }
127
-
128
- err = bs .store .Put (ctx , k , b .RawData ())
127
+ err := bs .Put (ctx , b )
129
128
if err != nil {
130
129
return err
131
130
}
0 commit comments