Line data Source code
1 : /**
2 : * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved.
3 : * http://soramitsu.co.jp
4 : *
5 : * Licensed under the Apache License, Version 2.0 (the "License");
6 : * you may not use this file except in compliance with the License.
7 : * You may obtain a copy of the License at
8 : *
9 : * http://www.apache.org/licenses/LICENSE-2.0
10 : *
11 : * Unless required by applicable law or agreed to in writing, software
12 : * distributed under the License is distributed on an "AS IS" BASIS,
13 : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 : * See the License for the specific language governing permissions and
15 : * limitations under the License.
16 : */
17 :
18 : #ifndef IROHA_SHARED_MODEL_PROPOSAL_HPP
19 : #define IROHA_SHARED_MODEL_PROPOSAL_HPP
20 :
21 : #include "cryptography/default_hash_provider.hpp"
22 : #include "interfaces/base/model_primitive.hpp"
23 : #include "interfaces/common_objects/types.hpp"
24 : #include "interfaces/transaction.hpp"
25 :
26 : namespace shared_model {
27 : namespace interface {
28 :
29 : class Proposal : public ModelPrimitive<Proposal> {
30 : public:
31 : /**
32 : * @return transactions
33 : */
34 : virtual types::TransactionsCollectionType transactions() const = 0;
35 :
36 : /**
37 : * @return the height
38 : */
39 : virtual types::HeightType height() const = 0;
40 :
41 : /**
42 : * @return created time
43 : */
44 : virtual types::TimestampType createdTime() const = 0;
45 :
46 : bool operator==(const Proposal &rhs) const override {
47 0 : return transactions() == rhs.transactions() and height() == rhs.height()
48 0 : and createdTime() == rhs.createdTime();
49 0 : }
50 :
51 : virtual const types::BlobType &blob() const = 0;
52 :
53 : virtual const types::HashType &hash() const = 0;
54 :
55 : std::string toString() const override {
56 0 : return detail::PrettyStringBuilder()
57 0 : .init("Proposal")
58 0 : .append("height", std::to_string(height()))
59 0 : .append("transactions")
60 0 : .appendAll(transactions(),
61 : [](auto &transaction) { return transaction.toString(); })
62 0 : .finalize();
63 0 : }
64 : };
65 :
66 : } // namespace interface
67 : } // namespace shared_model
68 :
69 : #endif // IROHA_SHARED_MODEL_PROPOSAL_HPP
|