lib/uplink: minor fixes (#2257)

This commit is contained in:
JT Olio 2019-06-20 15:50:13 -06:00 committed by Stefan Benten
parent d435d4859d
commit 06006effb3
2 changed files with 6 additions and 5 deletions

View File

@ -70,9 +70,6 @@ func (cfg *BucketConfig) setDefaults() {
if cfg.EncryptionParameters.CipherSuite == storj.EncUnspecified {
cfg.EncryptionParameters.CipherSuite = defaultCipher
}
if cfg.EncryptionParameters.BlockSize == 0 {
cfg.EncryptionParameters.BlockSize = (1 * memory.KiB).Int32()
}
if cfg.Volatile.RedundancyScheme.RequiredShares == 0 {
cfg.Volatile.RedundancyScheme.RequiredShares = 29
}
@ -88,6 +85,9 @@ func (cfg *BucketConfig) setDefaults() {
if cfg.Volatile.RedundancyScheme.ShareSize == 0 {
cfg.Volatile.RedundancyScheme.ShareSize = (1 * memory.KiB).Int32()
}
if cfg.EncryptionParameters.BlockSize == 0 {
cfg.EncryptionParameters.BlockSize = cfg.Volatile.RedundancyScheme.ShareSize * int32(cfg.Volatile.RedundancyScheme.RequiredShares)
}
if cfg.Volatile.SegmentsSize.Int() == 0 {
cfg.Volatile.SegmentsSize = 64 * memory.MiB
}

View File

@ -5,7 +5,8 @@ package kvmetainfo
import (
"context"
"fmt"
"github.com/zeebo/errs"
"storj.io/storj/pkg/storage/buckets"
"storj.io/storj/pkg/storj"
@ -75,7 +76,7 @@ func validateBlockSize(redundancyScheme storj.RedundancyScheme, blockSize int32)
stripeSize := redundancyScheme.StripeSize()
if blockSize%stripeSize != 0 {
return fmt.Errorf("encryption BlockSize (%d) must be a multiple of RS ShareSize (%d) * RS RequiredShares (%d)",
return errs.New("encryption BlockSize (%d) must be a multiple of RS ShareSize (%d) * RS RequiredShares (%d)",
blockSize, redundancyScheme.ShareSize, redundancyScheme.RequiredShares,
)
}