+2
-2
repomgr/repomgr.go
+2
-2
repomgr/repomgr.go
···
455
return cid.Undef, nil, err
456
}
457
458
-
bs := util.NewReadRecordBstore(robs)
459
460
head, err := rm.cs.GetUserRepoHead(ctx, user)
461
if err != nil {
···
472
return cid.Undef, nil, err
473
}
474
475
-
return head, bs.AllReadBlocks(), nil
476
}
477
478
func (rm *RepoManager) GetProfile(ctx context.Context, uid models.Uid) (*bsky.ActorProfile, error) {
···
455
return cid.Undef, nil, err
456
}
457
458
+
bs := util.NewLoggingBstore(robs)
459
460
head, err := rm.cs.GetUserRepoHead(ctx, user)
461
if err != nil {
···
472
return cid.Undef, nil, err
473
}
474
475
+
return head, bs.GetLoggedBlocks(), nil
476
}
477
478
func (rm *RepoManager) GetProfile(ctx context.Context, uid models.Uid) (*bsky.ActorProfile, error) {
+13
-13
util/readrecordbs.go
+13
-13
util/readrecordbs.go
···
9
blockstore "github.com/ipfs/go-ipfs-blockstore"
10
)
11
12
-
type ReadRecordBstore struct {
13
base blockstore.Blockstore
14
15
set map[cid.Cid]blockformat.Block
16
}
17
18
-
func NewReadRecordBstore(base blockstore.Blockstore) *ReadRecordBstore {
19
-
return &ReadRecordBstore{
20
base: base,
21
set: make(map[cid.Cid]blockformat.Block),
22
}
23
}
24
25
-
var _ blockstore.Blockstore = (*ReadRecordBstore)(nil)
26
27
-
func (bs *ReadRecordBstore) AllReadBlocks() []blockformat.Block {
28
var out []blockformat.Block
29
for _, v := range bs.set {
30
out = append(out, v)
···
32
return out
33
}
34
35
-
func (bs *ReadRecordBstore) Has(ctx context.Context, c cid.Cid) (bool, error) {
36
return bs.base.Has(ctx, c)
37
}
38
39
-
func (bs *ReadRecordBstore) Get(ctx context.Context, c cid.Cid) (blockformat.Block, error) {
40
blk, err := bs.base.Get(ctx, c)
41
if err != nil {
42
return nil, err
···
47
return blk, nil
48
}
49
50
-
func (bs *ReadRecordBstore) GetSize(ctx context.Context, c cid.Cid) (int, error) {
51
return bs.base.GetSize(ctx, c)
52
}
53
54
-
func (bs *ReadRecordBstore) DeleteBlock(ctx context.Context, c cid.Cid) error {
55
return fmt.Errorf("deletes not allowed on read-record blockstore")
56
}
57
58
-
func (bs *ReadRecordBstore) Put(context.Context, blockformat.Block) error {
59
return fmt.Errorf("writes not allowed on read-record blockstore")
60
}
61
62
-
func (bs *ReadRecordBstore) PutMany(context.Context, []blockformat.Block) error {
63
return fmt.Errorf("writes not allowed on read-record blockstore")
64
}
65
66
-
func (bs *ReadRecordBstore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error) {
67
return nil, fmt.Errorf("iteration not supported on read-record blockstore")
68
}
69
70
-
func (bs *ReadRecordBstore) HashOnRead(enabled bool) {
71
72
}
···
9
blockstore "github.com/ipfs/go-ipfs-blockstore"
10
)
11
12
+
type LoggingBstore struct {
13
base blockstore.Blockstore
14
15
set map[cid.Cid]blockformat.Block
16
}
17
18
+
func NewLoggingBstore(base blockstore.Blockstore) *LoggingBstore {
19
+
return &LoggingBstore{
20
base: base,
21
set: make(map[cid.Cid]blockformat.Block),
22
}
23
}
24
25
+
var _ blockstore.Blockstore = (*LoggingBstore)(nil)
26
27
+
func (bs *LoggingBstore) GetLoggedBlocks() []blockformat.Block {
28
var out []blockformat.Block
29
for _, v := range bs.set {
30
out = append(out, v)
···
32
return out
33
}
34
35
+
func (bs *LoggingBstore) Has(ctx context.Context, c cid.Cid) (bool, error) {
36
return bs.base.Has(ctx, c)
37
}
38
39
+
func (bs *LoggingBstore) Get(ctx context.Context, c cid.Cid) (blockformat.Block, error) {
40
blk, err := bs.base.Get(ctx, c)
41
if err != nil {
42
return nil, err
···
47
return blk, nil
48
}
49
50
+
func (bs *LoggingBstore) GetSize(ctx context.Context, c cid.Cid) (int, error) {
51
return bs.base.GetSize(ctx, c)
52
}
53
54
+
func (bs *LoggingBstore) DeleteBlock(ctx context.Context, c cid.Cid) error {
55
return fmt.Errorf("deletes not allowed on read-record blockstore")
56
}
57
58
+
func (bs *LoggingBstore) Put(context.Context, blockformat.Block) error {
59
return fmt.Errorf("writes not allowed on read-record blockstore")
60
}
61
62
+
func (bs *LoggingBstore) PutMany(context.Context, []blockformat.Block) error {
63
return fmt.Errorf("writes not allowed on read-record blockstore")
64
}
65
66
+
func (bs *LoggingBstore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error) {
67
return nil, fmt.Errorf("iteration not supported on read-record blockstore")
68
}
69
70
+
func (bs *LoggingBstore) HashOnRead(enabled bool) {
71
72
}