diff options
Diffstat (limited to 'rpc')
-rw-r--r-- | rpc/args.go | 16 | ||||
-rw-r--r-- | rpc/http/server.go | 2 | ||||
-rw-r--r-- | rpc/message.go | 1 | ||||
-rw-r--r-- | rpc/packages.go | 18 |
4 files changed, 19 insertions, 18 deletions
diff --git a/rpc/args.go b/rpc/args.go index 75eef873d..84b076d4a 100644 --- a/rpc/args.go +++ b/rpc/args.go @@ -37,16 +37,6 @@ type NewTxArgs struct { Data string `json:"data"` } -func (a *NewTxArgs) requirements() error { - if a.Gas == "" { - return NewErrorResponse("Transact requires a 'gas' value as argument") - } - if a.GasPrice == "" { - return NewErrorResponse("Transact requires a 'gasprice' value as argument") - } - return nil -} - type PushTxArgs struct { Tx string `json:"tx"` } @@ -214,7 +204,7 @@ type FilterOptions struct { Earliest int64 Latest int64 Address string - Topics []string + Topic []string Skip int Max int } @@ -224,8 +214,8 @@ func toFilterOptions(options *FilterOptions) core.FilterOptions { opts.Earliest = options.Earliest opts.Latest = options.Latest opts.Address = fromHex(options.Address) - opts.Topics = make([][]byte, len(options.Topics)) - for i, topic := range options.Topics { + opts.Topics = make([][]byte, len(options.Topic)) + for i, topic := range options.Topic { opts.Topics[i] = fromHex(topic) } diff --git a/rpc/http/server.go b/rpc/http/server.go index caa50d67c..7dcd6b867 100644 --- a/rpc/http/server.go +++ b/rpc/http/server.go @@ -88,7 +88,7 @@ func (s *RpcHttpServer) apiHandler(api *rpc.EthereumApi) http.Handler { fn := func(w http.ResponseWriter, req *http.Request) { w.Header().Set("Access-Control-Allow-Origin", "*") - rpchttplogger.Debugln("Handling request") + rpchttplogger.DebugDetailln("Handling request") reqParsed, reqerr := JSON.ParseRequestBody(req) if reqerr != nil { diff --git a/rpc/message.go b/rpc/message.go index 054b7a578..e110bdf3e 100644 --- a/rpc/message.go +++ b/rpc/message.go @@ -205,6 +205,7 @@ func (req *RpcRequest) ToFilterArgs() (*FilterOptions, error) { if len(req.Params) < 1 { return nil, NewErrorResponse(ErrorArguments) } + fmt.Println("FILTER PARAMS", string(req.Params[0])) args := new(FilterOptions) r := bytes.NewReader(req.Params[0]) diff --git a/rpc/packages.go b/rpc/packages.go index 06de5ca38..047bbda9a 100644 --- a/rpc/packages.go +++ b/rpc/packages.go @@ -40,6 +40,11 @@ import ( "github.com/ethereum/go-ethereum/xeth" ) +const ( + defaultGasPrice = "10000000000000" + defaultGas = "10000" +) + type EthereumApi struct { xeth *xeth.XEth filterManager *filter.FilterManager @@ -70,6 +75,7 @@ func NewEthereumApi(eth *xeth.XEth) *EthereumApi { func (self *EthereumApi) NewFilter(args *FilterOptions, reply *interface{}) error { var id int filter := core.NewFilter(self.xeth.Backend()) + filter.SetOptions(toFilterOptions(args)) filter.LogsCallback = func(logs state.Logs) { self.logMut.Lock() defer self.logMut.Unlock() @@ -115,10 +121,14 @@ func (p *EthereumApi) GetBlock(args *GetBlockArgs, reply *interface{}) error { } func (p *EthereumApi) Transact(args *NewTxArgs, reply *interface{}) error { - err := args.requirements() - if err != nil { - return err + if len(args.Gas) == 0 { + args.Gas = defaultGas + } + + if len(args.GasPrice) == 0 { + args.GasPrice = defaultGasPrice } + result, _ := p.xeth.Transact( /* TODO specify account */ args.To, args.Value, args.Gas, args.GasPrice, args.Data) *reply = result return nil @@ -386,7 +396,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error } return p.FilterChanged(args, reply) case "eth_gasPrice": - *reply = "10000000000000" + *reply = defaultGasPrice return nil case "web3_sha3": args, err := req.ToSha3Args() |