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
This commit is contained in:
committed by
Balint Gabor
parent
8a040de60b
commit
97887d98da
@@ -55,9 +55,6 @@ Two implementations are provided:
|
||||
*/
|
||||
|
||||
const (
|
||||
// SegmentCount is the maximum number of segments of the underlying chunk
|
||||
// Should be equal to max-chunk-data-size / hash-size
|
||||
SegmentCount = 128
|
||||
// PoolSize is the maximum number of bmt trees used by the hashers, i.e,
|
||||
// the maximum number of concurrent BMT hashing operations performed by the same hasher
|
||||
PoolSize = 8
|
||||
@@ -318,7 +315,7 @@ func (h *Hasher) Sum(b []byte) (s []byte) {
|
||||
// with every full segment calls writeSection in a go routine
|
||||
func (h *Hasher) Write(b []byte) (int, error) {
|
||||
l := len(b)
|
||||
if l == 0 || l > 4096 {
|
||||
if l == 0 || l > h.pool.Size {
|
||||
return 0, nil
|
||||
}
|
||||
t := h.getTree()
|
||||
|
Reference in New Issue
Block a user