inline GetBlockByNumber

This commit is contained in:
Taylor Gerring 2015-03-20 06:57:23 +01:00
parent bde161382a
commit 1d6451f5c3

View File

@ -97,13 +97,6 @@ func (p *EthereumApi) GetStorageAt(args *GetStorageAtArgs, reply *interface{}) e
return nil return nil
} }
func (p *EthereumApi) GetBlockByNumber(blocknum int64, includetx bool) (*BlockRes, error) {
block := p.xeth().EthBlockByNumber(blocknum)
br := NewBlockRes(block)
br.fullTx = includetx
return br, nil
}
// func (self *EthereumApi) Register(args string, reply *interface{}) error { // func (self *EthereumApi) Register(args string, reply *interface{}) error {
// self.regmut.Lock() // self.regmut.Lock()
// defer self.regmut.Unlock() // defer self.regmut.Unlock()
@ -284,11 +277,11 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return err return err
} }
v, err := p.GetBlockByNumber(args.BlockNumber, args.IncludeTxs) block := p.xeth().EthBlockByNumber(args.BlockNumber)
if err != nil { br := NewBlockRes(block)
return err br.fullTx = args.IncludeTxs
}
*reply = v *reply = br
case "eth_getTransactionByHash": case "eth_getTransactionByHash":
// HashIndexArgs used, but only the "Hash" part we need. // HashIndexArgs used, but only the "Hash" part we need.
args := new(HashIndexArgs) args := new(HashIndexArgs)
@ -318,10 +311,10 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return err return err
} }
v, err := p.GetBlockByNumber(args.BlockNumber, true) block := p.xeth().EthBlockByNumber(args.BlockNumber)
if err != nil { v := NewBlockRes(block)
return err v.fullTx = true
}
if args.Index > int64(len(v.Transactions)) || args.Index < 0 { if args.Index > int64(len(v.Transactions)) || args.Index < 0 {
return NewValidationError("Index", "does not exist") return NewValidationError("Index", "does not exist")
} }
@ -348,10 +341,10 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return err return err
} }
v, err := p.GetBlockByNumber(args.BlockNumber, true) block := p.xeth().EthBlockByNumber(args.BlockNumber)
if err != nil { v := NewBlockRes(block)
return err v.fullTx = true
}
if args.Index > int64(len(v.Uncles)) || args.Index < 0 { if args.Index > int64(len(v.Uncles)) || args.Index < 0 {
return NewValidationError("Index", "does not exist") return NewValidationError("Index", "does not exist")
} }