Skip to content

Commit

Permalink
Fix codacy issues:
Browse files Browse the repository at this point in the history
- Explicit constructors
- Field initialization
  • Loading branch information
grimadas committed Aug 6, 2017
1 parent 93eee65 commit edbf1e8
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 24 deletions.
35 changes: 19 additions & 16 deletions irohad/main/genesis_block_server/genesis_block_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
#ifndef IROHA_GENESIS_BLOCK_SERVICE_HPP
#define IROHA_GENESIS_BLOCK_SERVICE_HPP

#include <model/block.hpp>
#include <grpc++/grpc++.h>
#include <endpoint.grpc.pb.h>
#include <grpc++/grpc++.h>
#include <model/block.hpp>
#include "genesis_block_processor.hpp"

namespace iroha {
Expand All @@ -29,24 +29,26 @@ namespace iroha {

class GenesisBlockServerRunner;

class GenesisBlockService final : public iroha::protocol::GenesisBlockService::Service {
public:
GenesisBlockService(GenesisBlockProcessor &processor, GenesisBlockServerRunner* server_runner)
: processor_(processor), server_runner_(server_runner)
{}
class GenesisBlockService final
: public iroha::protocol::GenesisBlockService::Service {
public:
GenesisBlockService(GenesisBlockProcessor &processor,
GenesisBlockServerRunner *server_runner)
: processor_(processor), server_runner_(server_runner) {}

grpc::Status SendGenesisBlock(
grpc::ServerContext *context, const iroha::protocol::Block *request,
iroha::protocol::ApplyGenesisBlockResponse *response) override;

grpc::Status SendGenesisBlock(grpc::ServerContext* context,
const iroha::protocol::Block* request,
iroha::protocol::ApplyGenesisBlockResponse* response) override;
private:
private:
GenesisBlockProcessor &processor_;
GenesisBlockServerRunner *server_runner_;
};

class GenesisBlockServerRunner {
public:
GenesisBlockServerRunner(iroha::GenesisBlockProcessor &processor)
: processor_(processor) {}
public:
explicit GenesisBlockServerRunner(iroha::GenesisBlockProcessor &processor)
: processor_(processor) {}
/**
* runs genesis block server
* @param ip
Expand All @@ -58,11 +60,12 @@ namespace iroha {
* shuts down server if received genesis block.
*/
void shutdown();
private:

private:
iroha::GenesisBlockProcessor &processor_;
std::unique_ptr<grpc::Server> server_;
};

}
} // namespace iroha

#endif // IROHA_GENESIS_BLOCK_SERVICE_HPP
5 changes: 2 additions & 3 deletions irohad/main/server_runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ limitations under the License.
#include <logger/logger.hpp>
#include <main/server_runner.hpp>


ServerRunner::ServerRunner(const std::string &address)
: serverAddress_(address) {}

Expand All @@ -47,13 +46,13 @@ void ServerRunner::run(std::unique_ptr<torii::CommandService> command_service,
void ServerRunner::shutdown() {
serverInstance_->Shutdown();

while (!toriiServiceHandler_->isShutdownCompletionQueue()) {
while (not toriiServiceHandler_->isShutdownCompletionQueue()) {
usleep(1); // wait for shutting down completion queue
}
toriiServiceHandler_->shutdown();
}

void ServerRunner::waitForServersReady() {
std::unique_lock<std::mutex> lock(waitForServer_);
while (!serverInstance_) serverInstanceCV_.wait(lock);
serverInstanceCV_.wait(lock, [this] { return serverInstance_; });
}
7 changes: 4 additions & 3 deletions irohad/model/proposal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ namespace iroha {
* Proposal has no signatures and other meta information.
*/
struct Proposal {
explicit Proposal(std::vector<Transaction> txs) : transactions(txs) {}
explicit Proposal(std::vector<Transaction> txs)
: transactions(txs), height(0) {}

/**
* Bunch of transactions provided by ordering service.
Expand All @@ -43,7 +44,7 @@ namespace iroha {
*/
uint64_t height;
};
}
}
} // namespace model
} // namespace iroha

#endif // IROHA_PROPOSAL_HPP
4 changes: 2 additions & 2 deletions test/framework/test_subscriber.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ namespace framework {
* @param expected_number_of_calls - number of calls
* that required for call
*/
CallExact(uint64_t expected_number_of_calls)
explicit CallExact(uint64_t expected_number_of_calls)
: expected_number_of_calls_(expected_number_of_calls) {}

CallExact(CallExact<T> &&rhs) {
Expand Down Expand Up @@ -187,5 +187,5 @@ namespace framework {
};

} // namespace test_subscriber
} // namespace common
} // namespace framework
#endif // IROHA_TEST_SUBSCRIBER_HPP

0 comments on commit edbf1e8

Please sign in to comment.