diff --git a/irohad/common/config.hpp b/irohad/common/config.hpp index 728b500dd5..a0a95b722f 100644 --- a/irohad/common/config.hpp +++ b/irohad/common/config.hpp @@ -30,44 +30,19 @@ namespace common { class ConfigLoader { public: - ConfigLoader(const std::string& file); + ConfigLoader(const std::string &file); - int getIntOrDefault(const std::string& key, int def); - std::string getStringOrDefault(const std::string& key, const std::string& def); - bool getBoolOrDefault(const std::string& key, bool def); + int getIntOrDefault(const std::string &key, int def); - // template - // T getValueOrDefault(const std::string& key, T&& def) { - // const auto& val = doc[key.c_str()]; - // if (!(doc.IsObject() && doc.HasMember(key.c_str()))) { - // goto end; - // } + std::string getStringOrDefault(const std::string &key, + const std::string &def); - // if (std::is_same::value && val.IsInt()) { - // // quite dirty hack for pleasing the compiler - // // maybe that switch(type){..} possible - // // to make compile-time - // auto v = val.GetInt(); - // return *((T*)(&v)); - // } - - // if (std::is_same::value && val.IsString()) { - // auto v = val.GetString(); - // return *((T*)(&v)); - // } - - // if (std::is_same::value && val.IsBool()) { - // auto v = val.GetBool(); - // return *((T*)(&v)); - // } - // end: - // return def; - // } + bool getBoolOrDefault(const std::string &key, bool def); private: Document doc; }; - }; -}; // namespace common + } // namespace config +} // namespace common #endif // __COMMON_CONFIG_HPP_ diff --git a/irohad/consensus/yac/storage/impl/yac_proposal_storage.cpp b/irohad/consensus/yac/storage/impl/yac_proposal_storage.cpp index 12030a5e85..6237c6cf61 100644 --- a/irohad/consensus/yac/storage/impl/yac_proposal_storage.cpp +++ b/irohad/consensus/yac/storage/impl/yac_proposal_storage.cpp @@ -123,7 +123,7 @@ namespace iroha { BlockHash block_hash) { // find exist - for (auto i = 0; i < block_votes_.size(); ++i) { + for (uint32_t i = 0; i < block_votes_.size(); ++i) { if (block_votes_.at(i).getProposalHash() == proposal_hash and block_votes_.at(i).getBlockHash() == block_hash) { return i; diff --git a/irohad/consensus/yac/yac.hpp b/irohad/consensus/yac/yac.hpp index cd9563754f..244a3b0837 100644 --- a/irohad/consensus/yac/yac.hpp +++ b/irohad/consensus/yac/yac.hpp @@ -96,15 +96,16 @@ namespace iroha { void propagateRejectDirectly(model::Peer to, RejectMessage msg); // ------|Fields|------ - rxcpp::subjects::subject notifier_; + YacVoteStorage vote_storage_; std::shared_ptr network_; std::shared_ptr crypto_; std::shared_ptr timer_; - YacVoteStorage vote_storage_; + rxcpp::subjects::subject notifier_; // ------|One round|------ ClusterOrdering cluster_order_; + // ------|Constants|------ const uint64_t delay_; }; diff --git a/irohad/consensus/yac/yac_hash_provider.hpp b/irohad/consensus/yac/yac_hash_provider.hpp index 94f4a8a900..7b89b95637 100644 --- a/irohad/consensus/yac/yac_hash_provider.hpp +++ b/irohad/consensus/yac/yac_hash_provider.hpp @@ -53,7 +53,7 @@ namespace iroha { bool operator!=(const YacHash &obj) const { return !this->operator==(obj); - } + }; }; /** diff --git a/irohad/network/peer_communication_stub.cpp b/irohad/network/peer_communication_stub.cpp index 74d8e9e7f0..12440aa009 100644 --- a/irohad/network/peer_communication_stub.cpp +++ b/irohad/network/peer_communication_stub.cpp @@ -31,6 +31,7 @@ namespace iroha { rxcpp::observable > PeerCommunicationServiceStub::on_commit() { + return consensus_.on_commit(); } rxcpp::observable diff --git a/irohad/peer_service/connection_to.cpp b/irohad/peer_service/connection_to.cpp index 4bef666c6f..772fe25919 100644 --- a/irohad/peer_service/connection_to.cpp +++ b/irohad/peer_service/connection_to.cpp @@ -81,7 +81,7 @@ namespace peerservice { Heartbeat answer; status = stub_->RequestHeartbeat(&context, *request, &answer); - printf("[my ledger is %d] ping %s... ", request->height(), + printf("[my ledger is %lu] ping %s... ", request->height(), context.peer().c_str()); // TODO: validate heartbeat messages diff --git a/irohad/validation/impl/stateless_validator_impl.cpp b/irohad/validation/impl/stateless_validator_impl.cpp index d83f70088b..f0f368dfdd 100644 --- a/irohad/validation/impl/stateless_validator_impl.cpp +++ b/irohad/validation/impl/stateless_validator_impl.cpp @@ -21,56 +21,48 @@ namespace iroha { namespace validation { StatelessValidatorImpl::StatelessValidatorImpl( - model::ModelCryptoProvider& crypto_provider) + model::ModelCryptoProvider &crypto_provider) : crypto_provider_(crypto_provider) {} bool StatelessValidatorImpl::validate( - const model::Transaction& transaction) const { + const model::Transaction &transaction) const { // signatures are correct { if (!crypto_provider_.verify(transaction)) return false; } // time between creation and validation of tx - std::chrono::milliseconds now = + uint64_t now = static_cast( std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch()); - { - if (now.count() - transaction.created_ts > MAX_DELAY) { - return false; - } + std::chrono::system_clock::now().time_since_epoch()).count()); + + if (now - transaction.created_ts > MAX_DELAY) { + return false; } // tx is not sent from future - { - if (now.count() < transaction.created_ts) { - return false; - } + if (now < transaction.created_ts) { + return false; } return true; } - bool StatelessValidatorImpl::validate(const model::Query& query) const { + bool StatelessValidatorImpl::validate(const model::Query &query) const { // signatures are correct - { - if (!crypto_provider_.verify(query)) return false; - } + if (!crypto_provider_.verify(query)) return false; // time between creation and validation of the query - std::chrono::milliseconds now = + uint64_t now = static_cast( std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch()); - { - if (now.count() - query.created_ts > MAX_DELAY) { - return false; - } + std::chrono::system_clock::now().time_since_epoch()).count()); + + if (now - query.created_ts > MAX_DELAY) { + return false; } // query is not sent from future - { - if (now.count() < query.created_ts) { - return false; - } + if (now < query.created_ts) { + return false; } return true; }