Skip to content

Commit

Permalink
Merge branch 'feature/iroha-main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
lebdron committed Aug 4, 2017
2 parents 0769acb + 93f043d commit 25b6074
Show file tree
Hide file tree
Showing 78 changed files with 1,318 additions and 683 deletions.
9 changes: 6 additions & 3 deletions iroha-cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
// https://hackmd.io/GwRmwQ2BmCFoCsAGARtOAWBIBMcAcS0GcAZjhNNPvpAKZIDGQA==

DEFINE_string(config, "", "Trusted peer's ip addresses");
DEFINE_validator(config, &iroha_cli::validate_config);
//DEFINE_validator(config, &iroha_cli::validate_config);

DEFINE_string(genesis_block, "", "Genesis block for sending network");
DEFINE_validator(genesis_block, &iroha_cli::validate_genesis_block);
//DEFINE_validator(genesis_block, &iroha_cli::validate_genesis_block);

DEFINE_bool(new_account, false, "Choose if account does not exist");
DEFINE_string(name, "", "Name of the account");
Expand Down Expand Up @@ -74,7 +74,10 @@ int main(int argc, char* argv[]) {
std::cout << "Send transaction to " << FLAGS_address << ":"
<< FLAGS_torii_port << std::endl;
iroha_cli::CliClient client(FLAGS_address, FLAGS_torii_port);
auto status = client.sendTx(FLAGS_json_transaction);
std::ifstream file(FLAGS_json_transaction);
std::string str((std::istreambuf_iterator<char>(file)),
std::istreambuf_iterator<char>());
auto status = client.sendTx(str);
switch (status) {
case iroha_cli::CliClient::OK:
std::cout << "Transaction successfully sent" << std::endl;
Expand Down
54 changes: 0 additions & 54 deletions irohad/common/context.h

This file was deleted.

16 changes: 10 additions & 6 deletions irohad/consensus/yac/impl/network_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ namespace iroha {

void NetworkImpl::send_commit(model::Peer to, CommitMessage commit) {
std::cout << output("send_commit " + to.address + " " +
commit.votes.at(0).hash.block_hash)
bytestringToHexstring(
commit.votes.at(0).hash.block_hash))
<< std::endl;

proto::Commit request;
Expand Down Expand Up @@ -71,7 +72,8 @@ namespace iroha {

void NetworkImpl::send_reject(model::Peer to, RejectMessage reject) {
std::cout << output("send_reject " + to.address + " " +
reject.votes.at(0).hash.block_hash)
bytestringToHexstring(
reject.votes.at(0).hash.block_hash))
<< std::endl;

proto::Reject request;
Expand Down Expand Up @@ -99,7 +101,7 @@ namespace iroha {

void NetworkImpl::send_vote(model::Peer to, VoteMessage vote) {
std::cout << output("send_vote " + to.address + " " +
vote.hash.block_hash)
bytestringToHexstring(vote.hash.block_hash))
<< std::endl;

proto::Vote request;
Expand Down Expand Up @@ -144,7 +146,7 @@ namespace iroha {
vote.signature.pubkey.begin());

std::cout << input("SendVote " + peer.address + " " +
vote.hash.block_hash)
bytestringToHexstring(vote.hash.block_hash))
<< std::endl;

handler_.lock()->on_vote(peer, vote);
Expand Down Expand Up @@ -177,7 +179,8 @@ namespace iroha {
}

std::cout << input("SendCommit " + peer.address + " " +
commit.votes.at(0).hash.block_hash)
bytestringToHexstring(
commit.votes.at(0).hash.block_hash))
<< std::endl;

handler_.lock()->on_commit(peer, commit);
Expand Down Expand Up @@ -210,7 +213,8 @@ namespace iroha {
}

std::cout << input("SendReject " + peer.address + " " +
reject.votes.at(0).hash.block_hash)
bytestringToHexstring(
reject.votes.at(0).hash.block_hash))
<< std::endl;

handler_.lock()->on_reject(peer, reject);
Expand Down
6 changes: 2 additions & 4 deletions irohad/consensus/yac/impl/peer_orderer_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ namespace iroha {
namespace yac {

PeerOrdererImpl::PeerOrdererImpl(
std::shared_ptr<ametsuchi::WsvQuery> query,
std::shared_ptr<YacHashProvider> hash_provider)
: query_(std::move(query)),
hash_provider_(std::move(hash_provider)) {}
std::shared_ptr<ametsuchi::WsvQuery> query)
: query_(std::move(query)) {}

nonstd::optional<ClusterOrdering> PeerOrdererImpl::getInitialOrdering() {
auto peers = query_->getPeers();
Expand Down
3 changes: 1 addition & 2 deletions irohad/consensus/yac/impl/peer_orderer_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ namespace iroha {

class PeerOrdererImpl : public YacPeerOrderer {
public:
explicit PeerOrdererImpl(std::shared_ptr<ametsuchi::WsvQuery> query,
std::shared_ptr<YacHashProvider> hash_provider);
explicit PeerOrdererImpl(std::shared_ptr<ametsuchi::WsvQuery> query);

nonstd::optional<ClusterOrdering> getInitialOrdering() override;

Expand Down
8 changes: 6 additions & 2 deletions irohad/consensus/yac/impl/yac_gate_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ namespace iroha {
namespace yac {

YacGateImpl::YacGateImpl(
std::unique_ptr<HashGate> hash_gate,
std::unique_ptr<YacPeerOrderer> orderer,
std::shared_ptr<HashGate> hash_gate,
std::shared_ptr<YacPeerOrderer> orderer,
std::shared_ptr<YacHashProvider> hash_provider,
std::shared_ptr<simulator::BlockCreator> block_creator)
: hash_gate_(std::move(hash_gate)),
Expand All @@ -49,6 +49,10 @@ namespace iroha {
rxcpp::observable<model::Block> YacGateImpl::on_commit() {
return hash_gate_->on_commit().map([this](auto commit_message) {
if (commit_message.votes.at(0).hash == current_block_.first) {
current_block_.second.sigs.clear();
for (auto &&vote : commit_message.votes) {
current_block_.second.sigs.push_back(vote.signature);
}
return current_block_.second;
}

Expand Down
8 changes: 4 additions & 4 deletions irohad/consensus/yac/impl/yac_gate_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ namespace iroha {

class YacGateImpl : public YacGate {
public:
YacGateImpl(std::unique_ptr<HashGate> hash_gate,
std::unique_ptr<YacPeerOrderer> orderer,
YacGateImpl(std::shared_ptr<HashGate> hash_gate,
std::shared_ptr<YacPeerOrderer> orderer,
std::shared_ptr<YacHashProvider> hash_provider,
std::shared_ptr<simulator::BlockCreator> block_creator);
void vote(model::Block block) override;
rxcpp::observable<model::Block> on_commit() override;

private:
std::unique_ptr<HashGate> hash_gate_;
std::unique_ptr<YacPeerOrderer> orderer_;
std::shared_ptr<HashGate> hash_gate_;
std::shared_ptr<YacPeerOrderer> orderer_;
std::shared_ptr<YacHashProvider> hash_provider_;
std::shared_ptr<simulator::BlockCreator> block_creator_;

Expand Down
81 changes: 46 additions & 35 deletions irohad/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,48 +12,59 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)

add_library(server_runner server_runner.cpp)
target_link_libraries(server_runner
torii_service
logger
endpoint
schema
)
torii_service
logger
endpoint
schema
)

add_library(genesis_block_server
genesis_block_server/genesis_block_server.cpp
genesis_block_server/genesis_block_processor.cpp
impl/raw_block_insertion.cpp
)
genesis_block_server/genesis_block_server.cpp
genesis_block_server/genesis_block_processor.cpp
impl/raw_block_insertion.cpp
)
target_link_libraries(genesis_block_server
ametsuchi
model
timer
endpoint
optional
logger
)
ametsuchi
model
timer
endpoint
optional
logger
)

add_library(application application.cpp)
add_library(application
application.cpp
impl/ordering_init.cpp
impl/consensus_init.cpp
)
target_link_libraries(application
server_runner
model
ametsuchi
networking
ordering_service
chain_validator
hash
stateless_validator
processors
crypto
)
gtest
gmock
yac
server_runner
model
ametsuchi
networking
ordering_service
chain_validator
hash
stateless_validator
stateful_validator
processors
crypto
simulator
)

add_executable(irohad irohad.cpp)
target_link_libraries(irohad
application
genesis_block_server
ametsuchi
gflags
rapidjson
config
)
application
genesis_block_server
ametsuchi
gflags
rapidjson
config
)
Loading

0 comments on commit 25b6074

Please sign in to comment.