From dd7c762ff968b95896994d7fe86d38416f6ce705 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Tue, 29 Aug 2023 12:34:53 +0300 Subject: [PATCH] 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 --- pkg/config/config.go | 4 +++- pkg/services/rpcsrv/server.go | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index ed701d8ac..47318828c 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -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, }, diff --git a/pkg/services/rpcsrv/server.go b/pkg/services/rpcsrv/server.go index 153458cc7..d1f1a00c5 100644 --- a/pkg/services/rpcsrv/server.go +++ b/pkg/services/rpcsrv/server.go @@ -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))