diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-02-25 00:29:08 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-02-25 00:29:08 +0800 |
commit | 0b757ad12f6e79f8d8d92e412425f46a66d408c1 (patch) | |
tree | d77ed1a302a0683ca9bc44a7228a649b5173875d /rpc | |
parent | 0adff214c38a501efc99d68e7365b475020c0516 (diff) | |
parent | 6fd894aae00c8c0f9f33eae7353dd9afd97f4fa1 (diff) | |
download | dexon-0b757ad12f6e79f8d8d92e412425f46a66d408c1.tar.gz dexon-0b757ad12f6e79f8d8d92e412425f46a66d408c1.tar.zst dexon-0b757ad12f6e79f8d8d92e412425f46a66d408c1.zip |
Merge pull request #369 from tgerring/issue367
Allow zero and negative block numbers
Diffstat (limited to 'rpc')
-rw-r--r-- | rpc/args.go | 7 | ||||
-rw-r--r-- | rpc/packages.go | 12 |
2 files changed, 4 insertions, 15 deletions
diff --git a/rpc/args.go b/rpc/args.go index f730819fd..347f60410 100644 --- a/rpc/args.go +++ b/rpc/args.go @@ -22,13 +22,6 @@ func (obj *GetBlockArgs) UnmarshalJSON(b []byte) (err error) { return NewErrorResponse(ErrorDecodeArgs) } -func (obj *GetBlockArgs) requirements() error { - if obj.BlockNumber == 0 && obj.Hash == "" { - return NewErrorResponse("GetBlock requires either a block 'number' or a block 'hash' as argument") - } - return nil -} - type NewTxArgs struct { From string `json:"from"` To string `json:"to"` diff --git a/rpc/packages.go b/rpc/packages.go index 571f3a300..97227a64d 100644 --- a/rpc/packages.go +++ b/rpc/packages.go @@ -174,15 +174,11 @@ func (self *EthereumApi) AllLogs(args *FilterOptions, reply *interface{}) error } func (p *EthereumApi) GetBlock(args *GetBlockArgs, reply *interface{}) error { - err := args.requirements() - if err != nil { - return err - } - - if args.BlockNumber > 0 { - *reply = p.xeth.BlockByNumber(args.BlockNumber) - } else { + // This seems a bit precarious Maybe worth splitting to discrete functions + if len(args.Hash) > 0 { *reply = p.xeth.BlockByHash(args.Hash) + } else { + *reply = p.xeth.BlockByNumber(args.BlockNumber) } return nil } |