aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/api/admin_args.go
diff options
context:
space:
mode:
authorzelig <viktor.tron@gmail.com>2015-07-02 23:38:48 +0800
committerJeffrey Wilcke <geffobscura@gmail.com>2015-07-07 16:43:49 +0800
commit518dc87db3dd09aed21f255f448f95dcc746dc12 (patch)
treea73eb6ec79e53d69523aee1d1d4b025542a488f4 /rpc/api/admin_args.go
parent6391ec0c8f5ea645d772ede9f4c6fbda3d84105f (diff)
downloaddexon-518dc87db3dd09aed21f255f448f95dcc746dc12.tar
dexon-518dc87db3dd09aed21f255f448f95dcc746dc12.tar.gz
dexon-518dc87db3dd09aed21f255f448f95dcc746dc12.tar.bz2
dexon-518dc87db3dd09aed21f255f448f95dcc746dc12.tar.lz
dexon-518dc87db3dd09aed21f255f448f95dcc746dc12.tar.xz
dexon-518dc87db3dd09aed21f255f448f95dcc746dc12.tar.zst
dexon-518dc87db3dd09aed21f255f448f95dcc746dc12.zip
fix sleepBlocks, implement sleep
Diffstat (limited to 'rpc/api/admin_args.go')
-rw-r--r--rpc/api/admin_args.go40
1 files changed, 32 insertions, 8 deletions
diff --git a/rpc/api/admin_args.go b/rpc/api/admin_args.go
index a4d692c0a..e7548c7be 100644
--- a/rpc/api/admin_args.go
+++ b/rpc/api/admin_args.go
@@ -149,6 +149,30 @@ func (args *StartRPCArgs) UnmarshalJSON(b []byte) (err error) {
return nil
}
+type SleepArgs struct {
+ S int
+}
+
+func (args *SleepArgs) UnmarshalJSON(b []byte) (err error) {
+
+ var obj []interface{}
+ if err := json.Unmarshal(b, &obj); err != nil {
+ return shared.NewDecodeParamError(err.Error())
+ }
+ if len(obj) >= 1 {
+ if obj[0] != nil {
+ if n, err := numString(obj[0]); err == nil {
+ args.S = int(n.Int64())
+ } else {
+ return shared.NewInvalidTypeError("N", "not an integer: "+err.Error())
+ }
+ } else {
+ return shared.NewInsufficientParamsError(0, 1)
+ }
+ }
+ return nil
+}
+
type SleepBlocksArgs struct {
N int64
Timeout int64
@@ -163,19 +187,19 @@ func (args *SleepBlocksArgs) UnmarshalJSON(b []byte) (err error) {
args.N = 1
args.Timeout = 0
- if len(obj) >= 1 {
- if n, ok := obj[0].(int64); ok {
- args.N = n
+ if len(obj) >= 1 && obj[0] != nil {
+ if n, err := numString(obj[0]); err == nil {
+ args.N = n.Int64()
} else {
- return shared.NewInvalidTypeError("N", "not an integer")
+ return shared.NewInvalidTypeError("N", "not an integer: "+err.Error())
}
}
- if len(obj) >= 2 {
- if n, ok := obj[1].(int64); ok {
- args.Timeout = n
+ if len(obj) >= 2 && obj[1] != nil {
+ if n, err := numString(obj[1]); err == nil {
+ args.Timeout = n.Int64()
} else {
- return shared.NewInvalidTypeError("N", "not an integer")
+ return shared.NewInvalidTypeError("Timeout", "not an integer: "+err.Error())
}
}