Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sgxwallet
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
董子豪
sgxwallet
Commits
ea74ba94
Unverified
Commit
ea74ba94
authored
Aug 13, 2020
by
kladko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-3067-cleanup-sgx
parent
b000e648
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
33 deletions
+9
-33
LevelDB.cpp
LevelDB.cpp
+8
-31
SGXWalletServer.hpp
SGXWalletServer.hpp
+1
-2
No files found.
LevelDB.cpp
View file @
ea74ba94
...
...
@@ -43,15 +43,10 @@ static WriteOptions writeOptions;
static
ReadOptions
readOptions
;
std
::
shared_ptr
<
string
>
LevelDB
::
readString
(
const
string
&
_key
)
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lock
(
mutex
);
auto
result
=
std
::
make_shared
<
string
>
();
if
(
db
==
nullptr
)
{
throw
SGXException
(
NULL_DATABASE
,
"Null db"
);
}
spdlog
::
debug
(
"key to read from db: {}"
,
_key
);
CHECK_STATE
(
db
)
auto
status
=
db
->
Get
(
readOptions
,
_key
,
result
.
get
());
...
...
@@ -65,18 +60,14 @@ std::shared_ptr<string> LevelDB::readString(const string &_key) {
}
void
LevelDB
::
writeString
(
const
string
&
_key
,
const
string
&
_value
)
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lock
(
mutex
);
auto
status
=
db
->
Put
(
writeOptions
,
Slice
(
_key
),
Slice
(
_value
));
throwExceptionOnError
(
status
);
spdlog
::
debug
(
"written key: {}"
,
_key
);
}
void
LevelDB
::
deleteDHDKGKey
(
const
string
&
_key
)
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lock
(
mutex
);
string
full_key
=
"DKG_DH_KEY_"
+
_key
;
...
...
@@ -84,48 +75,31 @@ void LevelDB::deleteDHDKGKey(const string &_key) {
throwExceptionOnError
(
status
);
spdlog
::
debug
(
"key deleted: {}"
,
full_key
);
}
void
LevelDB
::
deleteTempNEK
(
const
string
&
_key
)
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lock
(
mutex
);
string
prefix
=
_key
.
substr
(
0
,
8
);
if
(
prefix
!=
"tmp_NEK:"
)
{
return
;
}
CHECK_STATE
(
_key
.
rfind
(
"tmp_NEK"
,
0
)
==
0
);
auto
status
=
db
->
Delete
(
writeOptions
,
Slice
(
_key
));
throwExceptionOnError
(
status
);
spdlog
::
debug
(
"key deleted: {}"
,
_key
);
}
void
LevelDB
::
deleteKey
(
const
string
&
_key
)
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lock
(
mutex
);
auto
status
=
db
->
Delete
(
writeOptions
,
Slice
(
_key
));
throwExceptionOnError
(
status
);
spdlog
::
debug
(
"key deleted: {}"
,
_key
);
}
void
LevelDB
::
writeByteArray
(
const
char
*
_key
,
size_t
_keyLen
,
const
char
*
value
,
size_t
_valueLen
)
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lock
(
mutex
);
auto
status
=
db
->
Put
(
writeOptions
,
Slice
(
_key
,
_keyLen
),
Slice
(
value
,
_valueLen
));
throwExceptionOnError
(
status
);
}
void
LevelDB
::
writeByteArray
(
string
&
_key
,
const
char
*
value
,
size_t
_valueLen
)
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lock
(
mutex
);
CHECK_STATE
(
value
);
auto
status
=
db
->
Put
(
writeOptions
,
Slice
(
_key
),
Slice
(
value
,
_valueLen
));
...
...
@@ -142,6 +116,9 @@ void LevelDB::throwExceptionOnError(Status _status) {
}
uint64_t
LevelDB
::
visitKeys
(
LevelDB
::
KeyVisitor
*
_visitor
,
uint64_t
_maxKeysToVisit
)
{
CHECK_STATE
(
_visitor
);
uint64_t
readCounter
=
0
;
leveldb
::
Iterator
*
it
=
db
->
NewIterator
(
readOptions
);
...
...
@@ -187,7 +164,7 @@ void LevelDB::writeDataUnique(const string & Name, const string &value) {
writeString
(
key
,
value
);
spdlog
::
debug
(
"{}"
,
Name
,
" is written to db"
);
}
...
...
SGXWalletServer.hpp
View file @
ea74ba94
...
...
@@ -24,10 +24,9 @@
#ifndef SGXWALLET_SGXWALLETSERVER_HPP
#define SGXWALLET_SGXWALLETSERVER_HPP
#include <boost/thread/shared_mutex.hpp>
#include <jsonrpccpp/server/connectors/httpserver.h>
#include <mutex>
#include "abstractstubserver.h"
using
namespace
jsonrpc
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment