rpcsrv: set MaxNEP11Tokens 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 13:03:52 +03:00
parent f5b0489d74
commit b89078c42a
2 changed files with 7 additions and 3 deletions

View file

@ -26,6 +26,9 @@ const (
// DefaultMaxFindStorageResultItems is the default maximum number of resulting // DefaultMaxFindStorageResultItems is the default maximum number of resulting
// contract storage items that can be retrieved by `findstorge` JSON-RPC handler. // contract storage items that can be retrieved by `findstorge` JSON-RPC handler.
DefaultMaxFindStorageResultItems = 50 DefaultMaxFindStorageResultItems = 50
// DefaultMaxNEP11Tokens is the default maximum number of resulting NEP11 tokens
// that can be traversed by `getnep11balances` JSON-RPC handler.
DefaultMaxNEP11Tokens = 100
) )
// Version is the version of the node, set at the build time. // Version is the version of the node, set at the build time.
@ -77,9 +80,6 @@ func LoadFile(configPath string) (Config, error) {
PingInterval: 30 * time.Second, PingInterval: 30 * time.Second,
PingTimeout: 90 * time.Second, PingTimeout: 90 * time.Second,
}, },
RPC: RPC{
MaxNEP11Tokens: 100,
},
}, },
} }

View file

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