Skip to content

Commit

Permalink
Merge pull request hyperledger-iroha#391 from hyperledger/feature/cli…
Browse files Browse the repository at this point in the history
…ent-interfaces

Client interfaces
  • Loading branch information
grimadas authored Jun 26, 2017
2 parents 807c006 + 6c28862 commit a77c963
Show file tree
Hide file tree
Showing 11 changed files with 314 additions and 0 deletions.
1 change: 1 addition & 0 deletions irohad/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ add_subdirectory(main)
add_subdirectory(ordering)
add_subdirectory(peer_service)
add_subdirectory(validation)
add_subdirectory(torii)
add_subdirectory(network)
8 changes: 8 additions & 0 deletions irohad/torii/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
add_library(torii
impl/processor.cpp
)

target_link_libraries(torii PUBLIC
dao
rxcpp
)
35 changes: 35 additions & 0 deletions irohad/torii/client_processor.hpp
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions irohad/torii/impl/processor.cpp
Original file line number Diff line number Diff line change
@@ -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 <torii/client_processor.hpp>
49 changes: 49 additions & 0 deletions irohad/torii/query_processor.hpp
Original file line number Diff line number Diff line change
@@ -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 <dao/dao.hpp>
#include <rxcpp/rx.hpp>

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 <dao::QueryResponse> notifier() = 0;
};
} //namespace torii
} //namespace iroha

#endif //IROHA_QUERY_PROCESSOR_HPP
49 changes: 49 additions & 0 deletions irohad/torii/transaction_processor.hpp
Original file line number Diff line number Diff line change
@@ -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 <dao/dao.hpp>
#include <rxcpp/rx.hpp>

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 <dao::TransactionResponse> notifier() = 0;
};
} //namespace torii
} //namespace iroha
#endif //IROHA_TRANSACTION_PROCESSOR_HPP
31 changes: 31 additions & 0 deletions libs/dao/client.hpp
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions libs/dao/dao.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
31 changes: 31 additions & 0 deletions libs/dao/query.hpp
Original file line number Diff line number Diff line change
@@ -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
43 changes: 43 additions & 0 deletions libs/dao/query_response.hpp
Original file line number Diff line number Diff line change
@@ -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
44 changes: 44 additions & 0 deletions libs/dao/transaction_response.hpp
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a77c963

Please sign in to comment.