diff --git a/irohad/CMakeLists.txt b/irohad/CMakeLists.txt index 4fa3553110..1f208a52e4 100644 --- a/irohad/CMakeLists.txt +++ b/irohad/CMakeLists.txt @@ -21,4 +21,5 @@ add_subdirectory(main) add_subdirectory(ordering) add_subdirectory(peer_service) add_subdirectory(validation) +add_subdirectory(torii) add_subdirectory(network) \ No newline at end of file diff --git a/irohad/torii/CMakeLists.txt b/irohad/torii/CMakeLists.txt new file mode 100644 index 0000000000..0ff46c94d5 --- /dev/null +++ b/irohad/torii/CMakeLists.txt @@ -0,0 +1,8 @@ +add_library(torii + impl/processor.cpp + ) + +target_link_libraries(torii PUBLIC + dao + rxcpp + ) \ No newline at end of file diff --git a/irohad/torii/client_processor.hpp b/irohad/torii/client_processor.hpp new file mode 100644 index 0000000000..4b8c0c59e2 --- /dev/null +++ b/irohad/torii/client_processor.hpp @@ -0,0 +1,35 @@ +/** + * 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_CLIENT_PROCESSOR_HPP +#define IROHA_CLIENT_PROCESSOR_HPP + +#include "query_processor.hpp" +#include "transaction_processor.hpp" + +namespace iroha { + namespace torii { + + /** + * Client processor is interface + * for processing all user's intents in the system + */ + class ClientProcessor : public QueryProcessor, public TransactionProcessor { + }; + } //namespace torii +} //namespace iroha +#endif //IROHA_CLIENT_PROCESSOR_HPP diff --git a/irohad/torii/impl/processor.cpp b/irohad/torii/impl/processor.cpp new file mode 100644 index 0000000000..13f7fba7c7 --- /dev/null +++ b/irohad/torii/impl/processor.cpp @@ -0,0 +1,18 @@ +/** + * 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 \ No newline at end of file diff --git a/irohad/torii/query_processor.hpp b/irohad/torii/query_processor.hpp new file mode 100644 index 0000000000..49f5997e63 --- /dev/null +++ b/irohad/torii/query_processor.hpp @@ -0,0 +1,49 @@ +/** + * 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_QUERY_PROCESSOR_HPP +#define IROHA_QUERY_PROCESSOR_HPP + +#include +#include + +namespace iroha { + namespace torii { + + /** + * QueryProcessor provides start point for queries in the whole system + */ + class QueryProcessor { + public: + + /** + * Register client query + * @param client - query emitter + * @param query - client intent + */ + virtual void handle(dao::Client client, dao::Query query) = 0; + + /** + * Subscribe for query responses + * @return observable with query responses + */ + virtual rxcpp::observable notifier() = 0; + }; + } //namespace torii +} //namespace iroha + +#endif //IROHA_QUERY_PROCESSOR_HPP diff --git a/irohad/torii/transaction_processor.hpp b/irohad/torii/transaction_processor.hpp new file mode 100644 index 0000000000..767e9c315f --- /dev/null +++ b/irohad/torii/transaction_processor.hpp @@ -0,0 +1,49 @@ +/** + * 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_TRANSACTION_PROCESSOR_HPP +#define IROHA_TRANSACTION_PROCESSOR_HPP + +#include +#include + +namespace iroha { + namespace torii { + + /** + * Transaction processor is interface with start point + * for processing transaction in the system + */ + class TransactionProcessor { + public: + + /** + * Add transaction to the system for processing + * @param client - transaction owner + * @param transaction - transaction for processing + */ + virtual void handle(dao::Client client, dao::Transaction transaction) = 0; + + /** + * Subscribes will be notified with transaction status + * @return observable for subscribing + */ + virtual rxcpp::observable notifier() = 0; + }; + } //namespace torii +} //namespace iroha +#endif //IROHA_TRANSACTION_PROCESSOR_HPP diff --git a/libs/dao/client.hpp b/libs/dao/client.hpp new file mode 100644 index 0000000000..a3f2c2dc55 --- /dev/null +++ b/libs/dao/client.hpp @@ -0,0 +1,31 @@ +/** + * 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_CLIENT_HPP +#define IROHA_CLIENT_HPP +namespace iroha { + namespace dao { + + /** + * Client is representation of user in system + */ + struct Client { + + }; + } +} +#endif //IROHA_CLIENT_HPP diff --git a/libs/dao/dao.hpp b/libs/dao/dao.hpp index 928ee7bc4f..82a1c4414b 100644 --- a/libs/dao/dao.hpp +++ b/libs/dao/dao.hpp @@ -20,8 +20,13 @@ #include "block.hpp" #include "proposal.hpp" #include "transaction.hpp" +#include "transaction_response.hpp" #include "asset.hpp" #include "account.hpp" +#include "client.hpp" + +#include "query.hpp" +#include "query_response.hpp" #include "peer.hpp" #include "singature.hpp" #include "dao_crypto_provider.hpp" diff --git a/libs/dao/query.hpp b/libs/dao/query.hpp new file mode 100644 index 0000000000..e9a71b48f5 --- /dev/null +++ b/libs/dao/query.hpp @@ -0,0 +1,31 @@ +/** + * 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_QUERY_HPP +#define IROHA_QUERY_HPP +namespace iroha { + namespace dao { + /** + * This dao represents user intent for reading ledger. + * Concrete queries should extend this interface. + */ + struct Query { + + }; + } //namespace dao +} //namespace iroha +#endif //IROHA_QUERY_HPP diff --git a/libs/dao/query_response.hpp b/libs/dao/query_response.hpp new file mode 100644 index 0000000000..8c3dde3b0c --- /dev/null +++ b/libs/dao/query_response.hpp @@ -0,0 +1,43 @@ +/** + * 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_QUERY_RESPONSE_HPP +#define IROHA_QUERY_RESPONSE_HPP + +#include "query.hpp" +#include "client.hpp" + +namespace iroha { + namespace dao { + /** + * Interface of query response for user + */ + struct QueryResponse { + + /** + * Client query + */ + Query query; + + /** + * Client identifier + */ + Client client; + }; + } //namespace dao +} //namespace iroha +#endif //IROHA_QUERY_RESPONSE_HPP diff --git a/libs/dao/transaction_response.hpp b/libs/dao/transaction_response.hpp new file mode 100644 index 0000000000..9a52acf80c --- /dev/null +++ b/libs/dao/transaction_response.hpp @@ -0,0 +1,44 @@ +/** + * 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_TRANSACTION_RESPONSE_HPP +#define IROHA_TRANSACTION_RESPONSE_HPP + +#include "transaction.hpp" +#include "client.hpp" + +namespace iroha { + namespace dao { + + /** + * Transaction response is data with status during transaction lifecycle + */ + struct TransactionResponse { + + /** + * Processed transaction + */ + Transaction transaction; + + /** + * Transaction emitter + */ + Client client; + }; + } //namespace dao +} //namespace iroha +#endif //IROHA_TRANSACTION_RESPONSE_HPP