aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/args.go
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-03-23 15:28:54 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-03-23 15:28:54 +0800
commit372e1cad5bf02b83fd3c0becc442a5f5817f9d36 (patch)
treecea510b7e0f175d67fba39d1b4807eb835fa8af3 /rpc/args.go
parent8affdf96e23f092b7fe24d168b024b10eab35e05 (diff)
downloadgo-tangerine-372e1cad5bf02b83fd3c0becc442a5f5817f9d36.tar
go-tangerine-372e1cad5bf02b83fd3c0becc442a5f5817f9d36.tar.gz
go-tangerine-372e1cad5bf02b83fd3c0becc442a5f5817f9d36.tar.bz2
go-tangerine-372e1cad5bf02b83fd3c0becc442a5f5817f9d36.tar.lz
go-tangerine-372e1cad5bf02b83fd3c0becc442a5f5817f9d36.tar.xz
go-tangerine-372e1cad5bf02b83fd3c0becc442a5f5817f9d36.tar.zst
go-tangerine-372e1cad5bf02b83fd3c0becc442a5f5817f9d36.zip
Cleanup get/submitWork
getWork needs to return additional values
Diffstat (limited to 'rpc/args.go')
-rw-r--r--rpc/args.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/rpc/args.go b/rpc/args.go
index e50c9b1f5..504e67c07 100644
--- a/rpc/args.go
+++ b/rpc/args.go
@@ -686,3 +686,42 @@ func (args *WhisperFilterArgs) UnmarshalJSON(b []byte) (err error) {
return nil
}
+
+type SubmitWorkArgs struct {
+ Nonce uint64
+ Header common.Hash
+ Digest common.Hash
+}
+
+func (args *SubmitWorkArgs) UnmarshalJSON(b []byte) (err error) {
+ var obj []interface{}
+ if err = json.Unmarshal(b, &obj); err != nil {
+ return NewDecodeParamError(err.Error())
+ }
+
+ if len(obj) < 3 {
+ return NewInsufficientParamsError(len(obj), 3)
+ }
+
+ var objstr string
+ var ok bool
+ if objstr, ok = obj[0].(string); !ok {
+ return NewDecodeParamError("Nonce is not a string")
+ }
+
+ args.Nonce = common.BytesToNumber(common.Hex2Bytes(objstr))
+
+ if objstr, ok = obj[1].(string); !ok {
+ return NewDecodeParamError("Header is not a string")
+ }
+
+ args.Header = common.HexToHash(objstr)
+
+ if objstr, ok = obj[2].(string); !ok {
+ return NewDecodeParamError("Digest is not a string")
+ }
+
+ args.Digest = common.HexToHash(objstr)
+
+ return nil
+}