diff options
author | Anton Evangelatov <anton.evangelatov@gmail.com> | 2018-08-14 22:03:56 +0800 |
---|---|---|
committer | Balint Gabor <balint.g@gmail.com> | 2018-08-14 22:03:56 +0800 |
commit | 97887d98da703a31040bceee13bce9ee77fca673 (patch) | |
tree | ffc9a8a6fba087b26d33c0ef6c939a19aaaad8c9 /swarm/storage/chunker.go | |
parent | 8a040de60bd6b740ebe87cd8e1fe6bfdb6635d2f (diff) | |
download | dexon-97887d98da703a31040bceee13bce9ee77fca673.tar dexon-97887d98da703a31040bceee13bce9ee77fca673.tar.gz dexon-97887d98da703a31040bceee13bce9ee77fca673.tar.bz2 dexon-97887d98da703a31040bceee13bce9ee77fca673.tar.lz dexon-97887d98da703a31040bceee13bce9ee77fca673.tar.xz dexon-97887d98da703a31040bceee13bce9ee77fca673.tar.zst dexon-97887d98da703a31040bceee13bce9ee77fca673.zip |
swarm/network, swarm/storage: validate chunk size (#17397)
* swarm/network, swarm/storage: validate default chunk size
* swarm/bmt, swarm/network, swarm/storage: update BMT hash initialisation
* swarm/bmt: move segmentCount to tests
* swarm/chunk: change chunk.DefaultSize to be untyped const
* swarm/storage: add size validator
* swarm/storage: add chunk size validation to localstore
* swarm/storage: move validation from localstore to validator
* swarm/storage: global chunk rules in MRU
Diffstat (limited to 'swarm/storage/chunker.go')
-rw-r--r-- | swarm/storage/chunker.go | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/swarm/storage/chunker.go b/swarm/storage/chunker.go index b9b502273..6d805b8e2 100644 --- a/swarm/storage/chunker.go +++ b/swarm/storage/chunker.go @@ -25,6 +25,7 @@ import ( "time" "github.com/ethereum/go-ethereum/metrics" + "github.com/ethereum/go-ethereum/swarm/chunk" "github.com/ethereum/go-ethereum/swarm/log" "github.com/ethereum/go-ethereum/swarm/spancontext" opentracing "github.com/opentracing/opentracing-go" @@ -69,10 +70,6 @@ var ( errOperationTimedOut = errors.New("operation timed out") ) -const ( - DefaultChunkSize int64 = 4096 -) - type ChunkerParams struct { chunkSize int64 hashSize int64 @@ -136,7 +133,7 @@ type TreeChunker struct { func TreeJoin(ctx context.Context, addr Address, getter Getter, depth int) *LazyChunkReader { jp := &JoinerParams{ ChunkerParams: ChunkerParams{ - chunkSize: DefaultChunkSize, + chunkSize: chunk.DefaultSize, hashSize: int64(len(addr)), }, addr: addr, @@ -156,7 +153,7 @@ func TreeSplit(ctx context.Context, data io.Reader, size int64, putter Putter) ( tsp := &TreeSplitterParams{ SplitterParams: SplitterParams{ ChunkerParams: ChunkerParams{ - chunkSize: DefaultChunkSize, + chunkSize: chunk.DefaultSize, hashSize: putter.RefSize(), }, reader: data, |