+10
-4
recording_blockstore/recording_blockstore.go
+10
-4
recording_blockstore/recording_blockstore.go
···
13
base blockstore.Blockstore
14
15
inserts map[cid.Cid]blockformat.Block
16
}
17
18
func New(base blockstore.Blockstore) *RecordingBlockstore {
···
27
}
28
29
func (bs *RecordingBlockstore) Get(ctx context.Context, c cid.Cid) (blockformat.Block, error) {
30
-
return bs.base.Get(ctx, c)
31
}
32
33
func (bs *RecordingBlockstore) GetSize(ctx context.Context, c cid.Cid) (int, error) {
···
65
func (bs *RecordingBlockstore) HashOnRead(enabled bool) {
66
}
67
68
-
func (bs *RecordingBlockstore) GetLogMap() map[cid.Cid]blockformat.Block {
69
return bs.inserts
70
}
71
72
-
func (bs *RecordingBlockstore) GetLogArray() []blockformat.Block {
73
var blocks []blockformat.Block
74
-
for _, b := range bs.inserts {
75
blocks = append(blocks, b)
76
}
77
return blocks
···
13
base blockstore.Blockstore
14
15
inserts map[cid.Cid]blockformat.Block
16
+
reads map[cid.Cid]blockformat.Block
17
}
18
19
func New(base blockstore.Blockstore) *RecordingBlockstore {
···
28
}
29
30
func (bs *RecordingBlockstore) Get(ctx context.Context, c cid.Cid) (blockformat.Block, error) {
31
+
b, err := bs.base.Get(ctx, c)
32
+
if err != nil {
33
+
return nil, err
34
+
}
35
+
bs.reads[c] = b
36
+
return b, nil
37
}
38
39
func (bs *RecordingBlockstore) GetSize(ctx context.Context, c cid.Cid) (int, error) {
···
71
func (bs *RecordingBlockstore) HashOnRead(enabled bool) {
72
}
73
74
+
func (bs *RecordingBlockstore) GetWriteLog() map[cid.Cid]blockformat.Block {
75
return bs.inserts
76
}
77
78
+
func (bs *RecordingBlockstore) GetReadLog() []blockformat.Block {
79
var blocks []blockformat.Block
80
+
for _, b := range bs.reads {
81
blocks = append(blocks, b)
82
}
83
return blocks
+2
-2
server/repo.go
+2
-2
server/repo.go
···
274
}
275
}
276
277
-
for _, op := range bs.GetLogMap() {
278
if _, err := carstore.LdWrite(buf, op.Cid().Bytes(), op.RawData()); err != nil {
279
return nil, err
280
}
···
358
return cid.Undef, nil, err
359
}
360
361
-
return c, bs.GetLogArray(), nil
362
}
363
364
func (rm *RepoMan) incrementBlobRefs(urepo models.Repo, cbor []byte) ([]cid.Cid, error) {
···
274
}
275
}
276
277
+
for _, op := range bs.GetWriteLog() {
278
if _, err := carstore.LdWrite(buf, op.Cid().Bytes(), op.RawData()); err != nil {
279
return nil, err
280
}
···
358
return cid.Undef, nil, err
359
}
360
361
+
return c, bs.GetReadLog(), nil
362
}
363
364
func (rm *RepoMan) incrementBlobRefs(urepo models.Repo, cbor []byte) ([]cid.Cid, error) {