good morning!!!!

Skip to content
Snippets Groups Projects
Commit 6fd894aa authored by Taylor Gerring's avatar Taylor Gerring
Browse files

Allow zero and negative block numbers

0 is genesis block. Xeth recognises -1 as current
parent dd086791
No related branches found
No related tags found
No related merge requests found
......@@ -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"`
......
......@@ -177,15 +177,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
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment