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
3a73a043
Unverified
Commit
3a73a043
authored
Jan 28, 2021
by
kladko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug/SKALE-3751-enable-zeromq
parent
dbf340bd
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
15 deletions
+45
-15
SGXWalletServer.cpp
SGXWalletServer.cpp
+0
-1
ZMQClient.cpp
ZMQClient.cpp
+15
-1
ZMQClient.h
ZMQClient.h
+6
-1
ZMQServer.cpp
ZMQServer.cpp
+15
-8
ZMQServer.h
ZMQServer.h
+5
-2
testw.cpp
testw.cpp
+4
-2
No files found.
SGXWalletServer.cpp
View file @
3a73a043
...
...
@@ -173,7 +173,6 @@ int SGXWalletServer::initHttpsServer(bool _checkCerts) {
exit
(
-
12
);
}
httpServer
=
make_shared
<
HttpServer
>
(
BASE_PORT
,
certPath
,
keyPath
,
rootCAPath
,
_checkCerts
,
NUM_THREADS
);
...
...
ZMQClient.cpp
View file @
3a73a043
...
...
@@ -116,7 +116,21 @@ string ZMQClient::doZmqRequestReply(string &_req) {
}
ZMQClient
::
ZMQClient
(
string
&
ip
,
uint16_t
port
)
:
ctx
(
1
)
{
ZMQClient
::
ZMQClient
(
const
string
&
ip
,
uint16_t
port
,
bool
_sign
,
const
string
&
_certFileName
,
const
string
&
_certKeyName
)
:
ctx
(
1
)
{
if
(
_sign
)
{
CHECK_STATE
(
!
_certFileName
.
empty
());
CHECK_STATE
(
!
_certKeyName
.
empty
());
}
else
{
CHECK_STATE
(
_certFileName
.
empty
());
CHECK_STATE
(
_certKeyName
.
empty
());
}
certFileName
=
_certFileName
;
certKeyName
=
_certKeyName
;
url
=
"tcp://"
+
ip
+
":"
+
to_string
(
port
);
}
...
...
ZMQClient.h
View file @
3a73a043
...
...
@@ -45,6 +45,9 @@ class ZMQClient {
private
:
bool
sign
;
string
certFileName
;
string
certKeyName
;
recursive_mutex
mutex
;
...
...
@@ -66,7 +69,9 @@ private:
public
:
ZMQClient
(
string
&
ip
,
uint16_t
port
);
ZMQClient
(
const
string
&
ip
,
uint16_t
port
,
bool
_sign
,
const
string
&
_certPathName
,
const
string
&
_certKeyName
);
void
reconnect
()
;
string
blsSignMessageHash
(
const
std
::
string
&
keyShareName
,
const
std
::
string
&
messageHash
,
int
t
,
int
n
);
...
...
ZMQServer.cpp
View file @
3a73a043
...
...
@@ -34,11 +34,15 @@ using namespace std;
ZMQServer
*
ZMQServer
::
zmqServer
=
nullptr
;
ZMQServer
::
ZMQServer
()
:
isExitRequested
(
false
),
ctx_
(
make_shared
<
zmq
::
context_t
>
(
1
)),
ZMQServer
::
ZMQServer
(
bool
_checkSignature
,
const
string
&
_caCertFile
)
:
checkSignature
(
_checkSignature
),
caCertFile
(
_caCertFile
),
isExitRequested
(
false
),
ctx_
(
make_shared
<
zmq
::
context_t
>
(
1
)),
frontend_
(
*
ctx_
,
ZMQ_ROUTER
),
backend_
(
*
ctx_
,
ZMQ_DEALER
)
{
if
(
_checkSignature
)
{
CHECK_STATE
(
!
_caCertFile
.
empty
());
}
int
linger
=
0
;
zmq_setsockopt
(
frontend_
,
ZMQ_LINGER
,
&
linger
,
sizeof
(
linger
));
...
...
@@ -151,23 +155,26 @@ void ZMQServer::exitZMQServer() {
zmqServer
=
nullptr
;
}
void
ZMQServer
::
initZMQServer
(
bool
_
useClientCert
)
{
void
ZMQServer
::
initZMQServer
(
bool
_
checkSignature
)
{
static
bool
initedServer
=
false
;
CHECK_STATE
(
!
initedServer
)
initedServer
=
true
;
spdlog
::
info
(
"Initing zmq server ..."
);
zmqServer
=
new
ZMQServer
();
serverThread
=
make_shared
<
thread
>
(
std
::
bind
(
&
ZMQServer
::
run
,
ZMQServer
::
zmqServer
));
string
rootCAPath
=
""
;
serverThread
->
detach
();
if
(
_useClientCert
)
{
if
(
_checkSignature
)
{
string
rootCAPath
=
string
(
SGXDATA_FOLDER
)
+
"cert_data/rootCA.pem"
;
CHECK_STATE
(
access
(
rootCAPath
.
c_str
(),
F_OK
)
==
0
);
};
zmqServer
=
new
ZMQServer
(
_checkSignature
,
rootCAPath
);
serverThread
=
make_shared
<
thread
>
(
std
::
bind
(
&
ZMQServer
::
run
,
ZMQServer
::
zmqServer
));
serverThread
->
detach
();
spdlog
::
info
(
"Inited zmq server ..."
);
}
...
...
ZMQServer.h
View file @
3a73a043
...
...
@@ -44,11 +44,14 @@ using namespace std;
class
ZMQServer
{
public
:
bool
checkSignature
=
false
;
string
caCertFile
=
""
;
static
ZMQServer
*
zmqServer
;
static
shared_ptr
<
std
::
thread
>
serverThread
;
ZMQServer
();
ZMQServer
(
bool
_checkSignature
,
const
string
&
_caCertFile
);
enum
{
kMaxThread
=
1
...
...
@@ -58,7 +61,7 @@ public:
void
exitWorkers
();
static
void
initZMQServer
(
bool
_
useClientCert
);
static
void
initZMQServer
(
bool
_
checkSignature
);
static
void
exitZMQServer
();
...
...
testw.cpp
View file @
3a73a043
...
...
@@ -492,7 +492,9 @@ TEST_CASE_METHOD(TestFixture, "DKG_BLS ZMQ test", "[dkgblszmq]") {
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
string
ip
=
ZMQ_IP
;
auto
zmqClient
=
make_shared
<
ZMQClient
>
(
ip
,
ZMQ_PORT
);
string
empty
=
""
;
auto
zmqClient
=
make_shared
<
ZMQClient
>
(
ip
,
ZMQ_PORT
,
false
,
empty
,
empty
);
vector
<
string
>
ecdsaKeyNames
;
vector
<
string
>
blsKeyNames
;
...
...
@@ -935,7 +937,7 @@ TEST_CASE_METHOD(TestFixture, "ZMQ-ecdsa", "[zmq-ecdsa]") {
string
ip
=
ZMQ_IP
;
auto
client
=
make_shared
<
ZMQClient
>
(
ip
,
ZMQ_PORT
);
auto
client
=
make_shared
<
ZMQClient
>
(
ip
,
ZMQ_PORT
,
false
,
""
,
""
);
string
keyName
=
""
;
...
...
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