-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactoring - changed include style from `"../../something/header.hpp"` to relative to `core`: `#incude <model/object/transaction.hpp` - fixed few bugs related to config.json - removed empty files - improved circle.yml: now after docker run hyperledger/iroha-docker it shows its output modified: circle.yml new file: config/config.json modified: core/CMakeLists.txt modified: core/consensus/CMakeLists.txt new file: core/consensus/connection/CMakeLists.txt modified: core/consensus/connection/connection.hpp modified: core/consensus/consensus_event.hpp modified: core/consensus/sumeragi.cpp modified: core/consensus/sumeragi.hpp modified: core/infra/config/CMakeLists.txt new file: core/infra/config/abstract_config_manager.hpp deleted: core/infra/config/iroha_config.hpp modified: core/infra/config/iroha_config_with_json.cpp modified: core/infra/config/iroha_config_with_json.hpp modified: core/infra/config/peer_service_with_json.cpp modified: core/infra/config/peer_service_with_json.hpp modified: core/infra/connection/CMakeLists.txt modified: core/infra/connection/connection_with_grpc.cpp modified: core/infra/protobuf/CMakeLists.txt modified: core/infra/repository/CMakeLists.txt modified: core/infra/repository/world_state_repository_with_level_db.cpp modified: core/infra/server/CMakeLists.txt modified: core/infra/server/http_server_with_cappuccino.cpp modified: core/infra/smart_contract/smart_contract_with_java.cpp modified: core/model/CMakeLists.txt modified: core/model/commands/CMakeLists.txt modified: core/model/commands/add.cpp modified: core/model/commands/add.hpp modified: core/model/commands/command.hpp modified: core/model/commands/transfer.cpp modified: core/model/commands/transfer.hpp modified: core/model/commands/update.hpp modified: core/model/objects/CMakeLists.txt modified: core/model/objects/object.hpp deleted: core/model/transaction.cpp modified: core/model/transaction.hpp modified: core/repository/consensus/CMakeLists.txt modified: core/repository/consensus/transaction_repository.cpp modified: core/repository/consensus/transaction_repository.hpp modified: core/repository/domain/CMakeLists.txt modified: core/repository/domain/account_repository.hpp modified: core/repository/domain/domain_sample_asset_repository.hpp modified: core/repository/domain/instance/CMakeLists.txt modified: core/repository/domain/instance/account_repository.cpp modified: core/repository/domain/instance/asset_repository.cpp modified: core/repository/domain/instance/asset_repository.hpp modified: core/validation/CMakeLists.txt modified: core/validation/consensus_event_validator.cpp modified: core/validation/consensus_event_validator.hpp modified: core/validation/transaction_validator.hpp modified: docker/build/config/config.json modified: peer/CMakeLists.txt modified: peer/main.cpp modified: test/connection/CMakeLists.txt modified: test/connection/connection_with_grpc_test.cpp modified: test/consensus/CMakeLists.txt modified: test/consensus/sumeragi_test.cpp modified: test/consensus/transaction_test.cpp * Fixed pro->priv * Fix typo in log message on JSON config parsing * Create typed accessors for "config.json" parameters * Fix initializer_list typos, replace rvalue-ref to const lvalue-ref * Refactoring * Fixed dependency hell Probably you've got an error after make -j4? This commit fixes this. * Fixed bug in build.sh Now build.sh stops after errors at some step.
- Loading branch information
Showing
73 changed files
with
508 additions
and
474 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"database_path":"/tmp/iroha_ledger", | ||
"concurrency": 0, | ||
"max_faulty_peers" : 1, | ||
"pool_worker_queue_size": 1024 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
include_directories( | ||
"${PROJECT_SOURCE_DIR}/core" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,9 @@ | ||
set(JSON_PATH "${PROJECT_SOURCE_DIR}/core/vendor/json") | ||
|
||
include_directories( | ||
${JSON_PATH}/src | ||
) | ||
|
||
ADD_LIBRARY(iroha_config_with_json STATIC | ||
iroha_config_with_json.cpp | ||
) | ||
|
||
ADD_LIBRARY(peer_service_with_json STATIC | ||
peer_service_with_json.cpp | ||
${PROJECT_SOURCE_DIR}/core/vendor/json/src | ||
${PROJECT_SOURCE_DIR}/core | ||
) | ||
|
||
target_link_libraries( | ||
iroha_config_with_json | ||
peer_service_with_json | ||
logger | ||
add_library(config_manager STATIC | ||
peer_service_with_json.cpp | ||
iroha_config_with_json.cpp | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
Copyright Soramitsu Co., Ltd. 2016 All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
#ifndef IROHA_CONFIG_H | ||
#define IROHA_CONFIG_H | ||
|
||
#include <fstream> // ifstream, ofstream | ||
#include <util/logger.hpp> | ||
#include <util/use_optional.hpp> | ||
#include <vendor/json/src/json.hpp> | ||
|
||
namespace config { | ||
|
||
using json = nlohmann::json; | ||
|
||
class AbstractConfigManager { | ||
protected: | ||
optional<json> openConfig(const std::string& configName) { | ||
if (_configData) { // content is already loaded | ||
return _configData; | ||
} | ||
|
||
auto iroha_home = getenv("IROHA_HOME"); | ||
if (iroha_home == nullptr) { | ||
logger::error("config") << "Set environment variable IROHA_HOME"; | ||
exit(EXIT_FAILURE); | ||
} | ||
|
||
auto configFolderPath = std::string(iroha_home) + "/"; | ||
auto jsonStr = readConfigData(configFolderPath + configName); | ||
|
||
logger::debug("config") << "load json is " << jsonStr; | ||
|
||
setConfigData(std::move(jsonStr)); | ||
|
||
return _configData; | ||
} | ||
|
||
std::string readConfigData(const std::string& pathToJSONFile) { | ||
std::ifstream ifs(pathToJSONFile); | ||
if (ifs.fail()) { | ||
logger::error("config") << "Not found: " << pathToJSONFile; | ||
return nullptr; | ||
} | ||
|
||
std::istreambuf_iterator<char> it(ifs); | ||
return std::string(it, std::istreambuf_iterator<char>()); | ||
} | ||
|
||
void setConfigData(std::string&& jsonStr) { | ||
try { | ||
_configData = json::parse(std::move(jsonStr)); | ||
} catch (...) { | ||
logger::error("config") << "Can't parse json: " << getConfigName(); | ||
} | ||
} | ||
|
||
public: | ||
virtual std::string getConfigName() = 0; | ||
optional<json> getConfigData() { return this->_configData; } | ||
|
||
protected: | ||
optional<json> _configData; | ||
}; | ||
} | ||
|
||
#endif // IROHA_CONFIG_H |
Oops, something went wrong.