Skip to content

Commit

Permalink
change namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
satellitex committed Jul 13, 2017
1 parent 3d03ce0 commit d49c3c5
Show file tree
Hide file tree
Showing 4 changed files with 254 additions and 280 deletions.
192 changes: 86 additions & 106 deletions irohad/peer_service/peer_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,113 +16,93 @@ limitations under the License.

#include <peer_service/peer_service.hpp>

namespace iroha {
namespace peer_service {
namespace peer_service {

void initialize() {
detail::self_ = SelfStatus();
void initialize() {
detail::self_ = SelfStatus();

// detail::peers_ = ametsuchi::getPeers()
}

/**
* @return List of peers that therefore permutation.
*/
std::vector<std::shared_ptr<Peer>> getPermutationPeers() { return std::vector<std::shared_ptr<Peer>>(); }

/**
* @param i index
* @return A i-th peer that therefore permutation.
*/
Peer getPermutationAt(int i) { return Peer(); }

/**
* @return List of peers that is used by ordering service.
*/
std::vector<std::shared_ptr<Peer>> getOrderingPeers() { return std::vector<std::shared_ptr<Peer>>(); }

/**
* @return List of peers that is used by ordering service and is that will
* be send sumeragi.
*/
std::vector<std::shared_ptr<Peer>> getActiveOrderingPeers() { return std::vector<std::shared_ptr<Peer>>(); }

/**
* @return self status
*/
const SelfStatus &self() {
return detail::self_;
}

/**
* When on_porposal sends on_commit, it is called.
* It check signs from Block, and identify dead peers which It throw to
* issue Peer::Remove transaction.
* @param commited_block commited block with signs
*/
void DiesRemove(const iroha::model::Block &commited_block) {}

/**
* When on_commit, it is called.
* It change peer oreder.
*/
void changePermutation() {}

/**
* When commit fails, it is called.
* It throw to issue Peer::Stop(Self) transaction.
*/
void selfStop() {}

/**
* When commit successes and state of self peer is UnSynced, It is called.
* It throw to issue Peer::Activate(self) transaction.
*/
void selfActivate() {}


/**
* validate command
*/
void validate(const Command::Peer::Add& cmd){

}
void validate(const Command::Peer::Remove& cmd){

}
void validate(const Command::Peer::Activate& cmd){

}
void validate(const Command::Peer::Stop& cmd){

}
void validate(const Command::Peer::ChangeRole& cmd){

}


/**
* execute command
*/
void execute(const Command::Peer::Add& cmd){

}
void execute(const Command::Peer::Remove& cmd){

}
void execute(const Command::Peer::Activate& cmd){

}
void execute(const Command::Peer::Stop& cmd){

}
void execute(const Command::Peer::ChangeRole& cmd){
// detail::peers_ = ametsuchi::getPeers()
}

/**
* @return List of peers that therefore permutation.
*/
std::vector<std::shared_ptr<Peer>> getPermutationPeers() {
return std::vector<std::shared_ptr<Peer>>();
}

}

namespace detail {
void issueStop(std::string ip, Peer &stop_peer) {}
void issueActivate(std::string ip, Peer &activate_peer) {}
}
/**
* @param i index
* @return A i-th peer that therefore permutation.
*/
Peer getPermutationAt(int i) { return Peer(); }

/**
* @return List of peers that is used by ordering service.
*/
std::vector<std::shared_ptr<Peer>> getOrderingPeers() {
return std::vector<std::shared_ptr<Peer>>();
}
}

/**
* @return List of peers that is used by ordering service and is that will
* be send sumeragi.
*/
std::vector<std::shared_ptr<Peer>> getActiveOrderingPeers() {
return std::vector<std::shared_ptr<Peer>>();
}

/**
* @return self status
*/
const SelfStatus& self() { return detail::self_; }

/**
* When on_porposal sends on_commit, it is called.
* It check signs from Block, and identify dead peers which It throw to
* issue Peer::Remove transaction.
* @param commited_block commited block with signs
*/
void DiesRemove(const iroha::model::Block& commited_block) {}

/**
* When on_commit, it is called.
* It change peer oreder.
*/
void changePermutation() {}

/**
* When commit fails, it is called.
* It throw to issue Peer::Stop(Self) transaction.
*/
void selfStop() {}

/**
* When commit successes and state of self peer is UnSynced, It is called.
* It throw to issue Peer::Activate(self) transaction.
*/
void selfActivate() {}

/**
* validate command
*/
void validate(const Command::Peer::Add& cmd) {}
void validate(const Command::Peer::Remove& cmd) {}
void validate(const Command::Peer::Activate& cmd) {}
void validate(const Command::Peer::Stop& cmd) {}
void validate(const Command::Peer::ChangeRole& cmd) {}

/**
* execute command
*/
void execute(const Command::Peer::Add& cmd) {}
void execute(const Command::Peer::Remove& cmd) {}
void execute(const Command::Peer::Activate& cmd) {}
void execute(const Command::Peer::Stop& cmd) {}
void execute(const Command::Peer::ChangeRole& cmd) {}

namespace detail {
void issueStop(std::string ip, Peer& stop_peer) {}
void issueActivate(std::string ip, Peer& activate_peer) {}
} // namespace detail
} // namespace peer_servince
188 changes: 92 additions & 96 deletions irohad/peer_service/peer_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,105 +23,101 @@ limitations under the License.
#include <string>
#include <vector>

#include <commands.pb.h>
#include <model/block.hpp>
#include <model/peer.hpp>
#include <peer_service/self_status.hpp>
#include <commands.pb.h>

namespace iroha {
namespace peer_service {

using Peer = iroha::model::Peer;
using Command = iroha::protocol::Command;

void initialize();

/**
* @return List of peers that therefore permutation.
*/
std::vector<std::shared_ptr<Peer>> getPermutationPeers();

/**
* @param i index
* @return A i-th peer that therefore permutation.
*/
Peer getPermutationAt(int i);

/**
* @return List of peers that is used by ordering service.
*/
std::vector<std::shared_ptr<Peer>> getOrderingPeers();

/**
* @return List of peers that is used by ordering service and is that will
* be send sumeragi.
*/
std::vector<std::shared_ptr<Peer>> getActiveOrderingPeers();

/**
* @return self status
*/
const SelfStatus& self();

/**
* When on_porposal sends on_commit, it is called.
* It check signs from Block, and identify dead peers which It throw to
* issue Peer::Remove transaction.
* @param commited_block commited block with signs
*/
void DiesRemove(const iroha::model::Block& commited_block);

/**
* When on_commit, it is called.
* It change peer oreder.
*/
void changePermutation();

/**
* When commit fails, it is called.
* It throw to issue Peer::Stop(Self) transaction.
*/
void selfStop();

/**
* When commit successes and state of self peer is UnSynced, It is called.
* It throw to issue Peer::Activate(self) transaction.
*/
void selfActivate();


/**
* validate command
*/
void validate(const Command::Peer::Add& );
void validate(const Command::Peer::Remove& );
void validate(const Command::Peer::Activate& );
void validate(const Command::Peer::Stop& );
void validate(const Command::Peer::ChangeRole& );


/**
* execute command
*/
void execute(const Command::Peer::Add& );
void execute(const Command::Peer::Remove& );
void execute(const Command::Peer::Activate& );
void execute(const Command::Peer::Stop& );
void execute(const Command::Peer::ChangeRole& );

namespace detail {
void issueStop(std::string ip, Peer& stop_peer);

void issueActivate(std::string ip, Peer& activate_peer);

SelfStatus self_;
std::vector<int> permutation_;
std::vector<int> active_ordering_permutation_;

std::vector<std::shared_ptr<Peer>> peers_;
}

} // namespace peer_service
} // iroha
namespace peer_service {

using Peer = iroha::model::Peer;
using Command = iroha::protocol::Command;

void initialize();

/**
* @return List of peers that therefore permutation.
*/
std::vector<std::shared_ptr<Peer>> getPermutationPeers();

/**
* @param i index
* @return A i-th peer that therefore permutation.
*/
Peer getPermutationAt(int i);

/**
* @return List of peers that is used by ordering service.
*/
std::vector<std::shared_ptr<Peer>> getOrderingPeers();

/**
* @return List of peers that is used by ordering service and is that will
* be send sumeragi.
*/
std::vector<std::shared_ptr<Peer>> getActiveOrderingPeers();

/**
* @return self status
*/
const SelfStatus& self();

/**
* When on_porposal sends on_commit, it is called.
* It check signs from Block, and identify dead peers which It throw to
* issue Peer::Remove transaction.
* @param commited_block commited block with signs
*/
void DiesRemove(const iroha::model::Block& commited_block);

/**
* When on_commit, it is called.
* It change peer oreder.
*/
void changePermutation();

/**
* When commit fails, it is called.
* It throw to issue Peer::Stop(Self) transaction.
*/
void selfStop();

/**
* When commit successes and state of self peer is UnSynced, It is called.
* It throw to issue Peer::Activate(self) transaction.
*/
void selfActivate();

/**
* validate command
*/
void validate(const Command::Peer::Add&);
void validate(const Command::Peer::Remove&);
void validate(const Command::Peer::Activate&);
void validate(const Command::Peer::Stop&);
void validate(const Command::Peer::ChangeRole&);

/**
* execute command
*/
void execute(const Command::Peer::Add&);
void execute(const Command::Peer::Remove&);
void execute(const Command::Peer::Activate&);
void execute(const Command::Peer::Stop&);
void execute(const Command::Peer::ChangeRole&);

namespace detail {
void issueStop(std::string ip, Peer& stop_peer);

void issueActivate(std::string ip, Peer& activate_peer);

SelfStatus self_;
std::vector<int> permutation_;
std::vector<int> active_ordering_permutation_;

std::vector<std::shared_ptr<Peer>> peers_;
}

} // namespace peer_service

#endif
Loading

0 comments on commit d49c3c5

Please sign in to comment.