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
fdb3d9b0
Unverified
Commit
fdb3d9b0
authored
Sep 10, 2019
by
kladkogex
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes
parent
bbfc9f10
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
0 deletions
+13
-0
LevelDB.cpp
LevelDB.cpp
+10
-0
LevelDB.h
LevelDB.h
+3
-0
No files found.
LevelDB.cpp
View file @
fdb3d9b0
...
...
@@ -43,6 +43,8 @@ LevelDB* levelDb = nullptr;
std
::
shared_ptr
<
std
::
string
>
LevelDB
::
readString
(
const
std
::
string
&
_key
)
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lock
(
mutex
);
auto
result
=
std
::
make_shared
<
std
::
string
>
();
if
(
db
==
nullptr
)
{
...
...
@@ -61,6 +63,8 @@ std::shared_ptr<std::string> LevelDB::readString(const std::string &_key) {
void
LevelDB
::
writeString
(
const
std
::
string
&
_key
,
const
std
::
string
&
_value
)
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lock
(
mutex
);
auto
status
=
db
->
Put
(
writeOptions
,
Slice
(
_key
),
Slice
(
_value
));
throwExceptionOnError
(
status
);
...
...
@@ -69,6 +73,8 @@ void LevelDB::writeString(const std::string &_key, const std::string &_value) {
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
);
...
...
@@ -78,6 +84,8 @@ void LevelDB::writeByteArray(const char *_key, size_t _keyLen, const char *value
void
LevelDB
::
writeByteArray
(
std
::
string
&
_key
,
const
char
*
value
,
size_t
_valueLen
)
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lock
(
mutex
);
auto
status
=
db
->
Put
(
writeOptions
,
Slice
(
_key
),
Slice
(
value
,
_valueLen
));
throwExceptionOnError
(
status
);
...
...
@@ -95,6 +103,8 @@ void LevelDB::throwExceptionOnError(Status _status) {
uint64_t
LevelDB
::
visitKeys
(
LevelDB
::
KeyVisitor
*
_visitor
,
uint64_t
_maxKeysToVisit
)
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lock
(
mutex
);
uint64_t
readCounter
=
0
;
leveldb
::
Iterator
*
it
=
db
->
NewIterator
(
readOptions
);
...
...
LevelDB.h
View file @
fdb3d9b0
...
...
@@ -27,6 +27,7 @@
#include <memory>
#include <string>
#include <mutex>
namespace
leveldb
{
class
DB
;
...
...
@@ -36,6 +37,8 @@ namespace leveldb {
class
LevelDB
{
std
::
recursive_mutex
mutex
;
leveldb
::
DB
*
db
;
public
:
...
...
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