rpcsrv: set MaxFindResultItems to default if not specified

Do not use RPC configuration constructor for this, some external services
may skip this part.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
This commit is contained in:
Anna Shaleva 2023-08-29 12:34:53 +03:00
parent aeb7ee1021
commit dd7c762ff9
2 changed files with 7 additions and 1 deletions

View file

@ -20,6 +20,9 @@ const (
// iterator items per JSON-RPC response. It covers both session-based and
// naive iterators.
DefaultMaxIteratorResultItems = 100
// DefaultMaxFindResultItems is the default maximum number of resulting
// contract states items that can be retrieved by `findstates` JSON-RPC handler.
DefaultMaxFindResultItems = 100
// DefaultMaxFindStorageResultItems is the default maximum number of resulting
// contract storage items that can be retrieved by `findstorge` JSON-RPC handler.
DefaultMaxFindStorageResultItems = 50
@ -75,7 +78,6 @@ func LoadFile(configPath string) (Config, error) {
PingTimeout: 90 * time.Second,
},
RPC: RPC{
MaxFindResultItems: 100,
MaxFindStorageResultItems: DefaultMaxFindStorageResultItems,
MaxNEP11Tokens: 100,
},

View file

@ -299,6 +299,10 @@ func New(chain Ledger, conf config.RPC, coreServer *network.Server,
conf.MaxIteratorResultItems = config.DefaultMaxIteratorResultItems
log.Info("MaxIteratorResultItems is not set or wrong, setting default value", zap.Int("MaxIteratorResultItems", config.DefaultMaxIteratorResultItems))
}
if conf.MaxFindResultItems <= 0 {
conf.MaxFindResultItems = config.DefaultMaxFindResultItems
log.Info("MaxFindResultItems is not set or wrong, setting default value", zap.Int("MaxFindResultItems", config.DefaultMaxFindResultItems))
}
if conf.MaxWebSocketClients == 0 {
conf.MaxWebSocketClients = defaultMaxWebSocketClients
log.Info("MaxWebSocketClients is not set or wrong, setting default value", zap.Int("MaxWebSocketClients", defaultMaxWebSocketClients))