diff options
author | obscuren <geffobscura@gmail.com> | 2015-06-16 01:28:48 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-06-16 01:28:48 +0800 |
commit | 5daf8729be88eca87b302ebf7a46fc69cad0f6d0 (patch) | |
tree | 0053cb5b84978645b3c83895a651c512e081a183 /rpc/api/debug_args.go | |
parent | bac9a94ddf20dc530966cbf6cd384aaf94aedc77 (diff) | |
parent | 4673b04503742de9b1622557b44135d6a4934ad6 (diff) | |
download | dexon-5daf8729be88eca87b302ebf7a46fc69cad0f6d0.tar dexon-5daf8729be88eca87b302ebf7a46fc69cad0f6d0.tar.gz dexon-5daf8729be88eca87b302ebf7a46fc69cad0f6d0.tar.bz2 dexon-5daf8729be88eca87b302ebf7a46fc69cad0f6d0.tar.lz dexon-5daf8729be88eca87b302ebf7a46fc69cad0f6d0.tar.xz dexon-5daf8729be88eca87b302ebf7a46fc69cad0f6d0.tar.zst dexon-5daf8729be88eca87b302ebf7a46fc69cad0f6d0.zip |
Merge branch 'release/0.9.30'
Diffstat (limited to 'rpc/api/debug_args.go')
-rw-r--r-- | rpc/api/debug_args.go | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/rpc/api/debug_args.go b/rpc/api/debug_args.go new file mode 100644 index 000000000..b9b5aa27e --- /dev/null +++ b/rpc/api/debug_args.go @@ -0,0 +1,47 @@ +package api + +import ( + "encoding/json" + "fmt" + "math/big" + + "github.com/ethereum/go-ethereum/rpc/shared" +) + +type WaitForBlockArgs struct { + MinHeight int + Timeout int // in seconds +} + +func (args *WaitForBlockArgs) UnmarshalJSON(b []byte) (err error) { + var obj []interface{} + if err := json.Unmarshal(b, &obj); err != nil { + return shared.NewDecodeParamError(err.Error()) + } + + if len(obj) > 2 { + return fmt.Errorf("waitForArgs needs 0, 1, 2 arguments") + } + + // default values when not provided + args.MinHeight = -1 + args.Timeout = -1 + + if len(obj) >= 1 { + var minHeight *big.Int + if minHeight, err = numString(obj[0]); err != nil { + return err + } + args.MinHeight = int(minHeight.Int64()) + } + + if len(obj) >= 2 { + timeout, err := numString(obj[1]) + if err != nil { + return err + } + args.Timeout = int(timeout.Int64()) + } + + return nil +} |