Unverified Commit 9dc52fc1 authored by Oleh's avatar Oleh

remove locks

parent 12550f53
......@@ -106,12 +106,10 @@ Json::Value signByHashImpl(const string &hash, int status) {
}
Json::Value CSRManagerServer::getUnsignedCSRs() {
LOCK(m)
return getUnsignedCSRsImpl();
}
Json::Value CSRManagerServer::signByHash(const string &hash, int status) {
LOCK(m)
return signByHashImpl(hash, status);
}
......
......@@ -41,7 +41,6 @@
#include "common.h"
#include <mutex> // For std::unique_lock
#include <shared_mutex>
using namespace std;
......@@ -78,9 +77,5 @@ public:
#define HANDLE_SGX_EXCEPTION(_RESULT_) catch (SGXException &__e) { Log::handleSGXException(_RESULT_, __e);} \
catch (exception &__e) {spdlog::error(__e.what()); _RESULT_["status"] = 1; _RESULT_["errorMessage"] = __e.what();}
#define READ_LOCK(__M__) ReadLock __rlock(__M__);
#define WRITE_LOCK(__M__) WriteLock __wlock(__M__);
#define LOCK(__M__) lock_guard<recursive_mutex> lock(__M__);
#endif
......@@ -153,13 +153,11 @@ Json::Value getCertificateImpl(const string &hash) {
Json::Value SGXRegistrationServer::SignCertificate(const string &csr) {
spdlog::info(__FUNCTION__);
LOCK(m)
return signCertificateImpl(csr, autoSign);
}
Json::Value SGXRegistrationServer::GetCertificate(const string &hash) {
spdlog::info(__FUNCTION__);
LOCK(m)
return getCertificateImpl(hash);
}
......
......@@ -674,17 +674,14 @@ Json::Value SGXWalletServer::deleteBlsKeyImpl(const std::string& name) {
}
Json::Value SGXWalletServer::generateDKGPoly(const string &_polyName, int _t) {
WRITE_LOCK(m)
return generateDKGPolyImpl(_polyName, _t);
}
Json::Value SGXWalletServer::getVerificationVector(const string &_polynomeName, int _t, int _n) {
WRITE_LOCK(m)
return getVerificationVectorImpl(_polynomeName, _t, _n);
}
Json::Value SGXWalletServer::getSecretShare(const string &_polyName, const Json::Value &_publicKeys, int t, int n) {
WRITE_LOCK(m)
return getSecretShareImpl(_polyName, _publicKeys, t, n);
}
......@@ -692,39 +689,32 @@ Json::Value
SGXWalletServer::dkgVerification(const string &_publicShares, const string &ethKeyName, const string &SecretShare,
int t,
int n, int index) {
WRITE_LOCK(m)
return dkgVerificationImpl(_publicShares, ethKeyName, SecretShare, t, n, index);
}
Json::Value
SGXWalletServer::createBLSPrivateKey(const string &blsKeyName, const string &ethKeyName, const string &polyName,
const string &SecretShare, int t, int n) {
WRITE_LOCK(m)
return createBLSPrivateKeyImpl(blsKeyName, ethKeyName, polyName, SecretShare, t, n);
}
Json::Value SGXWalletServer::getBLSPublicKeyShare(const string &blsKeyName) {
READ_LOCK(m)
return getBLSPublicKeyShareImpl(blsKeyName);
}
Json::Value SGXWalletServer::generateECDSAKey() {
WRITE_LOCK(m)
return generateECDSAKeyImpl();
}
Json::Value SGXWalletServer::renameECDSAKey(const string &_keyName, const string &_tmpKeyName) {
WRITE_LOCK(m)
return renameECDSAKeyImpl(_keyName, _tmpKeyName);
}
Json::Value SGXWalletServer::getPublicECDSAKey(const string &_keyName) {
READ_LOCK(m)
return getPublicECDSAKeyImpl(_keyName);
}
Json::Value SGXWalletServer::ecdsaSignMessageHash(int _base, const string &_keyShareName, const string &_messageHash) {
READ_LOCK(m)
spdlog::debug("MessageHash first {}", _messageHash);
return ecdsaSignMessageHashImpl(_base, _keyShareName, _messageHash);
}
......@@ -732,48 +722,39 @@ Json::Value SGXWalletServer::ecdsaSignMessageHash(int _base, const string &_keyS
Json::Value
SGXWalletServer::importBLSKeyShare(const string &_keyShare, const string &_keyShareName, int _t, int _n,
int index) {
WRITE_LOCK(m)
return importBLSKeyShareImpl(_keyShare, _keyShareName, _t, _n, index);
}
Json::Value SGXWalletServer::blsSignMessageHash(const string &_keyShareName, const string &_messageHash, int _t, int _n,
int _signerIndex) {
READ_LOCK(m)
return blsSignMessageHashImpl(_keyShareName, _messageHash, _t, _n, _signerIndex);
}
Json::Value SGXWalletServer::importECDSAKey(const string &_key, const string &_keyName) {
WRITE_LOCK(m)
return importECDSAKeyImpl(_key, _keyName);
}
Json::Value SGXWalletServer::complaintResponse(const string &polyName, int ind) {
WRITE_LOCK(m)
return complaintResponseImpl(polyName, ind);
}
Json::Value SGXWalletServer::multG2(const string &x) {
WRITE_LOCK(m)
return multG2Impl(x);
}
Json::Value SGXWalletServer::isPolyExists(const string &polyName) {
WRITE_LOCK(m)
return isPolyExistsImpl(polyName);
}
Json::Value SGXWalletServer::getServerStatus() {
READ_LOCK(m)
return getServerStatusImpl();
}
Json::Value SGXWalletServer::getServerVersion() {
READ_LOCK(m)
return getServerVersionImpl();
}
Json::Value SGXWalletServer::deleteBlsKey(const std::string& name) {
READ_LOCK(m)
return deleteBlsKeyImpl(name);
}
......
......@@ -24,13 +24,8 @@
#ifndef SGXWALLET_SGXWALLETSERVER_HPP
#define SGXWALLET_SGXWALLETSERVER_HPP
#include <boost/thread/locks.hpp>
#include <boost/thread/shared_mutex.hpp>
typedef boost::shared_mutex Lock;
typedef boost::unique_lock< Lock > WriteLock;
typedef boost::shared_lock< Lock > ReadLock;
#include <jsonrpccpp/server/connectors/httpserver.h>
#include <mutex>
#include "abstractstubserver.h"
......@@ -42,8 +37,6 @@ using namespace std;
#define TOSTRING(x) STRINGIFY(x)
class SGXWalletServer : public AbstractStubServer {
Lock m;
static shared_ptr<SGXWalletServer> server;
static shared_ptr<HttpServer> httpServer;
public:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment