Skip to content

Commit c515124

Browse files
author
Alexander Avramenko
committed
Fix always-break-connection issue in executor service
1 parent a7f4a35 commit c515124

2 files changed

Lines changed: 5 additions & 7 deletions

File tree

api/include/apihandler.hpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ public slots:
470470
});
471471
}
472472

473-
static const int kReconnectTime = 5;
473+
static const int kReconnectTime = 2;
474474
std::this_thread::sleep_for(std::chrono::seconds(kReconnectTime));
475475

476476
if (!isConnect()) {
@@ -523,10 +523,6 @@ public slots:
523523

524524
bool connect() {
525525
try {
526-
if (executorTransport_->isOpen()) {
527-
executorTransport_->close();
528-
}
529-
530526
executorTransport_->open();
531527
}
532528
catch (...) {

api/src/apihandler.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2220,9 +2220,10 @@ namespace executor {
22202220

22212221
void Executor::executeByteCodeMultiple(ExecuteByteCodeMultipleResult& _return, const ::general::Address& initiatorAddress, const SmartContractBinary& invokedContract,
22222222
const std::string& method, const std::vector<std::vector<::general::Variant>>& params, const int64_t executionTime, cs::Sequence sequence) {
2223-
if (!connect()) {
2223+
if (!isConnect()) {
22242224
_return.status.code = 1;
22252225
_return.status.message = "No executor connection!";
2226+
notifyError();
22262227
return;
22272228
}
22282229
const auto access_id = generateAccessId(sequence);
@@ -2584,7 +2585,8 @@ namespace executor {
25842585
const SmartContractBinary& smartContractBinary, std::vector<MethodHeader>& methodHeader, bool isGetter, cs::Sequence explicit_sequence) {
25852586
constexpr uint64_t EXECUTION_TIME = Consensus::T_smart_contract;
25862587
OriginExecuteResult originExecuteRes{};
2587-
if (!connect()) {
2588+
if (!isConnect()) {
2589+
notifyError();
25882590
return std::nullopt;
25892591
}
25902592

0 commit comments

Comments
 (0)