diff --git a/pkg/config/application_config_test.go b/pkg/config/application_config_test.go index 6b5af8d816..d8e3fc8d29 100644 --- a/pkg/config/application_config_test.go +++ b/pkg/config/application_config_test.go @@ -194,32 +194,6 @@ func TestNeoFSBlockFetcherValidation(t *testing.T) { shouldFail: true, errMsg: "addresses are not set", }, - { - cfg: NeoFSBlockFetcher{ - InternalService: InternalService{Enabled: true}, - Timeout: time.Second, - ContainerID: validContainerID, - Addresses: []string{"127.0.0.1"}, - OIDBatchSize: 10, - BQueueSize: 5, - }, - shouldFail: true, - errMsg: "BQueueSize (5) is lower than OIDBatchSize (10)", - }, - { - cfg: NeoFSBlockFetcher{ - InternalService: InternalService{Enabled: true}, - Timeout: time.Second, - ContainerID: validContainerID, - Addresses: []string{"127.0.0.1"}, - OIDBatchSize: 10, - BQueueSize: 20, - SkipIndexFilesSearch: false, - IndexFileSize: 0, - }, - shouldFail: true, - errMsg: "IndexFileSize is not set", - }, } for _, c := range cases { diff --git a/pkg/config/blockfetcher_config.go b/pkg/config/blockfetcher_config.go index 22d4d46a05..74b8266c19 100644 --- a/pkg/config/blockfetcher_config.go +++ b/pkg/config/blockfetcher_config.go @@ -38,14 +38,8 @@ func (cfg *NeoFSBlockFetcher) Validate() error { if err != nil { return fmt.Errorf("invalid container ID: %w", err) } - if cfg.BQueueSize < cfg.OIDBatchSize { - return fmt.Errorf("BQueueSize (%d) is lower than OIDBatchSize (%d)", cfg.BQueueSize, cfg.OIDBatchSize) - } if len(cfg.Addresses) == 0 { return errors.New("addresses are not set") } - if !cfg.SkipIndexFilesSearch && cfg.IndexFileSize == 0 { - return errors.New("IndexFileSize is not set") - } return nil } diff --git a/pkg/services/blockfetcher/blockfetcher.go b/pkg/services/blockfetcher/blockfetcher.go index 90a0e53fc9..6e064b809b 100644 --- a/pkg/services/blockfetcher/blockfetcher.go +++ b/pkg/services/blockfetcher/blockfetcher.go @@ -16,6 +16,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/config" "github.com/nspcc-dev/neo-go/pkg/core/block" gio "github.com/nspcc-dev/neo-go/pkg/io" + "github.com/nspcc-dev/neo-go/pkg/network/bqueue" "github.com/nspcc-dev/neo-go/pkg/services/oracle/neofs" "github.com/nspcc-dev/neo-go/pkg/wallet" "github.com/nspcc-dev/neofs-sdk-go/client" @@ -34,9 +35,15 @@ const ( // defaultTimeout is the default timeout for NeoFS requests. defaultTimeout = 5 * time.Minute // defaultOIDBatchSize is the default number of OIDs to search and fetch at once. - defaultOIDBatchSize = 8000 + defaultOIDBatchSize = bqueue.DefaultCacheSize // defaultDownloaderWorkersCount is the default number of workers downloading blocks. defaultDownloaderWorkersCount = 100 + // defaultIndexFileSize is the default size of the index file. + defaultIndexFileSize = 128000 + // defaultBlockAttribute is the default attribute name for block objects. + defaultBlockAttribute = "Block" + // defaultIndexFileAttribute is the default attribute name for index file objects. + defaultIndexFileAttribute = "Index" ) // Constants related to NeoFS pool request timeouts. @@ -151,8 +158,14 @@ func New(chain Ledger, cfg config.NeoFSBlockFetcher, logger *zap.Logger, putBloc if cfg.DownloaderWorkersCount <= 0 { cfg.DownloaderWorkersCount = defaultDownloaderWorkersCount } - if len(cfg.Addresses) == 0 { - return nil, errors.New("no addresses provided") + if cfg.IndexFileSize <= 0 { + cfg.IndexFileSize = defaultIndexFileSize + } + if cfg.BlockAttribute == "" { + cfg.BlockAttribute = defaultBlockAttribute + } + if cfg.IndexFileAttribute == "" { + cfg.IndexFileAttribute = defaultIndexFileAttribute } params := pool.DefaultOptions()