aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/api.go
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-03-27 23:03:49 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-03-27 23:03:49 +0800
commit0ac346f7078dba597d60f991c32ddbfd7be167ba (patch)
tree33a690fa6ef7cbc8584ff2a1f40f85b28b42ac7f /rpc/api.go
parent9f84c78eb5cceb5f413fbdeafe63786f1b958e83 (diff)
parenteb102bf4bb0bff773824ff467fbb2e49c1f6939b (diff)
downloadgo-tangerine-0ac346f7078dba597d60f991c32ddbfd7be167ba.tar.gz
go-tangerine-0ac346f7078dba597d60f991c32ddbfd7be167ba.tar.zst
go-tangerine-0ac346f7078dba597d60f991c32ddbfd7be167ba.zip
Merge branch 'develop' into rpcargs
Diffstat (limited to 'rpc/api.go')
-rw-r--r--rpc/api.go23
1 files changed, 6 insertions, 17 deletions
diff --git a/rpc/api.go b/rpc/api.go
index 534b6fc5d..f755f07bd 100644
--- a/rpc/api.go
+++ b/rpc/api.go
@@ -3,13 +3,11 @@ package rpc
import (
"encoding/json"
"math/big"
- "path"
"sync"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/xeth"
)
@@ -19,15 +17,9 @@ type EthereumApi struct {
db common.Database
}
-func NewEthereumApi(xeth *xeth.XEth, dataDir string) *EthereumApi {
- // What about when dataDir is empty?
- db, err := ethdb.NewLDBDatabase(path.Join(dataDir, "dapps"))
- if err != nil {
- panic(err)
- }
+func NewEthereumApi(xeth *xeth.XEth) *EthereumApi {
api := &EthereumApi{
eth: xeth,
- db: db,
}
return api
@@ -44,10 +36,6 @@ func (api *EthereumApi) xethAtStateNum(num int64) *xeth.XEth {
return api.xeth().AtStateNum(num)
}
-func (api *EthereumApi) Close() {
- api.db.Close()
-}
-
func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error {
// Spec at https://github.com/ethereum/wiki/wiki/JSON-RPC
rpclogger.Debugf("%s %s", req.Method, req.Params)
@@ -343,7 +331,8 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
return err
}
- api.db.Put([]byte(args.Database+args.Key), args.Value)
+ api.xeth().DbPut([]byte(args.Database+args.Key), args.Value)
+
*reply = true
case "db_getString":
args := new(DbArgs)
@@ -355,7 +344,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
return err
}
- res, _ := api.db.Get([]byte(args.Database + args.Key))
+ res, _ := api.xeth().DbGet([]byte(args.Database + args.Key))
*reply = string(res)
case "db_putHex":
args := new(DbHexArgs)
@@ -367,7 +356,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
return err
}
- api.db.Put([]byte(args.Database+args.Key), args.Value)
+ api.xeth().DbPut([]byte(args.Database+args.Key), args.Value)
*reply = true
case "db_getHex":
args := new(DbHexArgs)
@@ -379,7 +368,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
return err
}
- res, _ := api.db.Get([]byte(args.Database + args.Key))
+ res, _ := api.xeth().DbGet([]byte(args.Database + args.Key))
*reply = common.ToHex(res)
case "shh_version":
*reply = api.xeth().WhisperVersion()