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_TX_PRESENCE_CACHE_UTILS_HPP
7 : #define IROHA_TX_PRESENCE_CACHE_UTILS_HPP
8 :
9 : #include "ametsuchi/tx_cache_response.hpp"
10 : #include "common/visitor.hpp"
11 :
12 : namespace iroha {
13 : namespace ametsuchi {
14 : /**
15 : * Determine if transaction was already processed by its status
16 : * @param tx_status - status obtained from transaction cache
17 : * @return true if transaction was committed or rejected
18 : */
19 : inline bool isAlreadyProcessed(
20 : const TxCacheStatusType &tx_status) noexcept {
21 3348 : return iroha::visit_in_place(
22 3312 : tx_status,
23 : [](const ametsuchi::tx_cache_status_responses::Missing &) {
24 3321 : return false;
25 : },
26 : [](const auto &) { return true; });
27 : }
28 :
29 : /**
30 : * Retrieve hash from status
31 : * @param status - transaction status obtained from cache
32 : * @return hash of the transaction
33 : */
34 : inline tx_cache_response_details::HashType getHash(
35 : const TxCacheStatusType &status) noexcept {
36 2 : return iroha::visit_in_place(
37 : status, [](const auto &status) { return status.hash; });
38 : }
39 : } // namespace ametsuchi
40 : } // namespace iroha
41 :
42 : #endif // IROHA_TX_PRESENCE_CACHE_HPP
|