Skip to content

Commit

Permalink
Optimize the network broadcasting
Browse files Browse the repository at this point in the history
  • Loading branch information
ubicorn authored Jun 12, 2020
1 parent 1e7b341 commit ffcedd6
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions API/Api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -883,8 +883,9 @@ std::string Api::readPassport(std::string json) {
x509Vector
);
if(txPool.appendTransaction(registerPassportTxForNetwork, BROADCAST_TRANSACTION, &transactionError)) {
Network &network = Network::Instance();
network.broadCastTransaction(registerPassportTxForNetwork);
std::thread t1(&Network::broadCastTransaction, registerPassportTxForNetwork);
t1.detach();

return "{\"success\": true}";
} else {
char response[1024];
Expand Down Expand Up @@ -1215,8 +1216,8 @@ std::string Api::pay(std::string json) {
TxPool &txPool = TxPool::Instance();
TransactionError transactionError;
if (txPool.appendTransaction(txForNetwork, BROADCAST_TRANSACTION, &transactionError)) {
Network &network = Network::Instance();
network.broadCastTransaction(txForNetwork);
std::thread t1(&Network::broadCastTransaction, txForNetwork);
t1.detach();

return "{\"success\": true}";
} else {
Expand Down Expand Up @@ -1827,17 +1828,17 @@ std::string Api::sendTransaction(std::string json) {
txForNetwork.setTransaction(tx);
} catch (const std::exception& e2) {
Log(LOG_LEVEL_ERROR) << "Cannot deserialize base64 encoded transaction";
Log(LOG_LEVEL_ERROR) << "Exception: " << e2.what();
Log(LOG_LEVEL_ERROR) << "Exception1: " << e.what();
Log(LOG_LEVEL_ERROR) << "Exception2: " << e2.what();
return "{\"success\": false, \"error\":\"Cannot deserialize base64 encoded transaction\"}";
}
}

TxPool &txPool = TxPool::Instance();
TransactionError transactionError;
if (txPool.appendTransaction(txForNetwork, BROADCAST_TRANSACTION, &transactionError)) {

Network &network = Network::Instance();
network.broadCastTransaction(txForNetwork);
std::thread t1(&Network::broadCastTransaction, txForNetwork);
t1.detach();

return "{\"success\": true}";
} else {
Expand Down

0 comments on commit ffcedd6

Please sign in to comment.