Skip to content

Commit

Permalink
[WIP] preparation peer-service test
Browse files Browse the repository at this point in the history
  • Loading branch information
satellitex authored and l4l committed Mar 17, 2017
1 parent e5dcb38 commit 55b69ef
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 12 deletions.
3 changes: 2 additions & 1 deletion config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"max_faulty_peers" : 1,
"pool_worker_queue_size": 1024,
"http_port": 1204,
"grpc_port": 50051
"grpc_port": 50051,
"active_start": true
}
4 changes: 4 additions & 0 deletions core/infra/config/iroha_config_with_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,7 @@ uint16_t IrohaConfigManager::getGrpcPortNumber(uint16_t defaultValue) {
uint16_t IrohaConfigManager::getHttpPortNumber(uint16_t defaultValue) {
return this->getParam<uint16_t>("http_port", defaultValue);
}

bool IrohaConfigManager::getActiveStart(bool defaultValue = false) {
return this->getParam<bool>("active_start", defaultValue);
}
1 change: 1 addition & 0 deletions core/infra/config/iroha_config_with_json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class IrohaConfigManager : config::AbstractConfigManager {
size_t getPoolWorkerQueueSize(size_t defaultValue);
uint16_t getGrpcPortNumber(uint16_t defaultValue);
uint16_t getHttpPortNumber(uint16_t defaultValue);
bool getActiveStart(bool defaultValue);
};
}

Expand Down
1 change: 1 addition & 0 deletions core/infra/config/peer_service_with_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ void PeerServiceConfig::finishedInitializePeer() {
.setPeer(txbuilder::createPeer( getMyPublicKey(), getMyIp(), txbuilder::createTrust(0.0, true)))
.build();
connection::iroha::PeerService::Sumeragi::send( leader_ip, txPeer );
updatePeer( getMyPublicKey(), peer::Node(getMyIp(),getMyPublicKey(),0.0, true) );
}

// invoke to issue transaction
Expand Down
29 changes: 21 additions & 8 deletions core/service/executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,9 @@ namespace executor{
tx.peer().trust().value(),
tx.peer().trust().isok()
);
if( tx.type() == "Add" ) {
config::PeerServiceConfig::getInstance().addPeer( query_peer );
} else if( tx.type() == "Remove" ) {
config::PeerServiceConfig::getInstance().removePeer( query_peer.getPublicKey() );
} else if( tx.type() == "Update" ) {
config::PeerServiceConfig::getInstance().updatePeer( query_peer.getPublicKey(), query_peer );
}
config::PeerServiceConfig::getInstance().addPeer( query_peer );
config::PeerServiceConfig::getInstance().removePeer( query_peer.getPublicKey() );
config::PeerServiceConfig::getInstance().updatePeer( query_peer.getPublicKey(), query_peer );
}
}

Expand All @@ -77,6 +73,7 @@ namespace executor{
// Add<Account>
}else if(tx.has_peer()){
// Transfer<Peer>
// nothing this transaction
}
}

Expand All @@ -90,6 +87,14 @@ namespace executor{
const auto account = tx.account();
repository::account::update(account.publickey(), account);
}else if(tx.has_peer()){
// Temporary - to operate peer service
peer::Node query_peer(
tx.peer().address(),
tx.peer().publickey(),
tx.peer().trust().value(),
tx.peer().trust().isok()
);
config::PeerServiceConfig::getInstance().updatePeer( query_peer.getPublicKey(), query_peer );
// Update<Peer>
}
}
Expand All @@ -106,7 +111,14 @@ namespace executor{
const auto account = tx.account();
repository::account::remove(account.publickey());
}else if(tx.has_peer()){
// Remove<Peer>
// Temporary - to operate peer service
peer::Node query_peer(
tx.peer().address(),
tx.peer().publickey(),
tx.peer().trust().value(),
tx.peer().trust().isok()
);
config::PeerServiceConfig::getInstance().removePeer( query_peer.getPublicKey() );
}
}

Expand All @@ -119,6 +131,7 @@ namespace executor{
// Contract<Account>
}else if(tx.has_peer()){
// Contract<Peer>
// nothing this transaction
}
}

Expand Down
8 changes: 6 additions & 2 deletions core/service/izanami.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ limitations under the License.
#include "executor.hpp"
#include <infra/protobuf/api.pb.h>
#include <consensus/connection/connection.hpp>
#include <service/peer_service.hpp>
#include <infra/config/peer_service_with_json.hpp>
#include <infra/config/iroha_config_with_json.hpp>
#include <crypto/hash.hpp>
Expand Down Expand Up @@ -144,6 +145,9 @@ namespace izanami {
event.finished();
logger::explore("izanami") << "Finished Receive ALl Transaction";
logger::explore("izanami") << "Closed Izanami";
for( auto&& p : config::PeerServiceConfig::getInstance().getPeerList() ) {
logger::explore("izanami_initialized_nodes") << p->getIP() + " : " + p->getPublicKey() + " : " + p->getPublicKey() + " : " + std::to_string( p->getTrustScore() );
}
} else {
detail::storeTransactionResponse(event);
}
Expand All @@ -163,8 +167,8 @@ namespace izanami {
//invoke when initialize Peer that to config Participation on the way
void startIzanami() {
logger::explore("izanami") << "startIzanami";
if( config::PeerServiceConfig::getInstance().isExistPublicKey( config::PeerServiceConfig::getInstance().getMyPublicKey() ) ) {
logger::explore("izanami") << "I am start up Iroha Peer.";
if( config::IrohaConfigManager::getInstance().getActiveStart(false) ) {
logger::explore("izanami") << "I am Active Start Iroha Peer.";
logger::explore("izanami") << "Closed Izanami";
return;
}
Expand Down
Empty file modified docker/clear.sh
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion docker/config-discovery/config-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def make_configs(network):
if config1 == config2:
continue

c['group'].append(extract(config2))
# c['group'].append(extract(config2))

result[id_] = json.dumps(c)

Expand Down

0 comments on commit 55b69ef

Please sign in to comment.