inline GetBlockByNumber
This commit is contained in:
parent
bde161382a
commit
1d6451f5c3
33
rpc/api.go
33
rpc/api.go
@ -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")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user