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
d522173a
Unverified
Commit
d522173a
authored
Dec 14, 2020
by
kladko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug/SKALE-3662 Adding libzmq
parent
80bf3d0c
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
190 additions
and
3 deletions
+190
-3
Makefile.am
Makefile.am
+3
-2
ServerTask.cpp
ServerTask.cpp
+64
-0
ServerTask.h
ServerTask.h
+53
-0
ServerWorker.cpp
ServerWorker.cpp
+37
-0
ServerWorker.h
ServerWorker.h
+32
-0
build_deps.py
scripts/build_deps.py
+1
-1
No files found.
Makefile.am
View file @
d522173a
...
...
@@ -49,7 +49,7 @@ AM_CFLAGS = -DUSER_SPACE -g -Og -rdynamic -Wl,--no-as-needed -lSegFault -DSGXWAL
AM_CXXFLAGS
=
${
AM_CPPFLAGS
}
-rdynamic
-Wl
,--no-as-needed
-lSegFault
-DSGXWALLET_VERSION
=
"
$(WALLET_VERSION)
"
AM_CPPFLAGS
+=
-DSGXWALLET_VERSION
=
"
$(WALLET_VERSION)
"
-Wall
-DSKALE_SGX
=
1
-DBINARY_OUTPUT
=
1
-Ileveldb
/include
-IlibBLS
/bls
-IlibBLS
/libff
-IlibBLS
-fno-builtin-memset
$(GMP_CPPFLAGS)
-I
.
-I
./libBLS/deps/deps_inst/x86_or_x64/include
AM_CPPFLAGS
+=
-DSGXWALLET_VERSION
=
"
$(WALLET_VERSION)
"
-Wall
-DSKALE_SGX
=
1
-DBINARY_OUTPUT
=
1
-Ileveldb
/include
-IlibBLS
/bls
-IlibBLS
/libff
-IlibBLS
-fno-builtin-memset
$(GMP_CPPFLAGS)
-I
.
-I
./libBLS/deps/deps_inst/x86_or_x64/include
-I
./libzmq/include
## Additional targets to remove with 'make clean'. You must list
## any edger8r generated files here.
...
...
@@ -111,7 +111,8 @@ nodist_testw_SOURCES=${nodist_sgxwallet_SOURCES}
EXTRA_testw_DEPENDENCIES
=
${
EXTRA_sgxwallet_DEPENDENCIES
}
testw_LDADD
=
${
sgxwallet_LDADD
}
cert_util_SOURCES
=
InvalidStateException.cpp Exception.cpp InvalidArgumentException.cpp Log.cpp cert_util.cpp stubclient.cpp LevelDB.cpp SGXRegistrationServer.cpp CSRManagerServer.cpp
cert_util_SOURCES
=
InvalidStateException.cpp Exception.cpp InvalidArgumentException.cpp Log.cpp cert_util.cpp stubclient.cpp LevelDB.cpp SGXRegistrationServer.cpp CSRManagerServer.cpp
\
ServerTask.cpp ServerWorker.cpp
cert_util_LDADD
=
-LlibBLS
/deps/deps_inst/x86_or_x64/lib
-Lleveldb
/build
-LlibBLS
/build
\
-LlibBLS
/build/libff/libff
\
-l
:libbls.a
-l
:libleveldb.a
\
...
...
ServerTask.cpp
0 → 100644
View file @
d522173a
/*
Copyright (C) 2019-Present SKALE Labs
This file is part of sgxwallet.
sgxwallet is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
sgxwallet is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with sgxwallet. If not, see <https://www.gnu.org/licenses/>.
@file ServerTask.cpp
@author Stan Kladko
@date 2019
*/
#include "sgxwallet.h"
#include "ServerTask.h"
ServerTask
::
ServerTask
()
:
ctx_
(
1
),
frontend_
(
ctx_
,
ZMQ_ROUTER
),
backend_
(
ctx_
,
ZMQ_DEALER
)
{}
void
ServerTask
::
run
()
{
frontend_
.
bind
(
"tcp://*:"
+
to_string
(
BASE_PORT
+
4
))
;
backend_
.
bind
(
"inproc://backend"
);
std
::
vector
<
server_worker
*
>
worker
;
std
::
vector
<
std
::
thread
*
>
worker_thread
;
for
(
int
i
=
0
;
i
<
kMaxThread
;
++
i
)
{
worker
.
push_back
(
new
server_worker
(
ctx_
,
ZMQ_DEALER
));
worker_thread
.
push_back
(
new
std
::
thread
(
std
::
bind
(
&
server_worker
::
work
,
worker
[
i
])));
worker_thread
[
i
]
->
detach
();
}
try
{
zmq
::
proxy
(
static_cast
<
void
*>
(
frontend_
),
static_cast
<
void
*>
(
backend_
),
nullptr
);
}
catch
(
std
::
exception
&
e
)
{}
for
(
int
i
=
0
;
i
<
kMaxThread
;
++
i
)
{
delete
worker
[
i
];
delete
worker_thread
[
i
];
}
}
zmq
::
context_t
ServerTask
::
ctx_
;
zmq
::
socket_t
ServerTask
::
frontend_
;
zmq
::
socket_t
ServerTask
::
backend_
;
ServerTask.h
0 → 100644
View file @
d522173a
/*
Copyright (C) 2019-Present SKALE Labs
This file is part of sgxwallet.
sgxwallet is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
sgxwallet is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with sgxwallet. If not, see <https://www.gnu.org/licenses/>.
@file ServerTask.h
@author Stan Kladko
@date 2020
*/
#ifndef SGXWALLET_SERVERTASK_H
#define SGXWALLET_SERVERTASK_H
#include <vector>
#include <thread>
#include <memory>
#include <functional>
#include <zmq.hpp>
#include "zhelpers.hpp"
class
ServerTask
{
class
ServerTask
{
public
:
ServerTask
();
enum
{
kMaxThread
=
5
};
void
run
();
private
:
zmq
::
context_t
ctx_
;
zmq
::
socket_t
frontend_
;
zmq
::
socket_t
backend_
;
};
#endif //SGXWALLET_SERVERTASK_H
ServerWorker.cpp
0 → 100644
View file @
d522173a
//
// Created by kladko on 14.12.20.
//
#include "ServerWorker.h"
ServerWorker
::
ServerWorker
(
zmq
::
context_t
&
ctx
,
int
sock_type
);
void
ServerWorker
::
work
()
{
worker_
.
connect
(
"inproc://backend"
);
try
{
while
(
true
)
{
zmq
::
message_t
identity
;
zmq
::
message_t
msg
;
zmq
::
message_t
copied_id
;
zmq
::
message_t
copied_msg
;
worker_
.
recv
(
&
identity
);
worker_
.
recv
(
&
msg
);
int
replies
=
within
(
5
);
for
(
int
reply
=
0
;
reply
<
replies
;
++
reply
)
{
s_sleep
(
within
(
1000
)
+
1
);
copied_id
.
copy
(
&
identity
);
copied_msg
.
copy
(
&
msg
);
worker_
.
send
(
copied_id
,
ZMQ_SNDMORE
);
worker_
.
send
(
copied_msg
);
}
}
}
catch
(
std
::
exception
&
e
)
{}
}
zmq
::
context_t
&
ServerWorker
::
ctx_
;
zmq
::
socket_t
ServerWorker
::
worker_
;
ServerWorker.h
0 → 100644
View file @
d522173a
//
// Created by kladko on 14.12.20.
//
#ifndef SGXWALLET_SERVERWORKER_H
#define SGXWALLET_SERVERWORKER_H
#include <vector>
#include <thread>
#include <memory>
#include <functional>
#include <zmq.hpp>
#include "zhelpers.hpp"
class
ServerWorker
{
public
:
ServerWorker
(
zmq
::
context_t
&
ctx
,
int
sock_type
);
void
work
();
private
:
zmq
::
context_t
&
ctx_
;
zmq
::
socket_t
worker_
;
};
#endif //SGXWALLET_SERVERWORKER_H
scripts/build_deps.py
View file @
d522173a
...
...
@@ -35,7 +35,7 @@ SCRIPTS_DIR = topDir + "/scripts"
GMP_DIR
=
topDir
+
"/sgx-gmp"
SGX_SDK_DIR_SSL
=
topDir
+
"/sgx-sdk-build/sgxsdk"
ZMQ_DIR
=
topDir
+
"/libzmq"
ZMQ_
_
BUILD_DIR
=
ZMQ_DIR
+
"/build"
ZMQ_BUILD_DIR
=
ZMQ_DIR
+
"/build"
LEVELDB_DIR
=
topDir
+
"/leveldb"
LEVELDB_BUILD_DIR
=
LEVELDB_DIR
+
"/build"
GMP_BUILD_DIR
=
topDir
+
"/gmp-build"
...
...
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