Skip to content

Commit

Permalink
rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
walldiss committed Sep 6, 2023
1 parent 1069153 commit 04d7c6c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 44 deletions.
2 changes: 1 addition & 1 deletion share/eds/cache/multicache.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (mc *MultiCache) Get(key shard.Key) (Accessor, error) {
func (mc *MultiCache) GetOrLoad(
ctx context.Context,
key shard.Key,
loader func(context.Context, shard.Key) (AccessorProvider, error),
loader func(context.Context, shard.Key) (Accessor, error),
) (Accessor, error) {
ac, err := mc.first.GetOrLoad(ctx, key, loader)
if err == nil {
Expand Down
2 changes: 1 addition & 1 deletion share/eds/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func NewStore(basepath string, ds datastore.Batching) (*Store, error) {
gcInterval: defaultGCInterval,
mounts: r,
shardFailures: failureChan,
cache: cache.NewMultiCache(recentBlocksCache, blockstoreCache),,
cache: cache.NewMultiCache(recentBlocksCache, blockstoreCache),
}
store.bs = newBlockstore(store, blockstoreCache, ds)
return store, nil
Expand Down
43 changes: 1 addition & 42 deletions share/eds/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ func Test_CachedAccessor(t *testing.T) {
require.Equal(t, firstBlock, secondBlock)
}

// Test_CachedAccessor verifies that the reader represented by a accessor obtained directly from
// Test_NotCachedAccessor verifies that the reader represented by a accessor obtained directly from
// dagstore can be read from multiple times, without exhausting the underlying reader.
func Test_NotCachedAccessor(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
Expand Down Expand Up @@ -383,47 +383,6 @@ func Test_NotCachedAccessor(t *testing.T) {
require.Equal(t, firstBlock, secondBlock)
}


// Test_CachedAccessor verifies that the reader represented by a accessor obtained directly from dagstore can be read from
// multiple times, without exhausting the underlying reader.
func Test_NotCachedAccessor(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
t.Cleanup(cancel)

edsStore, err := newStore(t)
require.NoError(t, err)
err = edsStore.Start(ctx)
require.NoError(t, err)
// replace cache with noopCache to
edsStore.cache = cache.NoopCache{}

eds, dah := randomEDS(t)
err = edsStore.Put(ctx, dah.Hash(), eds)
require.NoError(t, err)

// give some time to let cache to get settled in background
time.Sleep(time.Millisecond * 50)

// accessor should be in cache
_, err = edsStore.cache.Get(shard.KeyFromString(dah.String()))
require.ErrorIs(t, err, cache.ErrCacheMiss)

// first read from direct accessor
carReader, err := edsStore.getCAR(ctx, dah.Hash())
require.NoError(t, err)
firstBlock, err := io.ReadAll(carReader)
require.NoError(t, err)
require.NoError(t, carReader.Close())

// second read from direct accessor
carReader, err = edsStore.getCAR(ctx, dah.Hash())
require.NoError(t, err)
secondBlock, err := io.ReadAll(carReader)
require.NoError(t, err)
require.NoError(t, carReader.Close())

require.Equal(t, firstBlock, secondBlock)
}
func BenchmarkStore(b *testing.B) {
ctx, cancel := context.WithCancel(context.Background())
b.Cleanup(cancel)
Expand Down

0 comments on commit 04d7c6c

Please sign in to comment.