Merge branch 'rpcfrontier' of github.com-obscure:ethereum/go-ethereum into rpcfrontier
This commit is contained in:
commit
2da7af4ba0
47
rpc/api.go
47
rpc/api.go
|
@ -394,7 +394,7 @@ func (self *EthereumApi) MessagesChanged(id int, reply *interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *EthereumApi) WhisperPost(args *WhisperMessageArgs, reply *interface{}) error {
|
func (p *EthereumApi) WhisperPost(args *WhisperMessageArgs, reply *interface{}) error {
|
||||||
err := p.xeth().Whisper().Post(args.Payload, args.To, args.From, args.Topic, args.Priority, args.Ttl)
|
err := p.xeth().Whisper().Post(args.Payload, args.To, args.From, args.Topics, args.Priority, args.Ttl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -597,10 +597,10 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if args.TxIndex > int64(len(v.Transactions)) || args.TxIndex < 0 {
|
if args.Index > int64(len(v.Transactions)) || args.Index < 0 {
|
||||||
return NewErrorWithMessage(errDecodeArgs, "Transaction index does not exist")
|
return NewErrorWithMessage(errDecodeArgs, "Transaction index does not exist")
|
||||||
}
|
}
|
||||||
*reply = v.Transactions[args.TxIndex]
|
*reply = v.Transactions[args.Index]
|
||||||
case "eth_getTransactionByBlockNumberAndIndex":
|
case "eth_getTransactionByBlockNumberAndIndex":
|
||||||
args := new(BlockNumIndexArgs)
|
args := new(BlockNumIndexArgs)
|
||||||
if err := json.Unmarshal(req.Params, &args); err != nil {
|
if err := json.Unmarshal(req.Params, &args); err != nil {
|
||||||
|
@ -611,13 +611,48 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if args.TxIndex > int64(len(v.Transactions)) || args.TxIndex < 0 {
|
if args.Index > int64(len(v.Transactions)) || args.Index < 0 {
|
||||||
return NewErrorWithMessage(errDecodeArgs, "Transaction index does not exist")
|
return NewErrorWithMessage(errDecodeArgs, "Transaction index does not exist")
|
||||||
}
|
}
|
||||||
*reply = v.Transactions[args.TxIndex]
|
*reply = v.Transactions[args.Index]
|
||||||
case "eth_getUncleByBlockHashAndIndex":
|
case "eth_getUncleByBlockHashAndIndex":
|
||||||
|
args := new(HashIndexArgs)
|
||||||
|
if err := json.Unmarshal(req.Params, &args); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
v, err := p.GetBlockByHash(args.BlockHash, false)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if args.Index > int64(len(v.Uncles)) || args.Index < 0 {
|
||||||
|
return NewErrorWithMessage(errDecodeArgs, "Uncle index does not exist")
|
||||||
|
}
|
||||||
|
|
||||||
|
uncle, err := p.GetBlockByHash(toHex(v.Uncles[args.Index]), false)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
*reply = uncle
|
||||||
case "eth_getUncleByBlockNumberAndIndex":
|
case "eth_getUncleByBlockNumberAndIndex":
|
||||||
return errNotImplemented
|
args := new(BlockNumIndexArgs)
|
||||||
|
if err := json.Unmarshal(req.Params, &args); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
v, err := p.GetBlockByNumber(args.BlockNumber, true)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if args.Index > int64(len(v.Uncles)) || args.Index < 0 {
|
||||||
|
return NewErrorWithMessage(errDecodeArgs, "Uncle index does not exist")
|
||||||
|
}
|
||||||
|
|
||||||
|
uncle, err := p.GetBlockByHash(toHex(v.Uncles[args.Index]), false)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
*reply = uncle
|
||||||
case "eth_getCompilers":
|
case "eth_getCompilers":
|
||||||
return p.GetCompilers(reply)
|
return p.GetCompilers(reply)
|
||||||
case "eth_compileSolidity":
|
case "eth_compileSolidity":
|
||||||
|
|
17
rpc/args.go
17
rpc/args.go
|
@ -40,7 +40,12 @@ func (args *GetBlockByHashArgs) UnmarshalJSON(b []byte) (err error) {
|
||||||
if len(obj) < 1 {
|
if len(obj) < 1 {
|
||||||
return errArguments
|
return errArguments
|
||||||
}
|
}
|
||||||
args.BlockHash = obj[0].(string)
|
|
||||||
|
argstr, ok := obj[0].(string)
|
||||||
|
if !ok {
|
||||||
|
return errDecodeArgs
|
||||||
|
}
|
||||||
|
args.BlockHash = argstr
|
||||||
|
|
||||||
if len(obj) > 1 {
|
if len(obj) > 1 {
|
||||||
args.Transactions = obj[1].(bool)
|
args.Transactions = obj[1].(bool)
|
||||||
|
@ -219,12 +224,12 @@ func (args *GetDataArgs) requirements() error {
|
||||||
|
|
||||||
type BlockNumIndexArgs struct {
|
type BlockNumIndexArgs struct {
|
||||||
BlockNumber int64
|
BlockNumber int64
|
||||||
TxIndex int64
|
Index int64
|
||||||
}
|
}
|
||||||
|
|
||||||
type HashIndexArgs struct {
|
type HashIndexArgs struct {
|
||||||
BlockHash string
|
BlockHash string
|
||||||
TxIndex int64
|
Index int64
|
||||||
}
|
}
|
||||||
|
|
||||||
type Sha3Args struct {
|
type Sha3Args struct {
|
||||||
|
@ -362,7 +367,7 @@ type WhisperMessageArgs struct {
|
||||||
Payload string
|
Payload string
|
||||||
To string
|
To string
|
||||||
From string
|
From string
|
||||||
Topic []string
|
Topics []string
|
||||||
Priority uint32
|
Priority uint32
|
||||||
Ttl uint32
|
Ttl uint32
|
||||||
}
|
}
|
||||||
|
@ -372,7 +377,7 @@ func (args *WhisperMessageArgs) UnmarshalJSON(b []byte) (err error) {
|
||||||
Payload string
|
Payload string
|
||||||
To string
|
To string
|
||||||
From string
|
From string
|
||||||
Topic []string
|
Topics []string
|
||||||
Priority string
|
Priority string
|
||||||
Ttl string
|
Ttl string
|
||||||
}
|
}
|
||||||
|
@ -387,7 +392,7 @@ func (args *WhisperMessageArgs) UnmarshalJSON(b []byte) (err error) {
|
||||||
args.Payload = obj[0].Payload
|
args.Payload = obj[0].Payload
|
||||||
args.To = obj[0].To
|
args.To = obj[0].To
|
||||||
args.From = obj[0].From
|
args.From = obj[0].From
|
||||||
args.Topic = obj[0].Topic
|
args.Topics = obj[0].Topics
|
||||||
args.Priority = uint32(ethutil.Big(obj[0].Priority).Int64())
|
args.Priority = uint32(ethutil.Big(obj[0].Priority).Int64())
|
||||||
args.Ttl = uint32(ethutil.Big(obj[0].Ttl).Int64())
|
args.Ttl = uint32(ethutil.Big(obj[0].Ttl).Int64())
|
||||||
|
|
||||||
|
|
|
@ -270,7 +270,7 @@ func TestFilterOptions(t *testing.T) {
|
||||||
t.Errorf("Address shoud be %#v but is %#v", expected.Address, args.Address)
|
t.Errorf("Address shoud be %#v but is %#v", expected.Address, args.Address)
|
||||||
}
|
}
|
||||||
|
|
||||||
// if expected.Topic != args.Topic {
|
// if expected.Topics != args.Topics {
|
||||||
// t.Errorf("Topic shoud be %#v but is %#v", expected.Topic, args.Topic)
|
// t.Errorf("Topic shoud be %#v but is %#v", expected.Topic, args.Topic)
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
@ -316,7 +316,7 @@ func TestWhisperMessageArgs(t *testing.T) {
|
||||||
expected.Payload = "0x68656c6c6f20776f726c64"
|
expected.Payload = "0x68656c6c6f20776f726c64"
|
||||||
expected.Priority = 100
|
expected.Priority = 100
|
||||||
expected.Ttl = 100
|
expected.Ttl = 100
|
||||||
expected.Topic = []string{"0x68656c6c6f20776f726c64"}
|
expected.Topics = []string{"0x68656c6c6f20776f726c64"}
|
||||||
|
|
||||||
args := new(WhisperMessageArgs)
|
args := new(WhisperMessageArgs)
|
||||||
if err := json.Unmarshal([]byte(input), &args); err != nil {
|
if err := json.Unmarshal([]byte(input), &args); err != nil {
|
||||||
|
@ -343,7 +343,7 @@ func TestWhisperMessageArgs(t *testing.T) {
|
||||||
t.Errorf("Priority shoud be %#v but is %#v", expected.Priority, args.Priority)
|
t.Errorf("Priority shoud be %#v but is %#v", expected.Priority, args.Priority)
|
||||||
}
|
}
|
||||||
|
|
||||||
// if expected.Topic != args.Topic {
|
// if expected.Topics != args.Topics {
|
||||||
// t.Errorf("Topic shoud be %#v but is %#v", expected.Topic, args.Topic)
|
// t.Errorf("Topic shoud be %#v but is %#v", expected.Topic, args.Topic)
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package rpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
// "fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
|
Loading…
Reference in New Issue