Kagome
Polkadot Runtime Engine in C++17
store_impl.cpp
Go to the documentation of this file.
1 
7 
8 namespace kagome::parachain {
9  bool AvailabilityStoreImpl::hasChunk(const CandidateHash &candidate_hash,
10  ValidatorIndex index) {
11  auto it = per_candidate_.find(candidate_hash);
12  if (it == per_candidate_.end()) {
13  return false;
14  }
15  return it->second.chunks.count(index) != 0;
16  }
17 
18  bool AvailabilityStoreImpl::hasPov(const CandidateHash &candidate_hash) {
19  auto it = per_candidate_.find(candidate_hash);
20  if (it == per_candidate_.end()) {
21  return false;
22  }
23  return it->second.pov.has_value();
24  }
25 
26  bool AvailabilityStoreImpl::hasData(const CandidateHash &candidate_hash) {
27  auto it = per_candidate_.find(candidate_hash);
28  if (it == per_candidate_.end()) {
29  return false;
30  }
31  return it->second.data.has_value();
32  }
33 
34  std::optional<AvailabilityStore::ErasureChunk>
36  ValidatorIndex index) {
37  auto it = per_candidate_.find(candidate_hash);
38  if (it == per_candidate_.end()) {
39  return std::nullopt;
40  }
41  auto it2 = it->second.chunks.find(index);
42  if (it2 == it->second.chunks.end()) {
43  return std::nullopt;
44  }
45  return it2->second;
46  }
47 
48  std::optional<AvailabilityStore::ParachainBlock>
50  auto it = per_candidate_.find(candidate_hash);
51  if (it == per_candidate_.end()) {
52  return std::nullopt;
53  }
54  return it->second.pov;
55  }
56 
57  void AvailabilityStoreImpl::putChunk(const CandidateHash &candidate_hash,
58  const ErasureChunk &chunk) {
59  per_candidate_[candidate_hash].chunks[chunk.index] = chunk;
60  }
61 
62  void AvailabilityStoreImpl::putPov(const CandidateHash &candidate_hash,
63  const ParachainBlock &pov) {
64  per_candidate_[candidate_hash].pov = pov;
65  }
66 
67  void AvailabilityStoreImpl::putData(const CandidateHash &candidate_hash,
68  const PersistedValidationData &data) {
69  per_candidate_[candidate_hash].data = data;
70  }
71 } // namespace kagome::parachain
network::ValidatorIndex ValidatorIndex
Definition: store.hpp:19
primitives::BlockHash CandidateHash
std::unordered_map< CandidateHash, PerCandidate > per_candidate_
Definition: store_impl.hpp:40
bool hasPov(const CandidateHash &candidate_hash) override
Definition: store_impl.cpp:18
void putChunk(const CandidateHash &candidate_hash, const ErasureChunk &chunk) override
Definition: store_impl.cpp:57
bool hasData(const CandidateHash &candidate_hash) override
Definition: store_impl.cpp:26
network::CandidateHash CandidateHash
Definition: store.hpp:18
void putData(const CandidateHash &candidate_hash, const PersistedValidationData &data) override
Definition: store_impl.cpp:67
bool hasChunk(const CandidateHash &candidate_hash, ValidatorIndex index) override
Definition: store_impl.cpp:9
std::optional< ParachainBlock > getPov(const CandidateHash &candidate_hash) override
Definition: store_impl.cpp:49
ValidatorIndex index
The index of this erasure-encoded chunk of data.
A chunk of erasure-encoded block data.
std::optional< ErasureChunk > getChunk(const CandidateHash &candidate_hash, ValidatorIndex index) override
Definition: store_impl.cpp:35
void putPov(const CandidateHash &candidate_hash, const ParachainBlock &pov) override
Definition: store_impl.cpp:62