Line data Source code
1 : /*
2 : Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved.
3 :
4 : Licensed under the Apache License, Version 2.0 (the "License");
5 : you may not use this file except in compliance with the License.
6 : You may obtain a copy of the License at
7 :
8 : http://www.apache.org/licenses/LICENSE-2.0
9 :
10 : Unless required by applicable law or agreed to in writing, software
11 : distributed under the License is distributed on an "AS IS" BASIS,
12 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 : See the License for the specific language governing permissions and
14 : limitations under the License.
15 : */
16 :
17 : #include "network/impl/peer_communication_service_impl.hpp"
18 :
19 : #include "interfaces/iroha_internal/transaction_batch.hpp"
20 :
21 : namespace iroha {
22 : namespace network {
23 : PeerCommunicationServiceImpl::PeerCommunicationServiceImpl(
24 : std::shared_ptr<OrderingGate> ordering_gate,
25 : std::shared_ptr<synchronizer::Synchronizer> synchronizer,
26 : std::shared_ptr<iroha::simulator::VerifiedProposalCreator>
27 : proposal_creator)
28 245 : : ordering_gate_(std::move(ordering_gate)),
29 245 : synchronizer_(std::move(synchronizer)),
30 245 : proposal_creator_(std::move(proposal_creator)) {
31 245 : log_ = logger::log("PCS");
32 245 : }
33 :
34 : void PeerCommunicationServiceImpl::propagate_batch(
35 : std::shared_ptr<shared_model::interface::TransactionBatch> batch)
36 : const {
37 718 : log_->info("propagate batch");
38 718 : ordering_gate_->propagateBatch(batch);
39 718 : }
40 :
41 : rxcpp::observable<std::shared_ptr<shared_model::interface::Proposal>>
42 : PeerCommunicationServiceImpl::on_proposal() const {
43 490 : return ordering_gate_->on_proposal();
44 0 : }
45 :
46 : rxcpp::observable<
47 : std::shared_ptr<iroha::validation::VerifiedProposalAndErrors>>
48 : PeerCommunicationServiceImpl::on_verified_proposal() const {
49 490 : return proposal_creator_->on_verified_proposal();
50 0 : }
51 :
52 : rxcpp::observable<synchronizer::SynchronizationEvent>
53 : PeerCommunicationServiceImpl::on_commit() const {
54 980 : return synchronizer_->on_commit_chain();
55 0 : }
56 : } // namespace network
57 : } // namespace iroha
|