aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/api/debug_args.go
diff options
context:
space:
mode:
authorBas van Kervel <bas@ethdev.com>2015-06-09 15:48:18 +0800
committerBas van Kervel <basvankervel@gmail.com>2015-06-11 20:01:41 +0800
commit09d0d55fc579701191ff34f38cc20b437ee23577 (patch)
tree16f77a960c7428145961891b7f116e25dc6daf1b /rpc/api/debug_args.go
parentfaab931ce1282dea50c8fdf0577c42ee67f69828 (diff)
downloaddexon-09d0d55fc579701191ff34f38cc20b437ee23577.tar.gz
dexon-09d0d55fc579701191ff34f38cc20b437ee23577.tar.zst
dexon-09d0d55fc579701191ff34f38cc20b437ee23577.zip
added debug API
Diffstat (limited to 'rpc/api/debug_args.go')
-rw-r--r--rpc/api/debug_args.go47
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
+}