Commit ff6d89b6 authored by Felipe Andrade's avatar Felipe Andrade

nits

parent 71230f36
......@@ -103,9 +103,6 @@ func (c *cacheWithCompression) Put(ctx context.Context, key string, value string
return c.cache.Put(ctx, key, string(encodedVal))
}
type GetLatestBlockNumFn func(ctx context.Context) (uint64, error)
type GetLatestGasPriceFn func(ctx context.Context) (uint64, error)
type RPCCache interface {
GetRPC(ctx context.Context, req *RPCReq) (*RPCRes, error)
PutRPC(ctx context.Context, req *RPCReq, res *RPCRes) error
......@@ -117,16 +114,17 @@ type rpcCache struct {
}
func newRPCCache(cache Cache) RPCCache {
staticHandler := &StaticMethodHandler{cache: cache}
handlers := map[string]RPCMethodHandler{
"eth_chainId": &StaticMethodHandler{cache: cache},
"net_version": &StaticMethodHandler{cache: cache},
"eth_getBlockTransactionCountByHash": &StaticMethodHandler{cache: cache},
"eth_getUncleCountByBlockHash": &StaticMethodHandler{cache: cache},
"eth_getBlockByHash": &StaticMethodHandler{cache: cache},
"eth_getTransactionByHash": &StaticMethodHandler{cache: cache},
"eth_getTransactionByBlockHashAndIndex": &StaticMethodHandler{cache: cache},
"eth_getUncleByBlockHashAndIndex": &StaticMethodHandler{cache: cache},
"eth_getTransactionReceipt": &StaticMethodHandler{cache: cache},
"eth_chainId": staticHandler,
"net_version": staticHandler,
"eth_getBlockTransactionCountByHash": staticHandler,
"eth_getUncleCountByBlockHash": staticHandler,
"eth_getBlockByHash": staticHandler,
"eth_getTransactionByHash": staticHandler,
"eth_getTransactionByBlockHashAndIndex": staticHandler,
"eth_getUncleByBlockHashAndIndex": staticHandler,
"eth_getTransactionReceipt": staticHandler,
}
return &rpcCache{
cache: cache,
......@@ -149,7 +147,7 @@ func (c *rpcCache) GetRPC(ctx context.Context, req *RPCReq) (*RPCRes, error) {
} else {
RecordCacheHit(req.Method)
}
return res, err
return res, nil
}
func (c *rpcCache) PutRPC(ctx context.Context, req *RPCReq, res *RPCRes) error {
......
......@@ -67,7 +67,7 @@ func (e *StaticMethodHandler) PutRPCMethod(ctx context.Context, req *RPCReq, res
err := e.cache.Put(ctx, key, string(value))
if err != nil {
log.Error("error marshalling value to put into cache", "key", key, "method", req.Method, "err", err)
log.Error("error putting into cache", "key", key, "method", req.Method, "err", err)
return err
}
return nil
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment