Line data Source code
1 : /**
2 : * Copyright Soramitsu Co., Ltd. All Rights Reserved.
3 : * SPDX-License-Identifier: Apache-2.0
4 : */
5 :
6 : #ifndef IROHA_PB_COMMON_HPP
7 : #define IROHA_PB_COMMON_HPP
8 :
9 : #include "commands.pb.h"
10 : #include "cryptography/ed25519_sha3_impl/internal/sha3_hash.hpp"
11 : #include "model/account.hpp"
12 : #include "model/account_asset.hpp"
13 : #include "model/asset.hpp"
14 : #include "model/domain.hpp"
15 : #include "model/peer.hpp"
16 : #include "model/signature.hpp"
17 : #include "qry_responses.pb.h"
18 :
19 : namespace iroha {
20 : namespace model {
21 : namespace converters {
22 : // peer
23 : protocol::Peer serializePeer(iroha::model::Peer iroha_peer);
24 : iroha::model::Peer deserializePeer(protocol::Peer pb_peer);
25 :
26 : iroha::protocol::Account serializeAccount(
27 : const iroha::model::Account &account);
28 : iroha::protocol::Asset serializeAsset(const iroha::model::Asset &asset);
29 : iroha::protocol::AccountAsset serializeAccountAsset(
30 : const iroha::model::AccountAsset &account_asset);
31 : iroha::protocol::Domain serializeDomain(
32 : const iroha::model::Domain &domain);
33 : } // namespace converters
34 : } // namespace model
35 :
36 : /**
37 : * Calculate hash from protobuf model object
38 : * @tparam T - protobuf model type
39 : * @param pb - protobuf model object
40 : * @return hash of object payload
41 : */
42 : template <typename T>
43 : hash256_t hash(const T &pb) {
44 40 : return sha3_256(pb.payload().SerializeAsString());
45 0 : }
46 : } // namespace iroha
47 :
48 : #endif // IROHA_PB_COMMON_HPP
|