hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
utils.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_VALIDATION_UTILS
7 #define IROHA_VALIDATION_UTILS
8 
9 #include <string>
10 #include <vector>
11 
12 #include <boost/range/adaptor/transformed.hpp>
13 #include <boost/range/any_range.hpp>
14 
17 
18 namespace iroha {
19  namespace validation {
27  inline bool signaturesSubset(
29  const boost::any_range<shared_model::crypto::PublicKey,
30  boost::forward_traversal_tag> &public_keys) {
31  return std::all_of(
32  signatures.begin(),
33  signatures.end(),
34  [&public_keys](const auto &signature) {
35  return std::find_if(public_keys.begin(),
36  public_keys.end(),
37  [&signature](const auto &public_key) {
38  return signature.publicKey() == public_key;
39  })
40  != public_keys.end();
41  });
42  }
43 
50  template <typename Peers>
51  inline bool peersSubset(
53  const Peers &peers) {
54  return signaturesSubset(signatures,
55  peers
56  | boost::adaptors::transformed(
57  [](const auto &p) -> decltype(auto) {
58  return p->pubkey();
59  }));
60  }
61 
62  } // namespace validation
63 } // namespace iroha
64 
65 #endif // IROHA_VALIDATION_UTILS
bool signaturesSubset(const shared_model::interface::types::SignatureRangeType &signatures, const boost::any_range< shared_model::crypto::PublicKey, boost::forward_traversal_tag > &public_keys)
Definition: utils.hpp:27
bool peersSubset(const shared_model::interface::types::SignatureRangeType &signatures, const Peers &peers)
Definition: utils.hpp:51
boost::any_range< interface::Signature, boost::forward_traversal_tag, const Signature & > SignatureRangeType
Type of signature range, which returns when signatures are invoked.
Definition: range_types.hpp:24
Definition: block_query.hpp:16
Definition: public_key.hpp:16