aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/args.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-03-18 04:40:05 +0800
committerobscuren <geffobscura@gmail.com>2015-03-18 04:40:05 +0800
commit142e81258cd7b77226d706c84f93da417aaaf426 (patch)
tree3b84c4139d100252512db487c33e2be57191e5d3 /rpc/args.go
parent86661de07746cd4e4ad8d016afee9fa8074aa141 (diff)
parent048d4ec5be5352dcb06f5123e3458b99aa151e6b (diff)
downloaddexon-142e81258cd7b77226d706c84f93da417aaaf426.tar
dexon-142e81258cd7b77226d706c84f93da417aaaf426.tar.gz
dexon-142e81258cd7b77226d706c84f93da417aaaf426.tar.bz2
dexon-142e81258cd7b77226d706c84f93da417aaaf426.tar.lz
dexon-142e81258cd7b77226d706c84f93da417aaaf426.tar.xz
dexon-142e81258cd7b77226d706c84f93da417aaaf426.tar.zst
dexon-142e81258cd7b77226d706c84f93da417aaaf426.zip
Merge branch 'develop' into conversion
Diffstat (limited to 'rpc/args.go')
-rw-r--r--rpc/args.go68
1 files changed, 28 insertions, 40 deletions
diff --git a/rpc/args.go b/rpc/args.go
index 7ed482c30..fee44c4e0 100644
--- a/rpc/args.go
+++ b/rpc/args.go
@@ -331,42 +331,6 @@ func (args *Sha3Args) UnmarshalJSON(b []byte) (err error) {
return nil
}
-// type FilterArgs struct {
-// FromBlock uint64
-// ToBlock uint64
-// Limit uint64
-// Offset uint64
-// Address string
-// Topics []string
-// }
-
-// func (args *FilterArgs) UnmarshalJSON(b []byte) (err error) {
-// var obj []struct {
-// FromBlock string `json:"fromBlock"`
-// ToBlock string `json:"toBlock"`
-// Limit string `json:"limit"`
-// Offset string `json:"offset"`
-// Address string `json:"address"`
-// Topics []string `json:"topics"`
-// }
-
-// if err = json.Unmarshal(b, &obj); err != nil {
-// return errDecodeArgs
-// }
-
-// if len(obj) < 1 {
-// return errArguments
-// }
-// args.FromBlock = uint64(common.Big(obj[0].FromBlock).Int64())
-// args.ToBlock = uint64(common.Big(obj[0].ToBlock).Int64())
-// args.Limit = uint64(common.Big(obj[0].Limit).Int64())
-// args.Offset = uint64(common.Big(obj[0].Offset).Int64())
-// args.Address = obj[0].Address
-// args.Topics = obj[0].Topics
-
-// return nil
-// }
-
type FilterOptions struct {
Earliest int64
Latest int64
@@ -378,8 +342,8 @@ type FilterOptions struct {
func (args *FilterOptions) UnmarshalJSON(b []byte) (err error) {
var obj []struct {
- FromBlock string `json:"fromBlock"`
- ToBlock string `json:"toBlock"`
+ FromBlock interface{} `json:"fromBlock"`
+ ToBlock interface{} `json:"toBlock"`
Limit string `json:"limit"`
Offset string `json:"offset"`
Address string `json:"address"`
@@ -394,8 +358,32 @@ func (args *FilterOptions) UnmarshalJSON(b []byte) (err error) {
return NewInsufficientParamsError(len(obj), 1)
}
- args.Earliest = int64(common.Big(obj[0].FromBlock).Int64())
- args.Latest = int64(common.Big(obj[0].ToBlock).Int64())
+ fromstr, ok := obj[0].FromBlock.(string)
+ if !ok {
+ return NewDecodeParamError("FromBlock is not a string")
+ }
+
+ switch fromstr {
+ case "latest":
+ args.Earliest = 0
+ default:
+ args.Earliest = int64(common.Big(obj[0].FromBlock.(string)).Int64())
+ }
+
+ tostr, ok := obj[0].ToBlock.(string)
+ if !ok {
+ return NewDecodeParamError("ToBlock is not a string")
+ }
+
+ switch tostr {
+ case "latest":
+ args.Latest = 0
+ case "pending":
+ args.Latest = -1
+ default:
+ args.Latest = int64(common.Big(obj[0].ToBlock.(string)).Int64())
+ }
+
args.Max = int(common.Big(obj[0].Limit).Int64())
args.Skip = int(common.Big(obj[0].Offset).Int64())
args.Address = obj[0].Address