Skip to content

Commit

Permalink
Separate definition and declaration of ordering init class
Browse files Browse the repository at this point in the history
  • Loading branch information
muratovv committed Aug 4, 2017
1 parent fb54299 commit 4e96445
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 13 deletions.
27 changes: 27 additions & 0 deletions irohad/main/impl/ordering_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,30 @@

#include "main/impl/ordering_init.hpp"

namespace iroha {
namespace network {
auto OrderingInit::createGate(std::string network_address) {
return std::make_shared<ordering::OrderingGateImpl>(network_address);
}

auto OrderingInit::createService(std::vector<model::Peer> peers,
size_t max_size,
size_t delay_milliseconds,
std::shared_ptr<uvw::Loop> loop) {

return std::make_shared<ordering::OrderingServiceImpl>(peers,
max_size,
delay_milliseconds,
loop);
}

std::shared_ptr<ordering::OrderingGateImpl> OrderingInit::initOrderingGate(
std::vector<model::Peer> peers, std::shared_ptr<uvw::Loop> loop,
size_t max_size, size_t delay_milliseconds) {
ordering_service =
createService(peers, max_size, delay_milliseconds, loop);
ordering_gate = createGate(peers.front().address);
return ordering_gate;
}
} // namespace network
} // namespace iroha
41 changes: 28 additions & 13 deletions irohad/main/impl/ordering_init.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,43 @@

namespace iroha {
namespace network {

/**
* Class aimed to effective initialization of OrderingGate component
*/
class OrderingInit {
private:
auto createGate(std::string network_address) {
return std::make_shared<ordering::OrderingGateImpl>(network_address);
}

/**
* Init effective realisation of ordering gate (client of ordering service)
* @param network_address - address of ordering service
*/
auto createGate(std::string network_address);

/**
* Init ordering service
* @param peers - endpoints of peers for connection
* @param max_size - limitation of proposal size
* @param delay_milliseconds - delay before emitting proposal
* @param loop - handler of async events
*/
auto createService(std::vector<model::Peer> peers, size_t max_size,
size_t delay_milliseconds,
std::shared_ptr<uvw::Loop> loop) {
return std::make_shared<ordering::OrderingServiceImpl>(
peers, max_size, delay_milliseconds, loop);
}
std::shared_ptr<uvw::Loop> loop);

public:

/**
* Initialization of ordering gate(client) and ordering service (service)
* @param peers - endpoints of peers for connection
* @param loop - handler of async events
* @param max_size - limitation of proposal size
* @param delay_milliseconds - delay before emitting proposal
* @return effective realisation of OrderingGate
*/
std::shared_ptr<ordering::OrderingGateImpl> initOrderingGate(
std::vector<model::Peer> peers, std::shared_ptr<uvw::Loop> loop,
size_t max_size, size_t delay_milliseconds) {
ordering_service =
createService(peers, max_size, delay_milliseconds, loop);
ordering_gate = createGate(peers.front().address);
return ordering_gate;
}
size_t max_size, size_t delay_milliseconds);

std::shared_ptr<ordering::OrderingServiceImpl> ordering_service;
std::shared_ptr<ordering::OrderingGateImpl> ordering_gate;
Expand Down

0 comments on commit 4e96445

Please sign in to comment.