forked from TrueCloudLab/neoneo-go
rpc: restrict default SessionExpirationTime
This commit is contained in:
parent
b5d39a3ffd
commit
47ffc1f3e8
3 changed files with 11 additions and 10 deletions
|
@ -137,7 +137,7 @@ RPC:
|
||||||
MaxNEP11Tokens: 100
|
MaxNEP11Tokens: 100
|
||||||
Port: 10332
|
Port: 10332
|
||||||
SessionEnabled: false
|
SessionEnabled: false
|
||||||
SessionExpirationTime: 60
|
SessionExpirationTime: 15
|
||||||
SessionBackedByMPT: false
|
SessionBackedByMPT: false
|
||||||
StartWhenSynchronized: false
|
StartWhenSynchronized: false
|
||||||
TLSConfig:
|
TLSConfig:
|
||||||
|
@ -177,8 +177,8 @@ where:
|
||||||
enable `SessionBackedByMPT`, see `SessionBackedByMPT` documentation for more
|
enable `SessionBackedByMPT`, see `SessionBackedByMPT` documentation for more
|
||||||
details.
|
details.
|
||||||
- `SessionExpirationTime` is a lifetime of iterator session in seconds. It is set
|
- `SessionExpirationTime` is a lifetime of iterator session in seconds. It is set
|
||||||
to `60` seconds by default and is relevant only if `SessionEnabled` is set to
|
to `SecondsPerBlock` seconds by default and is relevant only if `SessionEnabled`
|
||||||
`true`.
|
is set to `true`.
|
||||||
- `SessionBackedByMPT` is a flag forcing JSON-RPC server into using MPT-backed
|
- `SessionBackedByMPT` is a flag forcing JSON-RPC server into using MPT-backed
|
||||||
storage for delayed iterator traversal. If `true`, then iterator resources got
|
storage for delayed iterator traversal. If `true`, then iterator resources got
|
||||||
after `invoke*` calls will be released immediately. Further iterator traversing
|
after `invoke*` calls will be released immediately. Further iterator traversing
|
||||||
|
|
|
@ -19,9 +19,6 @@ const (
|
||||||
// DefaultMaxIteratorResultItems is the default upper bound of traversed
|
// DefaultMaxIteratorResultItems is the default upper bound of traversed
|
||||||
// iterator items per JSON-RPC response.
|
// iterator items per JSON-RPC response.
|
||||||
DefaultMaxIteratorResultItems = 100
|
DefaultMaxIteratorResultItems = 100
|
||||||
// DefaultSessionExpirationTime is the default session expiration time in
|
|
||||||
// seconds for iterator RPC-server session.
|
|
||||||
DefaultSessionExpirationTime = 60
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Version is the version of the node, set at the build time.
|
// Version is the version of the node, set at the build time.
|
||||||
|
@ -65,7 +62,6 @@ func LoadFile(configPath string) (Config, error) {
|
||||||
MaxIteratorResultItems: DefaultMaxIteratorResultItems,
|
MaxIteratorResultItems: DefaultMaxIteratorResultItems,
|
||||||
MaxFindResultItems: 100,
|
MaxFindResultItems: 100,
|
||||||
MaxNEP11Tokens: 100,
|
MaxNEP11Tokens: 100,
|
||||||
SessionExpirationTime: DefaultSessionExpirationTime,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,13 +202,18 @@ func New(chain blockchainer.Blockchainer, conf rpc.Config, coreServer *network.S
|
||||||
if orc != nil {
|
if orc != nil {
|
||||||
orc.SetBroadcaster(broadcaster.New(orc.MainCfg, log))
|
orc.SetBroadcaster(broadcaster.New(orc.MainCfg, log))
|
||||||
}
|
}
|
||||||
|
protoCfg := chain.GetConfig()
|
||||||
|
if conf.SessionEnabled && conf.SessionExpirationTime <= 0 {
|
||||||
|
conf.SessionExpirationTime = protoCfg.SecondsPerBlock
|
||||||
|
log.Info("SessionExpirationTime is not set or wrong, setting default value", zap.Int("SessionExpirationTime", protoCfg.SecondsPerBlock))
|
||||||
|
}
|
||||||
return Server{
|
return Server{
|
||||||
Server: httpServer,
|
Server: httpServer,
|
||||||
chain: chain,
|
chain: chain,
|
||||||
config: conf,
|
config: conf,
|
||||||
wsReadLimit: int64(chain.GetConfig().MaxBlockSize*4)/3 + 1024, // Enough for Base64-encoded content of `submitblock` and `submitp2pnotaryrequest`.
|
wsReadLimit: int64(protoCfg.MaxBlockSize*4)/3 + 1024, // Enough for Base64-encoded content of `submitblock` and `submitp2pnotaryrequest`.
|
||||||
network: chain.GetConfig().Magic,
|
network: protoCfg.Magic,
|
||||||
stateRootEnabled: chain.GetConfig().StateRootInHeader,
|
stateRootEnabled: protoCfg.StateRootInHeader,
|
||||||
coreServer: coreServer,
|
coreServer: coreServer,
|
||||||
log: log,
|
log: log,
|
||||||
oracle: orc,
|
oracle: orc,
|
||||||
|
|
Loading…
Reference in a new issue