LCOV - code coverage report
Current view: top level - irohad/consensus/yac/impl - cluster_order.cpp (source / functions) Hit Total Coverage
Test: cleared_cor.info Lines: 15 15 100.0 %
Date: 2019-03-07 14:46:43 Functions: 8 8 100.0 %

          Line data    Source code
       1             : /**
       2             :  * Copyright Soramitsu Co., Ltd. All Rights Reserved.
       3             :  * SPDX-License-Identifier: Apache-2.0
       4             :  */
       5             : 
       6             : #include "consensus/yac/cluster_order.hpp"
       7             : 
       8             : namespace iroha {
       9             :   namespace consensus {
      10             :     namespace yac {
      11             : 
      12             :       boost::optional<ClusterOrdering> ClusterOrdering::create(
      13             :           const std::vector<std::shared_ptr<shared_model::interface::Peer>>
      14             :               &order) {
      15        4138 :         if (order.empty()) {
      16           1 :           return boost::none;
      17             :         }
      18        4137 :         return ClusterOrdering(order);
      19        4138 :       }
      20             : 
      21             :       ClusterOrdering::ClusterOrdering(
      22             :           std::vector<std::shared_ptr<shared_model::interface::Peer>> order)
      23        4137 :           : order_(std::move(order)) {}
      24             : 
      25             :       // TODO :  24/03/2018 x3medima17: make it const, IR-1164
      26             :       const shared_model::interface::Peer &ClusterOrdering::currentLeader() {
      27        3590 :         if (index_ >= order_.size()) {
      28           1 :           index_ = 0;
      29           1 :         }
      30        3590 :         return *order_.at(index_);
      31             :       }
      32             : 
      33             :       bool ClusterOrdering::hasNext() const {
      34        3587 :         return index_ != order_.size();
      35             :       }
      36             : 
      37             :       ClusterOrdering &ClusterOrdering::switchToNext() {
      38        3589 :         ++index_;
      39        3589 :         return *this;
      40             :       }
      41             : 
      42             :       std::vector<std::shared_ptr<shared_model::interface::Peer>>
      43             :       ClusterOrdering::getPeers() const {
      44        7005 :         return order_;
      45             :       }
      46             : 
      47             :       size_t ClusterOrdering::getNumberOfPeers() const {
      48        6735 :         return order_.size();
      49             :       }
      50             :     }  // namespace yac
      51             :   }    // namespace consensus
      52             : }  // namespace iroha

Generated by: LCOV version 1.13