Added database init

parent 8346a462
...@@ -22,8 +22,11 @@ ...@@ -22,8 +22,11 @@
*/ */
#ifndef TESTW_LEVELDB_H #ifndef SGXWALLET_LEVELDB_H
#define TESTW_LEVELDB_H #define SGXWALLET_LEVELDB_H
#include <memory>
#include <string>
namespace leveldb { namespace leveldb {
class DB; class DB;
......
...@@ -65,7 +65,7 @@ bin_PROGRAMS = sgxwallet testw ...@@ -65,7 +65,7 @@ bin_PROGRAMS = sgxwallet testw
COMMON_SRC = sgx_stub.c sgx_detect_linux.c create_enclave.c oc_alloc.c COMMON_SRC = sgx_stub.c sgx_detect_linux.c create_enclave.c oc_alloc.c
COMMON_ENCLAVE_SRC = secure_enclave_u.c secure_enclave_u.h COMMON_ENCLAVE_SRC = secure_enclave_u.c secure_enclave_u.h
sgxwallet_SOURCES = sgxwallet.c SGXWalletServer.cpp BLSCrypto.cpp ServerInit.cpp BLSPrivateKeyShareSGX.cpp LevelDB.cpp $(COMMON_SRC) sgxwallet_SOURCES = sgxwallet.c SGXWalletServer.cpp BLSCrypto.cpp ServerInit.cpp LevelDB.cpp BLSPrivateKeyShareSGX.cpp LevelDB.cpp $(COMMON_SRC)
nodist_sgxwallet_SOURCES = $(COMMON_ENCLAVE_SRC) nodist_sgxwallet_SOURCES = $(COMMON_ENCLAVE_SRC)
EXTRA_sgxwallet_DEPENDENCIES = secure_enclave.signed.so EXTRA_sgxwallet_DEPENDENCIES = secure_enclave.signed.so
...@@ -90,7 +90,7 @@ secure_enclave.signed.so: secure_enclave/secure_enclave.signed.so ...@@ -90,7 +90,7 @@ secure_enclave.signed.so: secure_enclave/secure_enclave.signed.so
sgxwallet_LDADD=-l$(SGX_URTS_LIB) -Lleveldb/build -LlibBLS/build -LlibBLS/build/libff/libff -l:libbls.a -l:libleveldb.a -l:libff.a -lgmp -ldl -l:libsgx_capable.a -l:libsgx_tprotected_fs.a -ljsonrpccpp-stub -lpthread -ljsonrpccpp-common -ljsonrpccpp-server -ljsoncpp -lprocps sgxwallet_LDADD=-l$(SGX_URTS_LIB) -Lleveldb/build -LlibBLS/build -LlibBLS/build/libff/libff -l:libbls.a -l:libleveldb.a -l:libff.a -lgmp -ldl -l:libsgx_capable.a -l:libsgx_tprotected_fs.a -ljsonrpccpp-stub -lpthread -ljsonrpccpp-common -ljsonrpccpp-server -ljsoncpp -lprocps
testw_SOURCES=testw.cpp SGXWalletServer.cpp BLSCrypto.cpp ServerInit.cpp BLSPrivateKeyShareSGX.cpp $(COMMON_SRC) testw_SOURCES=testw.cpp SGXWalletServer.cpp BLSCrypto.cpp ServerInit.cpp LevelDB.cpp BLSPrivateKeyShareSGX.cpp $(COMMON_SRC)
nodist_testw_SOURCES=${nodist_sgxwallet_SOURCES} nodist_testw_SOURCES=${nodist_sgxwallet_SOURCES}
EXTRA_testw_DEPENDENCIES=${EXTRA_sgxwallet_DEPENDENCIES} EXTRA_testw_DEPENDENCIES=${EXTRA_sgxwallet_DEPENDENCIES}
testw_LDADD= ${sgxwallet_LDADD} testw_LDADD= ${sgxwallet_LDADD}
\ No newline at end of file
...@@ -20,10 +20,16 @@ ...@@ -20,10 +20,16 @@
#include "SGXWalletServer.h" #include "SGXWalletServer.h"
#include "LevelDB.h"
using namespace jsonrpc; using namespace jsonrpc;
using namespace std; using namespace std;
class SGXWalletServer : public AbstractStubServer { class SGXWalletServer : public AbstractStubServer {
public: public:
SGXWalletServer(AbstractServerConnector &connector, serverVersion_t type); SGXWalletServer(AbstractServerConnector &connector, serverVersion_t type);
......
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
#include "sgxwallet.h" #include "sgxwallet.h"
#include "LevelDB.h"
#include "SGXWalletServer.h" #include "SGXWalletServer.h"
#include "BLSCrypto.h" #include "BLSCrypto.h"
...@@ -30,16 +32,18 @@ ...@@ -30,16 +32,18 @@
LevelDB* levelDb = nullptr;
void init_daemon() { void init_daemon() {
libff::init_alt_bn128_params(); libff::init_alt_bn128_params();
// Set up database connection information and open database static std::string dbName("./sgxwalletdb");
leveldb::DB* db;
leveldb::Options options;
options.create_if_missing = true;
leveldb::Status status = leveldb::DB::Open(options, "./keysdb", &db); levelDb = new LevelDB(dbName);
} }
......
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