aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/api.go
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-03-27 16:36:18 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-03-27 16:36:18 +0800
commite29396b6915a27d3e44be45fe9e540c6ef39f1dd (patch)
tree079f5dc51816ae63ea2e7b5547d5b24e798aaf04 /rpc/api.go
parentb0b0939879b9fb8453ec1c8fa2ceb522e56df3bc (diff)
downloaddexon-e29396b6915a27d3e44be45fe9e540c6ef39f1dd.tar
dexon-e29396b6915a27d3e44be45fe9e540c6ef39f1dd.tar.gz
dexon-e29396b6915a27d3e44be45fe9e540c6ef39f1dd.tar.bz2
dexon-e29396b6915a27d3e44be45fe9e540c6ef39f1dd.tar.lz
dexon-e29396b6915a27d3e44be45fe9e540c6ef39f1dd.tar.xz
dexon-e29396b6915a27d3e44be45fe9e540c6ef39f1dd.tar.zst
dexon-e29396b6915a27d3e44be45fe9e540c6ef39f1dd.zip
Use ExtraDB for 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()