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
b0303b5c
Unverified
Commit
b0303b5c
authored
May 07, 2020
by
kladko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed docs
parent
5e9c346d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
29 deletions
+33
-29
CSRManagerServer.cpp
CSRManagerServer.cpp
+20
-26
CSRManagerServer.h
CSRManagerServer.h
+13
-3
No files found.
CSRManagerServer.cpp
View file @
b0303b5c
...
...
@@ -22,21 +22,26 @@
*/
#include "CSRManagerServer.h"
#include "SGXException.h"
#include "sgxwallet_common.h"
#include <iostream>
#include <fstream>
#include <jsonrpccpp/server/connectors/httpserver.h>
#include "spdlog/spdlog.h"
#include "CSRManagerServer.h"
#include "SGXException.h"
#include "sgxwallet_common.h"
#include "Log.h"
#include "common.h"
CSRManagerServer
*
cs
=
nullptr
;
jsonrpc
::
HttpServer
*
hs3
=
nullptr
;
shared_ptr
<
CSRManagerServer
>
CSRManagerServer
::
cs
=
nullptr
;
shared_ptr
<
jsonrpc
::
HttpServer
>
CSRManagerServer
::
hs3
=
nullptr
;
CSRManagerServer
::
CSRManagerServer
(
AbstractServerConnector
&
connector
,
...
...
@@ -44,22 +49,15 @@ CSRManagerServer::CSRManagerServer(AbstractServerConnector &connector,
Json
::
Value
getUnsignedCSRsImpl
()
{
spdlog
::
info
(
"Enter getUnsignedCSRsImpl"
);
Json
::
Value
result
;
result
[
"status"
]
=
0
;
result
[
"errorMessage"
]
=
""
;
spdlog
::
info
(
__FUNCTION__
);
INIT_RESULT
(
result
)
try
{
vector
<
string
>
hashes_vect
=
LevelDB
::
getCsrDb
()
->
writeKeysToVector1
(
MAX_CSR_NUM
);
for
(
int
i
=
0
;
i
<
(
int
)
hashes_vect
.
size
();
i
++
)
{
result
[
"hashes"
][
i
]
=
hashes_vect
.
at
(
i
);
}
}
catch
(
SGXException
&
_e
)
{
cerr
<<
" err str "
<<
_e
.
errString
<<
endl
;
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
}
}
HANDLE_SGX_EXCEPTION
(
result
);
return
result
;
}
...
...
@@ -111,30 +109,26 @@ Json::Value signByHashImpl(const string &hash, int status) {
result
[
"status"
]
=
status
;
}
catch
(
SGXException
&
_e
)
{
cerr
<<
" err str "
<<
_e
.
errString
<<
endl
;
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
}
}
HANDLE_SGX_EXCEPTION
(
result
)
return
result
;
}
Json
::
Value
CSRManagerServer
::
getUnsignedCSRs
()
{
lock_guard
<
recursive_mutex
>
lock
(
m
);
LOCK
(
m
)
return
getUnsignedCSRsImpl
();
}
Json
::
Value
CSRManagerServer
::
signByHash
(
const
string
&
hash
,
int
status
)
{
lock_guard
<
recursive_mutex
>
lock
(
m
);
LOCK
(
m
)
return
signByHashImpl
(
hash
,
status
);
}
int
CSRManagerServer
::
initCSRManagerServer
()
{
hs3
=
new
jsonrpc
::
HttpServer
(
BASE_PORT
+
2
);
hs3
=
make_shared
<
jsonrpc
::
HttpServer
>
(
BASE_PORT
+
2
);
hs3
->
BindLocalhost
();
cs
=
new
CSRManagerServer
(
*
hs3
,
JSONRPC_SERVER_V2
);
// server (json-rpc 2.0)
cs
=
make_shared
<
CSRManagerServer
>
(
*
hs3
,
JSONRPC_SERVER_V2
);
// server (json-rpc 2.0)
if
(
!
cs
->
StartListening
())
{
spdlog
::
info
(
"CSR manager server could not start listening"
);
...
...
CSRManagerServer.h
View file @
b0303b5c
...
...
@@ -25,23 +25,33 @@
#ifndef SGXD_CSRMANAGERSERVER_H
#define SGXD_CSRMANAGERSERVER_H
#include <mutex>
#include <jsonrpccpp/server/connectors/httpserver.h>
#include "abstractCSRManagerServer.h"
#include "LevelDB.h"
#include <mutex>
using
namespace
jsonrpc
;
using
namespace
std
;
class
CSRManagerServer
:
public
abstractCSRManagerServer
{
std
::
recursive_mutex
m
;
recursive_mutex
m
;
static
shared_ptr
<
HttpServer
>
hs3
;
static
shared_ptr
<
CSRManagerServer
>
cs
;
public
:
CSRManagerServer
(
AbstractServerConnector
&
connector
,
serverVersion_t
type
);
virtual
Json
::
Value
getUnsignedCSRs
();
virtual
Json
::
Value
signByHash
(
const
st
d
::
st
ring
&
hash
,
int
status
);
virtual
Json
::
Value
signByHash
(
const
string
&
hash
,
int
status
);
static
int
initCSRManagerServer
();
};
...
...
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