Skip to content

Commit

Permalink
review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
distractedm1nd committed Dec 22, 2022
1 parent 6e2cf9c commit 3ba0a6f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion share/eds/blockstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (bs *blockstore) getReadOnlyBlockstore(ctx context.Context, cid cid.Cid) (d

// a share can exist in multiple EDSes, so just take the first one.
shardKey := keys[0]
accessor, err := bs.store.getAccessor(ctx, shardKey)
accessor, err := bs.store.getCachedAccessor(ctx, shardKey)
if err != nil {
return nil, fmt.Errorf("failed to get accessor for shard %s: %w", shardKey, err)
}
Expand Down
12 changes: 6 additions & 6 deletions share/eds/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func (s *Store) Put(ctx context.Context, root share.DataHash, square *rsmt2d.Ext
// Caller must Close returned reader after reading.
func (s *Store) GetCAR(ctx context.Context, root share.DataHash) (io.ReadCloser, error) {
key := root.String()
accessor, err := s.acquireShard(ctx, shard.KeyFromString(key))
accessor, err := s.getAccessor(ctx, shard.KeyFromString(key))
if err != nil {
return nil, fmt.Errorf("failed to get accessor: %w", err)
}
Expand All @@ -211,7 +211,7 @@ func (s *Store) CARBlockstore(
root share.DataHash,
) (dagstore.ReadBlockstore, error) {
key := shard.KeyFromString(root.String())
accessor, err := s.getAccessor(ctx, key)
accessor, err := s.getCachedAccessor(ctx, key)
if err != nil {
return nil, fmt.Errorf("eds/store: failed to get accessor: %w", err)
}
Expand All @@ -221,7 +221,7 @@ func (s *Store) CARBlockstore(
// GetDAH returns the DataAvailabilityHeader for the EDS identified by DataHash.
func (s *Store) GetDAH(ctx context.Context, root share.DataHash) (*share.Root, error) {
key := shard.KeyFromString(root.String())
accessor, err := s.acquireShard(ctx, key)
accessor, err := s.getAccessor(ctx, key)
if err != nil {
return nil, fmt.Errorf("eds/store: failed to get accessor: %w", err)
}
Expand Down Expand Up @@ -252,7 +252,7 @@ func dahFromCARHeader(carHeader *carv1.CarHeader) *header.DataAvailabilityHeader
}
}

func (s *Store) acquireShard(ctx context.Context, key shard.Key) (*dagstore.ShardAccessor, error) {
func (s *Store) getAccessor(ctx context.Context, key shard.Key) (*dagstore.ShardAccessor, error) {
ch := make(chan dagstore.ShardResult, 1)
err := s.dgstr.AcquireShard(ctx, key, ch, dagstore.AcquireOpts{})
if err != nil {
Expand All @@ -270,7 +270,7 @@ func (s *Store) acquireShard(ctx context.Context, key shard.Key) (*dagstore.Shar
}
}

func (s *Store) getAccessor(ctx context.Context, key shard.Key) (*accessorWithBlockstore, error) {
func (s *Store) getCachedAccessor(ctx context.Context, key shard.Key) (*accessorWithBlockstore, error) {
// try to fetch from cache
accessor, err := s.cache.Get(key)
if err != nil && err != errCacheMiss {
Expand All @@ -281,7 +281,7 @@ func (s *Store) getAccessor(ctx context.Context, key shard.Key) (*accessorWithBl
}

// wasn't found in cache, so acquire it and add to cache
shardAccessor, err := s.acquireShard(ctx, key)
shardAccessor, err := s.getAccessor(ctx, key)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion share/eds/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func Test_BlockstoreCache(t *testing.T) {
assert.ErrorIs(t, err, errCacheMiss)

// now get it, so that the key is in the cache
_, err = edsStore.getAccessor(ctx, shardKey)
_, err = edsStore.getCachedAccessor(ctx, shardKey)
assert.NoError(t, err)
_, err = edsStore.cache.Get(shardKey)
assert.NoError(t, err, errCacheMiss)
Expand Down

0 comments on commit 3ba0a6f

Please sign in to comment.