Merge pull request #3529 from nspcc-dev/fix-sessionexpiration-default

This commit is contained in:
Roman Khimov 2024-07-26 17:24:14 +03:00 committed by GitHub
commit 4fe9597dd5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View file

@ -250,8 +250,8 @@ where:
enable `SessionBackedByMPT`, see `SessionBackedByMPT` documentation for more
details.
- `SessionExpirationTime` is a lifetime of iterator session in seconds. It is set
to `TimePerBlock` seconds by default and is relevant only if `SessionEnabled`
is set to `true`.
to `TimePerBlock` seconds (but not less than 5s) by default and is relevant
only if `SessionEnabled` is set to `true`.
- `SessionBackedByMPT` is a flag forcing JSON-RPC server into using MPT-backed
storage for delayed iterator traversal. If `true`, then iterator resources got
after `invoke*` calls will be released immediately. Further iterator traversing

View file

@ -274,6 +274,9 @@ func New(chain Ledger, conf config.RPC, coreServer *network.Server,
if conf.SessionEnabled {
if conf.SessionExpirationTime <= 0 {
conf.SessionExpirationTime = int(protoCfg.TimePerBlock / time.Second)
if conf.SessionExpirationTime < 5 {
conf.SessionExpirationTime = 5
}
log.Info("SessionExpirationTime is not set or wrong, setting default value", zap.Int("SessionExpirationTime", conf.SessionExpirationTime))
}
if conf.SessionPoolSize <= 0 {