aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/api.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-03-27 18:48:03 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-03-27 18:48:03 +0800
commit54a14d5c9d7d1e5039753eac991cd057a5514fe8 (patch)
tree322f74746ac7a2ddfea0e5fbb42383f46d5aad15 /rpc/api.go
parent09280c5f11993ee64ce231433270345c7e253ee3 (diff)
parente29396b6915a27d3e44be45fe9e540c6ef39f1dd (diff)
downloaddexon-54a14d5c9d7d1e5039753eac991cd057a5514fe8.tar
dexon-54a14d5c9d7d1e5039753eac991cd057a5514fe8.tar.gz
dexon-54a14d5c9d7d1e5039753eac991cd057a5514fe8.tar.bz2
dexon-54a14d5c9d7d1e5039753eac991cd057a5514fe8.tar.lz
dexon-54a14d5c9d7d1e5039753eac991cd057a5514fe8.tar.xz
dexon-54a14d5c9d7d1e5039753eac991cd057a5514fe8.tar.zst
dexon-54a14d5c9d7d1e5039753eac991cd057a5514fe8.zip
Merge pull request #584 from tgerring/issue577
Use ExtraDB for RPC storage. Fixes #577
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 aa5b54199..f2915f658 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)
@@ -370,7 +358,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)
@@ -382,7 +371,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)
@@ -394,7 +383,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)
@@ -406,7 +395,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()