Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions swarm/storage/filestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"io"
"sort"
"sync"
)

/*
Expand Down Expand Up @@ -104,6 +105,7 @@ func (f *FileStore) GetAllReferences(ctx context.Context, data io.Reader, toEncr
putter := &HashExplorer{
hasherStore: NewHasherStore(f.ChunkStore, f.hashFunc, toEncrypt),
References: make([]Reference, 0),
lock: &sync.RWMutex{},
}
// do the actual splitting anyway, no way around it
_, _, err = PyramidSplit(ctx, data, putter, putter)
Expand All @@ -123,6 +125,7 @@ func (f *FileStore) GetAllReferences(ctx context.Context, data io.Reader, toEncr
type HashExplorer struct {
*hasherStore
References []Reference
lock *sync.RWMutex
}

// HashExplorer's Put will add just the chunk hashes to its `References`
Expand All @@ -133,6 +136,8 @@ func (he *HashExplorer) Put(ctx context.Context, chunkData ChunkData) (Reference
return nil, err
}
// internally store the reference
he.lock.Lock()
he.References = append(he.References, ref)
he.lock.Unlock()
return ref, nil
}