Skip to content

Commit

Permalink
Yac: recreate channel and stub on each send
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Lebedev <[email protected]>
  • Loading branch information
lebdron committed Sep 20, 2019
1 parent 5e6766a commit 3dae58e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions irohad/consensus/yac/transport/impl/network_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
#include "logger/logger.hpp"
#include "yac.pb.h"

namespace {
const std::chrono::seconds kSendStateTimeout{5};
} // namespace

namespace iroha {
namespace consensus {
namespace yac {
Expand Down Expand Up @@ -46,6 +50,9 @@ namespace iroha {
}

async_call_->Call([&](auto context, auto cq) {
// set a timeout to avoid being hung
context->set_deadline(std::chrono::system_clock::now()
+ kSendStateTimeout);
return peers_.at(to.address())->AsyncSendState(context, request, cq);
});

Expand Down Expand Up @@ -86,9 +93,7 @@ namespace iroha {

void NetworkImpl::createPeerConnection(
const shared_model::interface::Peer &peer) {
if (peers_.count(peer.address()) == 0) {
peers_[peer.address()] = client_creator_(peer);
}
peers_[peer.address()] = client_creator_(peer);
}

} // namespace yac
Expand Down

0 comments on commit 3dae58e

Please sign in to comment.