Rename for clarity

release/1.0.1
Taylor Gerring 10 years ago
parent 7b45f3377f
commit 6669ef5b70
  1. 18
      rpc/api.go
  2. 12
      rpc/args.go
  3. 12
      rpc/args_test.go

@ -46,6 +46,13 @@ func NewEthereumApi(eth *xeth.XEth, dataDir string) *EthereumApi {
return api return api
} }
func (self *EthereumApi) xeth() *xeth.XEth {
self.xethMu.RLock()
defer self.xethMu.RUnlock()
return self.eth
}
func (self *EthereumApi) xethWithStateNum(num int64) *xeth.XEth { func (self *EthereumApi) xethWithStateNum(num int64) *xeth.XEth {
chain := self.xeth().Backend().ChainManager() chain := self.xeth().Backend().ChainManager()
var block *types.Block var block *types.Block
@ -328,7 +335,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return err return err
} }
v, err := p.GetBlockByHash(args.BlockHash, args.Transactions) v, err := p.GetBlockByHash(args.BlockHash, args.IncludeTxs)
if err != nil { if err != nil {
return err return err
} }
@ -339,7 +346,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return err return err
} }
v, err := p.GetBlockByNumber(args.BlockNumber, args.Transactions) v, err := p.GetBlockByNumber(args.BlockNumber, args.IncludeTxs)
if err != nil { if err != nil {
return err return err
} }
@ -580,13 +587,6 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return nil return nil
} }
func (self *EthereumApi) xeth() *xeth.XEth {
self.xethMu.RLock()
defer self.xethMu.RUnlock()
return self.eth
}
func toFilterOptions(options *FilterOptions) *core.FilterOptions { func toFilterOptions(options *FilterOptions) *core.FilterOptions {
var opts core.FilterOptions var opts core.FilterOptions

@ -35,8 +35,8 @@ func blockAge(raw interface{}, number *int64) (err error) {
} }
type GetBlockByHashArgs struct { type GetBlockByHashArgs struct {
BlockHash string BlockHash string
Transactions bool IncludeTxs bool
} }
func (args *GetBlockByHashArgs) UnmarshalJSON(b []byte) (err error) { func (args *GetBlockByHashArgs) UnmarshalJSON(b []byte) (err error) {
@ -57,15 +57,15 @@ func (args *GetBlockByHashArgs) UnmarshalJSON(b []byte) (err error) {
args.BlockHash = argstr args.BlockHash = argstr
if len(obj) > 1 { if len(obj) > 1 {
args.Transactions = obj[1].(bool) args.IncludeTxs = obj[1].(bool)
} }
return nil return nil
} }
type GetBlockByNumberArgs struct { type GetBlockByNumberArgs struct {
BlockNumber int64 BlockNumber int64
Transactions bool IncludeTxs bool
} }
func (args *GetBlockByNumberArgs) UnmarshalJSON(b []byte) (err error) { func (args *GetBlockByNumberArgs) UnmarshalJSON(b []byte) (err error) {
@ -86,7 +86,7 @@ func (args *GetBlockByNumberArgs) UnmarshalJSON(b []byte) (err error) {
} }
if len(obj) > 1 { if len(obj) > 1 {
args.Transactions = obj[1].(bool) args.IncludeTxs = obj[1].(bool)
} }
return nil return nil

@ -82,7 +82,7 @@ func TestGetBlockByHashArgs(t *testing.T) {
input := `["0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331", true]` input := `["0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331", true]`
expected := new(GetBlockByHashArgs) expected := new(GetBlockByHashArgs)
expected.BlockHash = "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331" expected.BlockHash = "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331"
expected.Transactions = true expected.IncludeTxs = true
args := new(GetBlockByHashArgs) args := new(GetBlockByHashArgs)
if err := json.Unmarshal([]byte(input), &args); err != nil { if err := json.Unmarshal([]byte(input), &args); err != nil {
@ -93,8 +93,8 @@ func TestGetBlockByHashArgs(t *testing.T) {
t.Errorf("BlockHash should be %v but is %v", expected.BlockHash, args.BlockHash) t.Errorf("BlockHash should be %v but is %v", expected.BlockHash, args.BlockHash)
} }
if args.Transactions != expected.Transactions { if args.IncludeTxs != expected.IncludeTxs {
t.Errorf("Transactions should be %v but is %v", expected.Transactions, args.Transactions) t.Errorf("IncludeTxs should be %v but is %v", expected.IncludeTxs, args.IncludeTxs)
} }
} }
@ -112,7 +112,7 @@ func TestGetBlockByNumberArgs(t *testing.T) {
input := `["0x1b4", false]` input := `["0x1b4", false]`
expected := new(GetBlockByNumberArgs) expected := new(GetBlockByNumberArgs)
expected.BlockNumber = 436 expected.BlockNumber = 436
expected.Transactions = false expected.IncludeTxs = false
args := new(GetBlockByNumberArgs) args := new(GetBlockByNumberArgs)
if err := json.Unmarshal([]byte(input), &args); err != nil { if err := json.Unmarshal([]byte(input), &args); err != nil {
@ -123,8 +123,8 @@ func TestGetBlockByNumberArgs(t *testing.T) {
t.Errorf("BlockHash should be %v but is %v", expected.BlockNumber, args.BlockNumber) t.Errorf("BlockHash should be %v but is %v", expected.BlockNumber, args.BlockNumber)
} }
if args.Transactions != expected.Transactions { if args.IncludeTxs != expected.IncludeTxs {
t.Errorf("Transactions should be %v but is %v", expected.Transactions, args.Transactions) t.Errorf("IncludeTxs should be %v but is %v", expected.IncludeTxs, args.IncludeTxs)
} }
} }

Loading…
Cancel
Save