mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-29 03:41:45 +00:00
rpc: set MaxGasInvoke in config
Implement ability to restrict maximum amount of GAS available for free RPC calls.
This commit is contained in:
parent
4718375db1
commit
54e0b5a4a7
2 changed files with 4 additions and 0 deletions
|
@ -96,6 +96,9 @@ type (
|
||||||
EnableCORSWorkaround bool `yaml:"EnableCORSWorkaround"`
|
EnableCORSWorkaround bool `yaml:"EnableCORSWorkaround"`
|
||||||
Address string `yaml:"Address"`
|
Address string `yaml:"Address"`
|
||||||
Port uint16 `yaml:"Port"`
|
Port uint16 `yaml:"Port"`
|
||||||
|
// MaxGasInvoke is a maximum amount of gas which
|
||||||
|
// can be spent during RPC call.
|
||||||
|
MaxGasInvoke util.Fixed8 `yaml:"MaxGasInvoke"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NetMode describes the mode the blockchain will operate on.
|
// NetMode describes the mode the blockchain will operate on.
|
||||||
|
|
|
@ -396,6 +396,7 @@ func (s *Server) invokescript(reqParams Params) (interface{}, error) {
|
||||||
// result.
|
// result.
|
||||||
func (s *Server) runScriptInVM(script []byte) *wrappers.InvokeResult {
|
func (s *Server) runScriptInVM(script []byte) *wrappers.InvokeResult {
|
||||||
vm, _ := s.chain.GetTestVM()
|
vm, _ := s.chain.GetTestVM()
|
||||||
|
vm.SetGasLimit(s.config.MaxGasInvoke)
|
||||||
vm.LoadScript(script)
|
vm.LoadScript(script)
|
||||||
_ = vm.Run()
|
_ = vm.Run()
|
||||||
result := &wrappers.InvokeResult{
|
result := &wrappers.InvokeResult{
|
||||||
|
|
Loading…
Reference in a new issue