diff --git a/config/config.json b/config/config.json index a9433db777..48f175466d 100644 --- a/config/config.json +++ b/config/config.json @@ -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 } diff --git a/core/infra/config/iroha_config_with_json.cpp b/core/infra/config/iroha_config_with_json.cpp index 3cf17c7720..6f71fe984a 100644 --- a/core/infra/config/iroha_config_with_json.cpp +++ b/core/infra/config/iroha_config_with_json.cpp @@ -76,3 +76,7 @@ uint16_t IrohaConfigManager::getGrpcPortNumber(uint16_t defaultValue) { uint16_t IrohaConfigManager::getHttpPortNumber(uint16_t defaultValue) { return this->getParam("http_port", defaultValue); } + +bool IrohaConfigManager::getActiveStart(bool defaultValue = false) { + return this->getParam("active_start", defaultValue); +} \ No newline at end of file diff --git a/core/infra/config/iroha_config_with_json.hpp b/core/infra/config/iroha_config_with_json.hpp index cee5f537ac..56d4fa3285 100644 --- a/core/infra/config/iroha_config_with_json.hpp +++ b/core/infra/config/iroha_config_with_json.hpp @@ -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); }; } diff --git a/core/infra/config/peer_service_with_json.cpp b/core/infra/config/peer_service_with_json.cpp index 09ff5ff789..72c27a9967 100644 --- a/core/infra/config/peer_service_with_json.cpp +++ b/core/infra/config/peer_service_with_json.cpp @@ -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 diff --git a/core/service/executor.cpp b/core/service/executor.cpp index 9b1e8108be..4e0f327803 100644 --- a/core/service/executor.cpp +++ b/core/service/executor.cpp @@ -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 ); } } @@ -77,6 +73,7 @@ namespace executor{ // Add }else if(tx.has_peer()){ // Transfer + // nothing this transaction } } @@ -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 } } @@ -106,7 +111,14 @@ namespace executor{ const auto account = tx.account(); repository::account::remove(account.publickey()); }else if(tx.has_peer()){ - // Remove + // 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() ); } } @@ -119,6 +131,7 @@ namespace executor{ // Contract }else if(tx.has_peer()){ // Contract + // nothing this transaction } } diff --git a/core/service/izanami.cpp b/core/service/izanami.cpp index 2d5fb1abcd..0c6d23d9c5 100644 --- a/core/service/izanami.cpp +++ b/core/service/izanami.cpp @@ -22,6 +22,7 @@ limitations under the License. #include "executor.hpp" #include #include +#include #include #include #include @@ -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); } @@ -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; } diff --git a/docker/clear.sh b/docker/clear.sh old mode 100644 new mode 100755 diff --git a/docker/config-discovery/config-server.py b/docker/config-discovery/config-server.py index 32f7950ecc..ce2518d51d 100755 --- a/docker/config-discovery/config-server.py +++ b/docker/config-discovery/config-server.py @@ -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)