diff options
Diffstat (limited to 'rpc/api')
-rw-r--r-- | rpc/api/admin.go | 8 | ||||
-rw-r--r-- | rpc/api/debug.go | 2 | ||||
-rw-r--r-- | rpc/api/eth.go | 50 | ||||
-rw-r--r-- | rpc/api/eth_args.go | 6 |
4 files changed, 32 insertions, 34 deletions
diff --git a/rpc/api/admin.go b/rpc/api/admin.go index 8af69b189..6aa04e667 100644 --- a/rpc/api/admin.go +++ b/rpc/api/admin.go @@ -151,7 +151,7 @@ func (self *adminApi) DataDir(req *shared.Request) (interface{}, error) { return self.ethereum.DataDir, nil } -func hasAllBlocks(chain *core.ChainManager, bs []*types.Block) bool { +func hasAllBlocks(chain *core.BlockChain, bs []*types.Block) bool { for _, b := range bs { if !chain.HasBlock(b.Hash()) { return false @@ -193,10 +193,10 @@ func (self *adminApi) ImportChain(req *shared.Request) (interface{}, error) { break } // Import the batch. - if hasAllBlocks(self.ethereum.ChainManager(), blocks[:i]) { + if hasAllBlocks(self.ethereum.BlockChain(), blocks[:i]) { continue } - if _, err := self.ethereum.ChainManager().InsertChain(blocks[:i]); err != nil { + if _, err := self.ethereum.BlockChain().InsertChain(blocks[:i]); err != nil { return false, fmt.Errorf("invalid block %d: %v", n, err) } } @@ -214,7 +214,7 @@ func (self *adminApi) ExportChain(req *shared.Request) (interface{}, error) { return false, err } defer fh.Close() - if err := self.ethereum.ChainManager().Export(fh); err != nil { + if err := self.ethereum.BlockChain().Export(fh); err != nil { return false, err } diff --git a/rpc/api/debug.go b/rpc/api/debug.go index d325b1720..e193f7ad2 100644 --- a/rpc/api/debug.go +++ b/rpc/api/debug.go @@ -152,7 +152,7 @@ func (self *debugApi) SetHead(req *shared.Request) (interface{}, error) { return nil, fmt.Errorf("block #%d not found", args.BlockNumber) } - self.ethereum.ChainManager().SetHead(block) + self.ethereum.BlockChain().SetHead(block) return nil, nil } diff --git a/rpc/api/eth.go b/rpc/api/eth.go index 30366a951..6db006a46 100644 --- a/rpc/api/eth.go +++ b/rpc/api/eth.go @@ -168,7 +168,7 @@ func (self *ethApi) IsMining(req *shared.Request) (interface{}, error) { } func (self *ethApi) IsSyncing(req *shared.Request) (interface{}, error) { - current := self.ethereum.ChainManager().CurrentBlock().NumberU64() + current := self.ethereum.BlockChain().CurrentBlock().NumberU64() origin, height := self.ethereum.Downloader().Boundaries() if current < height { @@ -210,7 +210,7 @@ func (self *ethApi) GetTransactionCount(req *shared.Request) (interface{}, error } count := self.xeth.AtStateNum(args.BlockNumber).TxCountAt(args.Address) - return newHexNum(big.NewInt(int64(count)).Bytes()), nil + return fmt.Sprintf("%#x", count), nil } func (self *ethApi) GetBlockTransactionCountByHash(req *shared.Request) (interface{}, error) { @@ -218,14 +218,11 @@ func (self *ethApi) GetBlockTransactionCountByHash(req *shared.Request) (interfa if err := self.codec.Decode(req.Params, &args); err != nil { return nil, shared.NewDecodeParamError(err.Error()) } - - raw := self.xeth.EthBlockByHash(args.Hash) - block := NewBlockRes(raw, self.xeth.Td(raw.Hash()), false) + block := self.xeth.EthBlockByHash(args.Hash) if block == nil { return nil, nil - } else { - return newHexNum(big.NewInt(int64(len(block.Transactions))).Bytes()), nil } + return fmt.Sprintf("%#x", len(block.Transactions())), nil } func (self *ethApi) GetBlockTransactionCountByNumber(req *shared.Request) (interface{}, error) { @@ -234,13 +231,11 @@ func (self *ethApi) GetBlockTransactionCountByNumber(req *shared.Request) (inter return nil, shared.NewDecodeParamError(err.Error()) } - raw := self.xeth.EthBlockByNumber(args.BlockNumber) - block := NewBlockRes(raw, self.xeth.Td(raw.Hash()), false) + block := self.xeth.EthBlockByNumber(args.BlockNumber) if block == nil { return nil, nil - } else { - return newHexNum(big.NewInt(int64(len(block.Transactions))).Bytes()), nil } + return fmt.Sprintf("%#x", len(block.Transactions())), nil } func (self *ethApi) GetUncleCountByBlockHash(req *shared.Request) (interface{}, error) { @@ -249,12 +244,11 @@ func (self *ethApi) GetUncleCountByBlockHash(req *shared.Request) (interface{}, return nil, shared.NewDecodeParamError(err.Error()) } - raw := self.xeth.EthBlockByHash(args.Hash) - block := NewBlockRes(raw, self.xeth.Td(raw.Hash()), false) + block := self.xeth.EthBlockByHash(args.Hash) if block == nil { return nil, nil } - return newHexNum(big.NewInt(int64(len(block.Uncles))).Bytes()), nil + return fmt.Sprintf("%#x", len(block.Uncles())), nil } func (self *ethApi) GetUncleCountByBlockNumber(req *shared.Request) (interface{}, error) { @@ -263,12 +257,11 @@ func (self *ethApi) GetUncleCountByBlockNumber(req *shared.Request) (interface{} return nil, shared.NewDecodeParamError(err.Error()) } - raw := self.xeth.EthBlockByNumber(args.BlockNumber) - block := NewBlockRes(raw, self.xeth.Td(raw.Hash()), false) + block := self.xeth.EthBlockByNumber(args.BlockNumber) if block == nil { return nil, nil } - return newHexNum(big.NewInt(int64(len(block.Uncles))).Bytes()), nil + return fmt.Sprintf("%#x", len(block.Uncles())), nil } func (self *ethApi) GetData(req *shared.Request) (interface{}, error) { @@ -377,8 +370,10 @@ func (self *ethApi) GetBlockByHash(req *shared.Request) (interface{}, error) { if err := self.codec.Decode(req.Params, &args); err != nil { return nil, shared.NewDecodeParamError(err.Error()) } - block := self.xeth.EthBlockByHash(args.BlockHash) + if block == nil { + return nil, nil + } return NewBlockRes(block, self.xeth.Td(block.Hash()), args.IncludeTxs), nil } @@ -389,6 +384,9 @@ func (self *ethApi) GetBlockByNumber(req *shared.Request) (interface{}, error) { } block := self.xeth.EthBlockByNumber(args.BlockNumber) + if block == nil { + return nil, nil + } return NewBlockRes(block, self.xeth.Td(block.Hash()), args.IncludeTxs), nil } @@ -419,10 +417,10 @@ func (self *ethApi) GetTransactionByBlockHashAndIndex(req *shared.Request) (inte } raw := self.xeth.EthBlockByHash(args.Hash) - block := NewBlockRes(raw, self.xeth.Td(raw.Hash()), true) - if block == nil { + if raw == nil { return nil, nil } + block := NewBlockRes(raw, self.xeth.Td(raw.Hash()), true) if args.Index >= int64(len(block.Transactions)) || args.Index < 0 { return nil, nil } else { @@ -437,10 +435,10 @@ func (self *ethApi) GetTransactionByBlockNumberAndIndex(req *shared.Request) (in } raw := self.xeth.EthBlockByNumber(args.BlockNumber) - block := NewBlockRes(raw, self.xeth.Td(raw.Hash()), true) - if block == nil { + if raw == nil { return nil, nil } + block := NewBlockRes(raw, self.xeth.Td(raw.Hash()), true) if args.Index >= int64(len(block.Transactions)) || args.Index < 0 { // return NewValidationError("Index", "does not exist") return nil, nil @@ -455,10 +453,10 @@ func (self *ethApi) GetUncleByBlockHashAndIndex(req *shared.Request) (interface{ } raw := self.xeth.EthBlockByHash(args.Hash) - block := NewBlockRes(raw, self.xeth.Td(raw.Hash()), false) - if block == nil { + if raw == nil { return nil, nil } + block := NewBlockRes(raw, self.xeth.Td(raw.Hash()), false) if args.Index >= int64(len(block.Uncles)) || args.Index < 0 { // return NewValidationError("Index", "does not exist") return nil, nil @@ -473,10 +471,10 @@ func (self *ethApi) GetUncleByBlockNumberAndIndex(req *shared.Request) (interfac } raw := self.xeth.EthBlockByNumber(args.BlockNumber) - block := NewBlockRes(raw, self.xeth.Td(raw.Hash()), true) - if block == nil { + if raw == nil { return nil, nil } + block := NewBlockRes(raw, self.xeth.Td(raw.Hash()), true) if args.Index >= int64(len(block.Uncles)) || args.Index < 0 { return nil, nil } else { diff --git a/rpc/api/eth_args.go b/rpc/api/eth_args.go index 8bd077e20..66c190a51 100644 --- a/rpc/api/eth_args.go +++ b/rpc/api/eth_args.go @@ -24,8 +24,8 @@ import ( "strings" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/rpc/shared" ) @@ -830,7 +830,7 @@ type LogRes struct { TransactionIndex *hexnum `json:"transactionIndex"` } -func NewLogRes(log *state.Log) LogRes { +func NewLogRes(log *vm.Log) LogRes { var l LogRes l.Topics = make([]*hexdata, len(log.Topics)) for j, topic := range log.Topics { @@ -847,7 +847,7 @@ func NewLogRes(log *state.Log) LogRes { return l } -func NewLogsRes(logs state.Logs) (ls []LogRes) { +func NewLogsRes(logs vm.Logs) (ls []LogRes) { ls = make([]LogRes, len(logs)) for i, log := range logs { |