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.
Add OrderingServiceStub and ConsensusServiceStub
- Loading branch information
Showing
14 changed files
with
267 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* 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_CONSENSUS_SERVICE_HPP | ||
#define IROHA_CONSENSUS_SERVICE_HPP | ||
|
||
#include <dao/proposal.hpp> | ||
#include <dao/block.hpp> | ||
#include <rxcpp/rx-observable.hpp> | ||
|
||
namespace iroha { | ||
namespace consensus { | ||
/** | ||
* Consensus interface for peer communication service | ||
*/ | ||
class ConsensusService { | ||
public: | ||
|
||
/** | ||
* Propagate a block formed from proposal | ||
* @param block | ||
*/ | ||
virtual void propagate_block(dao::Block &block) = 0; | ||
|
||
/** | ||
* Return observable of all commits from the consensus | ||
* @return | ||
*/ | ||
virtual rxcpp::observable<rxcpp::observable<dao::Block>> on_commit() = 0; | ||
}; | ||
} // namespace consensus | ||
} // namespace iroha | ||
|
||
#endif //IROHA_CONSENSUS_SERVICE_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* 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 <consensus/consensus_service_stub.hpp> | ||
|
||
namespace iroha { | ||
namespace consensus { | ||
|
||
using dao::Transaction; | ||
using dao::Proposal; | ||
using dao::Block; | ||
|
||
rxcpp::observable<rxcpp::observable<dao::Block>> | ||
ConsensusServiceStub::on_commit() { | ||
return commits_.get_observable(); | ||
} | ||
|
||
void ConsensusServiceStub::propagate_block(dao::Block &block) { | ||
commits_.get_subscriber().on_next(rxcpp::observable<>::from(block)); | ||
} | ||
|
||
} // namespace consensus | ||
} // 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,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. | ||
*/ | ||
|
||
#ifndef IROHA_CONSENSUS_SERVICE_STUB_HPP | ||
#define IROHA_CONSENSUS_SERVICE_STUB_HPP | ||
|
||
#include <ametsuchi/ametsuchi.hpp> | ||
#include <consensus/consensus_service.hpp> | ||
#include <validation/chain/validator.hpp> | ||
#include <validation/stateful/validator.hpp> | ||
|
||
namespace iroha { | ||
namespace consensus { | ||
class ConsensusServiceStub : public ConsensusService { | ||
public: | ||
void propagate_block(dao::Block &block) override; | ||
rxcpp::observable<rxcpp::observable<dao::Block>> on_commit() override; | ||
|
||
private: | ||
rxcpp::subjects::subject<rxcpp::observable<dao::Block>> commits_; | ||
}; | ||
} // namespace consensus | ||
} // namespace iroha | ||
|
||
#endif // IROHA_CONSENSUS_SERVICE_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,48 @@ | ||
/** | ||
* 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_ORDERING_SERVICE_HPP | ||
#define IROHA_ORDERING_SERVICE_HPP | ||
|
||
#include <dao/transaction.hpp> | ||
#include <dao/proposal.hpp> | ||
#include <rxcpp/rx-observable.hpp> | ||
|
||
namespace iroha { | ||
namespace ordering { | ||
/** | ||
* Ordering service interface for peer communication service | ||
*/ | ||
class OrderingService { | ||
public: | ||
|
||
/** | ||
* Propagate a signed transaction for further processing | ||
* @param transaction | ||
*/ | ||
virtual void propagate_transaction(dao::Transaction &transaction) = 0; | ||
|
||
/** | ||
* Return observable of all proposals in the consensus | ||
* @return | ||
*/ | ||
virtual rxcpp::observable<dao::Proposal> on_proposal() = 0; | ||
}; | ||
}//namespace ordering | ||
}// namespace iroha | ||
|
||
#endif //IROHA_ORDERING_SERVICE_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* 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 <ordering/ordering_service_stub.hpp> | ||
|
||
namespace iroha { | ||
namespace ordering { | ||
|
||
using dao::Transaction; | ||
using dao::Proposal; | ||
|
||
void OrderingServiceStub::propagate_transaction( | ||
dao::Transaction &transaction) { | ||
std::vector<Transaction> transactions{transaction}; | ||
Proposal proposal(transactions); | ||
proposals_.get_subscriber().on_next(proposal); | ||
} | ||
|
||
rxcpp::observable<dao::Proposal> OrderingServiceStub::on_proposal() { | ||
return proposals_.get_observable(); | ||
} | ||
} // namespace ordering | ||
} // 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,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_ORDERING_SERVICE_STUB_HPP | ||
#define IROHA_ORDERING_SERVICE_STUB_HPP | ||
|
||
#include <ordering/ordering_service.hpp> | ||
|
||
namespace iroha { | ||
namespace ordering { | ||
class OrderingServiceStub : public OrderingService { | ||
public: | ||
void propagate_transaction(dao::Transaction &transaction) override; | ||
rxcpp::observable<dao::Proposal> on_proposal() override; | ||
private: | ||
rxcpp::subjects::subject<dao::Proposal> proposals_; | ||
}; | ||
}//namespace ordering | ||
}// namespace iroha | ||
|
||
#endif //IROHA_ORDERING_SERVICE_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
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