diff options
author | Péter Szilágyi <peterke@gmail.com> | 2019-05-10 19:09:01 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-10 19:09:01 +0800 |
commit | 494f5d448a1685d5de4cb1524b863cd1fc9a13b0 (patch) | |
tree | 4db9d1afe4910c888f3488cd93e8537501d88314 /swarm/storage/pyramid.go | |
parent | c94d582aa781b26412ba7d570f6707d193303a02 (diff) | |
parent | 9b1543c282f39d452f611eeee0307bdf828e8bc2 (diff) | |
download | go-tangerine-494f5d448a1685d5de4cb1524b863cd1fc9a13b0.tar go-tangerine-494f5d448a1685d5de4cb1524b863cd1fc9a13b0.tar.gz go-tangerine-494f5d448a1685d5de4cb1524b863cd1fc9a13b0.tar.bz2 go-tangerine-494f5d448a1685d5de4cb1524b863cd1fc9a13b0.tar.lz go-tangerine-494f5d448a1685d5de4cb1524b863cd1fc9a13b0.tar.xz go-tangerine-494f5d448a1685d5de4cb1524b863cd1fc9a13b0.tar.zst go-tangerine-494f5d448a1685d5de4cb1524b863cd1fc9a13b0.zip |
Merge pull request #19550 from ethersphere/swarm-rather-stable
swarm v0.4-rc1
Diffstat (limited to 'swarm/storage/pyramid.go')
-rw-r--r-- | swarm/storage/pyramid.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/swarm/storage/pyramid.go b/swarm/storage/pyramid.go index 281bbe9fe..9b0d5397b 100644 --- a/swarm/storage/pyramid.go +++ b/swarm/storage/pyramid.go @@ -96,12 +96,12 @@ func NewPyramidSplitterParams(addr Address, reader io.Reader, putter Putter, get When splitting, data is given as a SectionReader, and the key is a hashSize long byte slice (Address), the root hash of the entire content will fill this once processing finishes. New chunks to store are store using the putter which the caller provides. */ -func PyramidSplit(ctx context.Context, reader io.Reader, putter Putter, getter Getter) (Address, func(context.Context) error, error) { - return NewPyramidSplitter(NewPyramidSplitterParams(nil, reader, putter, getter, chunk.DefaultSize)).Split(ctx) +func PyramidSplit(ctx context.Context, reader io.Reader, putter Putter, getter Getter, tag *chunk.Tag) (Address, func(context.Context) error, error) { + return NewPyramidSplitter(NewPyramidSplitterParams(nil, reader, putter, getter, chunk.DefaultSize), tag).Split(ctx) } -func PyramidAppend(ctx context.Context, addr Address, reader io.Reader, putter Putter, getter Getter) (Address, func(context.Context) error, error) { - return NewPyramidSplitter(NewPyramidSplitterParams(addr, reader, putter, getter, chunk.DefaultSize)).Append(ctx) +func PyramidAppend(ctx context.Context, addr Address, reader io.Reader, putter Putter, getter Getter, tag *chunk.Tag) (Address, func(context.Context) error, error) { + return NewPyramidSplitter(NewPyramidSplitterParams(addr, reader, putter, getter, chunk.DefaultSize), tag).Append(ctx) } // Entry to create a tree node @@ -142,6 +142,7 @@ type PyramidChunker struct { putter Putter getter Getter key Address + tag *chunk.Tag workerCount int64 workerLock sync.RWMutex jobC chan *chunkJob @@ -152,7 +153,7 @@ type PyramidChunker struct { chunkLevel [][]*TreeEntry } -func NewPyramidSplitter(params *PyramidSplitterParams) (pc *PyramidChunker) { +func NewPyramidSplitter(params *PyramidSplitterParams, tag *chunk.Tag) (pc *PyramidChunker) { pc = &PyramidChunker{} pc.reader = params.reader pc.hashSize = params.hashSize @@ -161,6 +162,7 @@ func NewPyramidSplitter(params *PyramidSplitterParams) (pc *PyramidChunker) { pc.putter = params.putter pc.getter = params.getter pc.key = params.addr + pc.tag = tag pc.workerCount = 0 pc.jobC = make(chan *chunkJob, 2*ChunkProcessors) pc.wg = &sync.WaitGroup{} @@ -273,6 +275,7 @@ func (pc *PyramidChunker) processor(ctx context.Context, id int64) { return } pc.processChunk(ctx, id, job) + pc.tag.Inc(chunk.StateSplit) case <-pc.quitC: return } |