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
66238465
Unverified
Commit
66238465
authored
Dec 14, 2020
by
Oleh Nikolaiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-3023 fix format
parent
027d5067
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
9 deletions
+23
-9
LevelDB.cpp
LevelDB.cpp
+4
-5
LevelDB.h
LevelDB.h
+1
-1
SGXInfoServer.cpp
SGXInfoServer.cpp
+3
-1
sgx_util.cpp
sgx_util.cpp
+15
-2
No files found.
LevelDB.cpp
View file @
66238465
...
@@ -171,8 +171,8 @@ void LevelDB::writeDataUnique(const string & name, const string &value) {
...
@@ -171,8 +171,8 @@ void LevelDB::writeDataUnique(const string & name, const string &value) {
writeString
(
key
,
value
);
writeString
(
key
,
value
);
}
}
stringstream
LevelDB
::
getAllKeys
()
{
pair
<
stringstream
,
uint64_t
>
LevelDB
::
getAllKeys
()
{
stringstream
result
;
stringstream
keysInfo
;
leveldb
::
Iterator
*
it
=
db
->
NewIterator
(
readOptions
);
leveldb
::
Iterator
*
it
=
db
->
NewIterator
(
readOptions
);
uint64_t
counter
=
0
;
uint64_t
counter
=
0
;
...
@@ -192,11 +192,10 @@ stringstream LevelDB::getAllKeys() {
...
@@ -192,11 +192,10 @@ stringstream LevelDB::getAllKeys() {
// old style keys
// old style keys
value
=
" VALUE: "
+
it
->
value
().
ToString
();
value
=
" VALUE: "
+
it
->
value
().
ToString
();
}
}
result
<<
"KEY: "
<<
key
<<
','
<<
value
;
keysInfo
<<
"KEY: "
<<
key
<<
','
<<
value
;
}
}
result
<<
"TOTAL NUMBER OF KEYS: "
<<
counter
;
return
result
;
return
{
std
::
move
(
keysInfo
),
counter
}
;
}
}
pair
<
string
,
uint64_t
>
LevelDB
::
getLatestCreatedKey
()
{
pair
<
string
,
uint64_t
>
LevelDB
::
getLatestCreatedKey
()
{
...
...
LevelDB.h
View file @
66238465
...
@@ -71,7 +71,7 @@ public:
...
@@ -71,7 +71,7 @@ public:
shared_ptr
<
string
>
readNewStyleValue
(
const
string
&
value
);
shared_ptr
<
string
>
readNewStyleValue
(
const
string
&
value
);
stringstream
getAllKeys
();
pair
<
stringstream
,
uint64_t
>
getAllKeys
();
pair
<
string
,
uint64_t
>
getLatestCreatedKey
();
pair
<
string
,
uint64_t
>
getLatestCreatedKey
();
...
...
SGXInfoServer.cpp
View file @
66238465
...
@@ -56,7 +56,9 @@ Json::Value SGXInfoServer::getAllKeysInfo() {
...
@@ -56,7 +56,9 @@ Json::Value SGXInfoServer::getAllKeysInfo() {
Json
::
Value
result
;
Json
::
Value
result
;
try
{
try
{
result
[
"allKeys"
]
=
LevelDB
::
getLevelDb
()
->
getAllKeys
().
str
();
auto
allKeysInfo
=
LevelDB
::
getLevelDb
()
->
getAllKeys
();
result
[
"allKeys"
]
=
allKeysInfo
.
first
.
str
();
result
[
"keysNumber"
]
=
std
::
to_string
(
allKeysInfo
.
second
);
}
HANDLE_SGX_EXCEPTION
(
result
)
}
HANDLE_SGX_EXCEPTION
(
result
)
RETURN_SUCCESS
(
result
)
RETURN_SUCCESS
(
result
)
...
...
sgx_util.cpp
View file @
66238465
...
@@ -45,11 +45,20 @@ void sign_by_hash(std::string & hash, int status){
...
@@ -45,11 +45,20 @@ void sign_by_hash(std::string & hash, int status){
exit
(
0
);
exit
(
0
);
}
}
void
getNumberOfKeysCreated
()
{
jsonrpc
::
HttpClient
client
(
"http://localhost:1030"
);
StubClient
c
(
client
,
jsonrpc
::
JSONRPC_CLIENT_V2
);
std
::
cout
<<
"Info client inited"
<<
std
::
endl
;
std
::
cout
<<
c
.
getAllKeysInfo
()[
"keysNumber"
].
asString
()
<<
std
::
endl
;
exit
(
0
);
}
void
getAllKeysInfo
()
{
void
getAllKeysInfo
()
{
jsonrpc
::
HttpClient
client
(
"http://localhost:1030"
);
jsonrpc
::
HttpClient
client
(
"http://localhost:1030"
);
StubClient
c
(
client
,
jsonrpc
::
JSONRPC_CLIENT_V2
);
StubClient
c
(
client
,
jsonrpc
::
JSONRPC_CLIENT_V2
);
std
::
cout
<<
"Info client inited"
<<
std
::
endl
;
std
::
cout
<<
"Info client inited"
<<
std
::
endl
;
std
::
cout
<<
c
.
getAllKeysInfo
()[
"allKeys"
].
asString
().
c_str
()
<<
std
::
endl
;
std
::
cout
<<
c
.
getAllKeysInfo
()[
"allKeys"
].
asString
()
<<
std
::
endl
;
std
::
cout
<<
"TOTAL KEYS IN DATABASE: "
<<
c
.
getAllKeysInfo
()[
"keysNumber"
].
asString
()
<<
std
::
endl
;
exit
(
0
);
exit
(
0
);
}
}
...
@@ -126,6 +135,7 @@ int main(int argc, char *argv[]) {
...
@@ -126,6 +135,7 @@ int main(int argc, char *argv[]) {
std
::
cout
<<
" -r [hash] reject csr by hash"
<<
std
::
endl
;
std
::
cout
<<
" -r [hash] reject csr by hash"
<<
std
::
endl
;
std
::
cout
<<
" -a print all keys"
<<
std
::
endl
;
std
::
cout
<<
" -a print all keys"
<<
std
::
endl
;
std
::
cout
<<
" -l print latest created key"
<<
std
::
endl
;
std
::
cout
<<
" -l print latest created key"
<<
std
::
endl
;
std
::
cout
<<
" -n print number of keys stored in database"
<<
std
::
endl
;
std
::
cout
<<
" -c print server's config"
<<
std
::
endl
;
std
::
cout
<<
" -c print server's config"
<<
std
::
endl
;
std
::
cout
<<
" -i [name] check if key with such name presents in database"
<<
std
::
endl
;
std
::
cout
<<
" -i [name] check if key with such name presents in database"
<<
std
::
endl
;
exit
(
0
);
exit
(
0
);
...
@@ -133,7 +143,7 @@ int main(int argc, char *argv[]) {
...
@@ -133,7 +143,7 @@ int main(int argc, char *argv[]) {
std
::
string
hash
;
std
::
string
hash
;
std
::
string
key
;
std
::
string
key
;
while
((
opt
=
getopt
(
argc
,
argv
,
"ps:r:alci:"
))
!=
-
1
)
{
while
((
opt
=
getopt
(
argc
,
argv
,
"ps:r:alci:
n
"
))
!=
-
1
)
{
switch
(
opt
)
{
switch
(
opt
)
{
case
'p'
:
print_hashes
();
case
'p'
:
print_hashes
();
break
;
break
;
...
@@ -155,6 +165,9 @@ int main(int argc, char *argv[]) {
...
@@ -155,6 +165,9 @@ int main(int argc, char *argv[]) {
case
'i'
:
key
=
optarg
;
case
'i'
:
key
=
optarg
;
isKeyExists
(
key
);
isKeyExists
(
key
);
break
;
break
;
case
'n'
:
getNumberOfKeysCreated
();
break
;
case
'?'
:
// fprintf(stderr, "unknown flag\n");
case
'?'
:
// fprintf(stderr, "unknown flag\n");
exit
(
1
);
exit
(
1
);
}
}
...
...
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