aboutsummaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
Diffstat (limited to 'rpc')
-rw-r--r--rpc/api.go20
-rw-r--r--rpc/args.go7
-rw-r--r--rpc/args_test.go28
3 files changed, 49 insertions, 6 deletions
diff --git a/rpc/api.go b/rpc/api.go
index d00b86ac0..4f86e703d 100644
--- a/rpc/api.go
+++ b/rpc/api.go
@@ -86,7 +86,7 @@ func (self *EthereumApi) getStateWithNum(num int64) *xeth.State {
}
func (self *EthereumApi) start() {
- timer := time.NewTicker(filterTickerTime)
+ timer := time.NewTicker(2 * time.Second)
done:
for {
select {
@@ -94,20 +94,20 @@ done:
self.logMut.Lock()
self.messagesMut.Lock()
for id, filter := range self.logs {
- if time.Since(filter.timeout) > 20*time.Second {
+ if time.Since(filter.timeout) > filterTickerTime {
self.filterManager.UninstallFilter(id)
delete(self.logs, id)
}
}
for id, filter := range self.messages {
- if time.Since(filter.timeout) > 20*time.Second {
+ if time.Since(filter.timeout) > filterTickerTime {
self.xeth().Whisper().Unwatch(id)
delete(self.messages, id)
}
}
- self.logMut.Unlock()
self.messagesMut.Unlock()
+ self.logMut.Unlock()
case <-self.quit:
break done
}
@@ -180,10 +180,13 @@ func (self *EthereumApi) NewFilterString(args *FilterStringArgs, reply *interfac
var id int
filter := core.NewFilter(self.xeth().Backend())
- callback := func(block *types.Block) {
+ callback := func(block *types.Block, logs state.Logs) {
self.logMut.Lock()
defer self.logMut.Unlock()
+ for _, log := range logs {
+ self.logs[id].add(log)
+ }
self.logs[id].add(&state.StateLog{})
}
@@ -257,6 +260,11 @@ func (p *EthereumApi) Transact(args *NewTxArgs, reply *interface{}) (err error)
p.register[ags.From] = append(p.register[args.From], args)
}
*/
+
+ if err := args.requirements(); err != nil {
+ return err
+ }
+
// TODO: align default values to have the same type, e.g. not depend on
// common.Value conversions later on
if args.Gas.Cmp(big.NewInt(0)) == 0 {
@@ -478,7 +486,7 @@ func (p *EthereumApi) GetBlockUncleCountByNumber(blocknum int64) (int64, error)
func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error {
// Spec at https://github.com/ethereum/wiki/wiki/Generic-JSON-RPC
- rpclogger.Debugf("%s %s", req.Method, req.Params)
+ rpclogger.Infof("%s %s", req.Method, req.Params)
switch req.Method {
case "web3_sha3":
args := new(Sha3Args)
diff --git a/rpc/args.go b/rpc/args.go
index 992ea1eed..ab1c40585 100644
--- a/rpc/args.go
+++ b/rpc/args.go
@@ -145,6 +145,13 @@ func (args *NewTxArgs) UnmarshalJSON(b []byte) (err error) {
return nil
}
+func (args *NewTxArgs) requirements() error {
+ if len(args.From) == 0 {
+ return NewValidationError("From", "Is required")
+ }
+ return nil
+}
+
type GetStorageArgs struct {
Address string
BlockNumber int64
diff --git a/rpc/args_test.go b/rpc/args_test.go
index 872c535fa..0d8dc4085 100644
--- a/rpc/args_test.go
+++ b/rpc/args_test.go
@@ -219,6 +219,34 @@ func TestNewTxArgsEmpty(t *testing.T) {
}
}
+func TestNewTxArgsReqs(t *testing.T) {
+ args := new(NewTxArgs)
+ args.From = "0xb60e8dd61c5d32be8058bb8eb970870f07233155"
+
+ err := args.requirements()
+ switch err.(type) {
+ case nil:
+ break
+ default:
+ t.Errorf("Get %T", err)
+ }
+}
+
+func TestNewTxArgsReqsFromBlank(t *testing.T) {
+ args := new(NewTxArgs)
+ args.From = ""
+
+ err := args.requirements()
+ switch err.(type) {
+ case nil:
+ t.Error("Expected error but didn't get one")
+ case *ValidationError:
+ break
+ default:
+ t.Error("Wrong type of error")
+ }
+}
+
func TestGetStorageArgs(t *testing.T) {
input := `["0x407d73d8a49eeb85d32cf465507dd71d507100c1", "latest"]`
expected := new(GetStorageArgs)