Skip to content

Commit

Permalink
suck less at naming
Browse files Browse the repository at this point in the history
  • Loading branch information
whyrusleeping committed Nov 8, 2023
1 parent 93b7e18 commit bb835a1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions repomgr/repomgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ func (rm *RepoManager) GetRecordProof(ctx context.Context, user models.Uid, coll
return cid.Undef, nil, err
}

bs := util.NewReadRecordBstore(robs)
bs := util.NewLoggingBstore(robs)

head, err := rm.cs.GetUserRepoHead(ctx, user)
if err != nil {
Expand All @@ -472,7 +472,7 @@ func (rm *RepoManager) GetRecordProof(ctx context.Context, user models.Uid, coll
return cid.Undef, nil, err
}

return head, bs.AllReadBlocks(), nil
return head, bs.GetLoggedBlocks(), nil
}

func (rm *RepoManager) GetProfile(ctx context.Context, uid models.Uid) (*bsky.ActorProfile, error) {
Expand Down
26 changes: 13 additions & 13 deletions util/readrecordbs.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,34 @@ import (
blockstore "github.com/ipfs/go-ipfs-blockstore"
)

type ReadRecordBstore struct {
type LoggingBstore struct {
base blockstore.Blockstore

set map[cid.Cid]blockformat.Block
}

func NewReadRecordBstore(base blockstore.Blockstore) *ReadRecordBstore {
return &ReadRecordBstore{
func NewLoggingBstore(base blockstore.Blockstore) *LoggingBstore {
return &LoggingBstore{
base: base,
set: make(map[cid.Cid]blockformat.Block),
}
}

var _ blockstore.Blockstore = (*ReadRecordBstore)(nil)
var _ blockstore.Blockstore = (*LoggingBstore)(nil)

func (bs *ReadRecordBstore) AllReadBlocks() []blockformat.Block {
func (bs *LoggingBstore) GetLoggedBlocks() []blockformat.Block {
var out []blockformat.Block
for _, v := range bs.set {
out = append(out, v)
}
return out
}

func (bs *ReadRecordBstore) Has(ctx context.Context, c cid.Cid) (bool, error) {
func (bs *LoggingBstore) Has(ctx context.Context, c cid.Cid) (bool, error) {
return bs.base.Has(ctx, c)
}

func (bs *ReadRecordBstore) Get(ctx context.Context, c cid.Cid) (blockformat.Block, error) {
func (bs *LoggingBstore) Get(ctx context.Context, c cid.Cid) (blockformat.Block, error) {
blk, err := bs.base.Get(ctx, c)
if err != nil {
return nil, err
Expand All @@ -47,26 +47,26 @@ func (bs *ReadRecordBstore) Get(ctx context.Context, c cid.Cid) (blockformat.Blo
return blk, nil
}

func (bs *ReadRecordBstore) GetSize(ctx context.Context, c cid.Cid) (int, error) {
func (bs *LoggingBstore) GetSize(ctx context.Context, c cid.Cid) (int, error) {
return bs.base.GetSize(ctx, c)
}

func (bs *ReadRecordBstore) DeleteBlock(ctx context.Context, c cid.Cid) error {
func (bs *LoggingBstore) DeleteBlock(ctx context.Context, c cid.Cid) error {
return fmt.Errorf("deletes not allowed on read-record blockstore")
}

func (bs *ReadRecordBstore) Put(context.Context, blockformat.Block) error {
func (bs *LoggingBstore) Put(context.Context, blockformat.Block) error {
return fmt.Errorf("writes not allowed on read-record blockstore")
}

func (bs *ReadRecordBstore) PutMany(context.Context, []blockformat.Block) error {
func (bs *LoggingBstore) PutMany(context.Context, []blockformat.Block) error {
return fmt.Errorf("writes not allowed on read-record blockstore")
}

func (bs *ReadRecordBstore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error) {
func (bs *LoggingBstore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error) {
return nil, fmt.Errorf("iteration not supported on read-record blockstore")
}

func (bs *ReadRecordBstore) HashOnRead(enabled bool) {
func (bs *LoggingBstore) HashOnRead(enabled bool) {

}

0 comments on commit bb835a1

Please sign in to comment.