diff options
author | zelig <viktor.tron@gmail.com> | 2015-07-02 23:38:48 +0800 |
---|---|---|
committer | Jeffrey Wilcke <geffobscura@gmail.com> | 2015-07-07 16:43:49 +0800 |
commit | 518dc87db3dd09aed21f255f448f95dcc746dc12 (patch) | |
tree | a73eb6ec79e53d69523aee1d1d4b025542a488f4 /rpc/api/admin.go | |
parent | 6391ec0c8f5ea645d772ede9f4c6fbda3d84105f (diff) | |
download | go-tangerine-518dc87db3dd09aed21f255f448f95dcc746dc12.tar go-tangerine-518dc87db3dd09aed21f255f448f95dcc746dc12.tar.gz go-tangerine-518dc87db3dd09aed21f255f448f95dcc746dc12.tar.bz2 go-tangerine-518dc87db3dd09aed21f255f448f95dcc746dc12.tar.lz go-tangerine-518dc87db3dd09aed21f255f448f95dcc746dc12.tar.xz go-tangerine-518dc87db3dd09aed21f255f448f95dcc746dc12.tar.zst go-tangerine-518dc87db3dd09aed21f255f448f95dcc746dc12.zip |
fix sleepBlocks, implement sleep
Diffstat (limited to 'rpc/api/admin.go')
-rw-r--r-- | rpc/api/admin.go | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/rpc/api/admin.go b/rpc/api/admin.go index 0230937fa..5d214e8d8 100644 --- a/rpc/api/admin.go +++ b/rpc/api/admin.go @@ -43,7 +43,6 @@ var ( "admin_datadir": (*adminApi).DataDir, "admin_startRPC": (*adminApi).StartRPC, "admin_stopRPC": (*adminApi).StopRPC, - "admin_sleepBlocks": (*adminApi).SleepBlocks, "admin_setGlobalRegistrar": (*adminApi).SetGlobalRegistrar, "admin_setHashReg": (*adminApi).SetHashReg, "admin_setUrlHint": (*adminApi).SetUrlHint, @@ -54,6 +53,8 @@ var ( "admin_stopNatSpec": (*adminApi).StopNatSpec, "admin_getContractInfo": (*adminApi).GetContractInfo, "admin_httpGet": (*adminApi).HttpGet, + "admin_sleepBlocks": (*adminApi).SleepBlocks, + "admin_sleep": (*adminApi).Sleep, } ) @@ -303,14 +304,15 @@ func sleepBlocks(wait chan *big.Int, height *big.Int, timer <-chan time.Time) (n return } -// sec, err := call.Argument(0).ToInteger() -// if err != nil { -// fmt.Println(err) -// return otto.FalseValue() -// } -// time.Sleep(time.Duration(sec) * time.Second) -// return otto.UndefinedValue() -// } +func (self *adminApi) Sleep(req *shared.Request) (interface{}, error) { + args := new(SleepArgs) + if err := self.coder.Decode(req.Params, &args); err != nil { + return nil, shared.NewDecodeParamError(err.Error()) + } + time.Sleep(time.Duration(args.S) * time.Second) + return nil, nil +} + func (self *adminApi) SetGlobalRegistrar(req *shared.Request) (interface{}, error) { args := new(SetGlobalRegistrarArgs) if err := self.coder.Decode(req.Params, &args); err != nil { |