forked from hyperledger-iroha/iroha-dco
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
541 additions
and
58 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,11 @@ | ||
#add_subdirectory(block_store) | ||
#add_subdirectory(index) | ||
#add_subdirectory(wsv) | ||
|
||
add_library(storage | ||
# impl/ametsuchi_impl.cpp | ||
# index_mediator.cpp | ||
add_library(ametsuchi | ||
command_executor_stub.cpp | ||
temporary_wsv_stub.cpp | ||
mutable_storage_stub.cpp | ||
ametsuchi_stub.cpp | ||
) | ||
|
||
target_link_libraries(storage PUBLIC | ||
schema | ||
cpp_redis | ||
pqxx | ||
optional | ||
block_store | ||
index | ||
wsv | ||
target_link_libraries(ametsuchi | ||
rxcpp | ||
optional | ||
) |
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,89 @@ | ||
/** | ||
* Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. | ||
* http://soramitsu.co.jp | ||
* | ||
* 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. | ||
*/ | ||
|
||
#include <ametsuchi/ametsuchi_stub.hpp> | ||
#include <ametsuchi/mutable_storage_stub.hpp> | ||
#include <ametsuchi/temporary_wsv_stub.hpp> | ||
|
||
namespace iroha { | ||
namespace ametsuchi { | ||
|
||
std::unique_ptr<TemporaryWsv> AmetsuchiStub::createTemporaryWsv() { | ||
return std::make_unique<TemporaryWsvStub>(*this); | ||
} | ||
|
||
std::unique_ptr<MutableStorage> AmetsuchiStub::createMutableStorage() { | ||
return std::make_unique<MutableStorageStub>(*this); | ||
} | ||
|
||
void AmetsuchiStub::commit(MutableStorage &mutableStorage) { return; } | ||
|
||
rxcpp::observable<dao::Transaction> AmetsuchiStub::get_account_transactions( | ||
iroha::crypto::ed25519::pubkey_t pub_key) { | ||
return rxcpp::observable<>::create<dao::Transaction>( | ||
[](rxcpp::subscriber<dao::Transaction> s) { | ||
s.on_next(dao::Transaction{}); | ||
s.on_completed(); | ||
}); | ||
} | ||
|
||
rxcpp::observable<dao::Transaction> AmetsuchiStub::get_asset_transactions( | ||
std::string asset_full_name) { | ||
return rxcpp::observable<>::create<dao::Transaction>( | ||
[](rxcpp::subscriber<dao::Transaction> s) { | ||
s.on_next(dao::Transaction{}); | ||
s.on_completed(); | ||
}); | ||
} | ||
|
||
rxcpp::observable<dao::Transaction> AmetsuchiStub::get_wallet_transactions( | ||
std::string wallet_id) { | ||
return rxcpp::observable<>::create<dao::Transaction>( | ||
[](rxcpp::subscriber<dao::Transaction> s) { | ||
s.on_next(dao::Transaction{}); | ||
s.on_completed(); | ||
}); | ||
} | ||
|
||
dao::Account AmetsuchiStub::get_account( | ||
iroha::crypto::ed25519::pubkey_t pub_key) { | ||
return dao::Account{}; | ||
} | ||
|
||
dao::Asset AmetsuchiStub::get_asset(std::string asset_full_name) { | ||
return dao::Asset{}; | ||
} | ||
|
||
dao::Domain AmetsuchiStub::get_domain(std::string domain_full_name) { | ||
return dao::Domain{}; | ||
} | ||
|
||
dao::Wallet AmetsuchiStub::get_wallet(std::string wallet_id) { | ||
return dao::Wallet{}; | ||
} | ||
|
||
std::vector<dao::Wallet> AmetsuchiStub::get_account_wallets( | ||
iroha::crypto::ed25519::pubkey_t pub_key) { | ||
return std::vector<dao::Wallet>{dao::Wallet{}}; | ||
} | ||
|
||
std::vector<dao::Asset> AmetsuchiStub::get_domain_assets( | ||
std::string domain_full_name) { | ||
return std::vector<dao::Asset>{dao::Asset{}}; | ||
} | ||
} // namespace ametsuchi | ||
} // namespace iroha |
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,52 @@ | ||
/** | ||
* Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. | ||
* http://soramitsu.co.jp | ||
* | ||
* 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_AMETSUCHI_STUB_HPP | ||
#define IROHA_AMETSUCHI_STUB_HPP | ||
|
||
#include <ametsuchi/ametsuchi.hpp> | ||
#include <memory> | ||
|
||
namespace iroha { | ||
namespace ametsuchi { | ||
|
||
class AmetsuchiStub : public Ametsuchi { | ||
public: | ||
std::unique_ptr<TemporaryWsv> createTemporaryWsv() override; | ||
std::unique_ptr<MutableStorage> createMutableStorage() override; | ||
void commit(MutableStorage &mutableStorage) override; | ||
rxcpp::observable<iroha::dao::Transaction> get_account_transactions( | ||
iroha::crypto::ed25519::pubkey_t pub_key) override; | ||
rxcpp::observable<iroha::dao::Transaction> get_asset_transactions( | ||
std::string asset_full_name) override; | ||
rxcpp::observable<iroha::dao::Transaction> get_wallet_transactions( | ||
std::string wallet_id) override; | ||
dao::Account get_account( | ||
iroha::crypto::ed25519::pubkey_t pub_key) override; | ||
dao::Asset get_asset(std::string asset_full_name) override; | ||
dao::Domain get_domain(std::string domain_full_name) override; | ||
dao::Wallet get_wallet(std::string wallet_id) override; | ||
std::vector<dao::Wallet> get_account_wallets( | ||
iroha::crypto::ed25519::pubkey_t pub_key) override; | ||
std::vector<dao::Asset> get_domain_assets( | ||
std::string domain_full_name) override; | ||
}; | ||
|
||
} // namespace ametsuchi | ||
} // namespace iroha | ||
|
||
#endif // IROHA_AMETSUCHI_STUB_HPP |
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,39 @@ | ||
/** | ||
* Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. | ||
* http://soramitsu.co.jp | ||
* | ||
* 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. | ||
*/ | ||
|
||
#include <ametsuchi/command_executor_stub.hpp> | ||
|
||
namespace iroha { | ||
namespace ametsuchi { | ||
|
||
bool CommandExecutorStub::execute(const dao::Command &command) { | ||
auto handler = map_.find(command); | ||
return handler.value_or([](const dao::Command &) { return false; })( | ||
command); | ||
} | ||
|
||
bool CommandExecutorStub::executeAddPeer(const dao::AddPeer &command) { | ||
return true; | ||
} | ||
|
||
CommandExecutorStub::CommandExecutorStub(WsvQuery &query) : query_(query) { | ||
// https://stackoverflow.com/questions/9998402/c11-does-not-deduce-type-when-stdfunction-or-lambda-functions-are-involved | ||
map_.insert<dao::AddPeer>(std::bind(&CommandExecutorStub::executeAddPeer, | ||
this, std::placeholders::_1)); | ||
} | ||
} // namespace ametsuchi | ||
} // namespace iroha |
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,46 @@ | ||
/** | ||
* Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. | ||
* http://soramitsu.co.jp | ||
* | ||
* 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_COMMAND_EXECUTOR_STUB_HPP | ||
#define IROHA_COMMAND_EXECUTOR_STUB_HPP | ||
|
||
#include <ametsuchi/command_executor.hpp> | ||
#include <ametsuchi/wsv_query.hpp> | ||
#include <dao/dao.hpp> | ||
#include <functional> | ||
#include <handler_map/handler_map.hpp> | ||
#include <memory> | ||
#include <unordered_map> | ||
|
||
namespace iroha { | ||
namespace ametsuchi { | ||
|
||
class CommandExecutorStub : public CommandExecutor { | ||
public: | ||
CommandExecutorStub(WsvQuery &query); | ||
bool execute(const dao::Command &command) override; | ||
|
||
private: | ||
bool executeAddPeer(const dao::AddPeer &command); | ||
WsvQuery &query_; | ||
HandlerMap<dao::Command, bool> map_; | ||
}; | ||
|
||
} // namespace ametsuchi | ||
} // namespace iroha | ||
|
||
#endif // IROHA_COMMAND_EXECUTOR_STUB_HPP |
File renamed without changes.
File renamed without changes.
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,75 @@ | ||
/** | ||
* Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. | ||
* http://soramitsu.co.jp | ||
* | ||
* 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. | ||
*/ | ||
|
||
#include <ametsuchi/mutable_storage_stub.hpp> | ||
|
||
namespace iroha { | ||
namespace ametsuchi { | ||
|
||
rxcpp::observable<dao::Transaction> | ||
MutableStorageStub::get_account_transactions( | ||
iroha::crypto::ed25519::pubkey_t pub_key) { | ||
return ametsuchi_.get_account_transactions(pub_key); | ||
} | ||
|
||
rxcpp::observable<dao::Transaction> | ||
MutableStorageStub::get_asset_transactions(std::string asset_full_name) { | ||
return ametsuchi_.get_asset_transactions(asset_full_name); | ||
} | ||
|
||
rxcpp::observable<dao::Transaction> | ||
MutableStorageStub::get_wallet_transactions(std::string wallet_id) { | ||
return ametsuchi_.get_wallet_transactions(wallet_id); | ||
} | ||
|
||
dao::Account MutableStorageStub::get_account( | ||
iroha::crypto::ed25519::pubkey_t pub_key) { | ||
return ametsuchi_.get_account(pub_key); | ||
} | ||
|
||
dao::Asset MutableStorageStub::get_asset(std::string asset_full_name) { | ||
return ametsuchi_.get_asset(asset_full_name); | ||
} | ||
|
||
dao::Domain MutableStorageStub::get_domain(std::string domain_full_name) { | ||
return ametsuchi_.get_domain(domain_full_name); | ||
} | ||
|
||
dao::Wallet MutableStorageStub::get_wallet(std::string wallet_id) { | ||
return ametsuchi_.get_wallet(wallet_id); | ||
} | ||
|
||
std::vector<dao::Wallet> MutableStorageStub::get_account_wallets( | ||
iroha::crypto::ed25519::pubkey_t pub_key) { | ||
return ametsuchi_.get_account_wallets(pub_key); | ||
} | ||
|
||
std::vector<dao::Asset> MutableStorageStub::get_domain_assets( | ||
std::string domain_full_name) { | ||
return ametsuchi_.get_domain_assets(domain_full_name); | ||
} | ||
|
||
bool MutableStorageStub::apply( | ||
dao::Block block, | ||
std::function<bool(dao::Block&, CommandExecutor&, WsvQuery&)> function) { | ||
return function(block, executor_, ametsuchi_); | ||
} | ||
|
||
MutableStorageStub::MutableStorageStub(AmetsuchiStub &ametsuchi) | ||
: ametsuchi_(ametsuchi), executor_(*this) {} | ||
} // namespace ametsuchi | ||
} // namespace iroha |
Oops, something went wrong.