veriblock-pop-cpp
C++11 Libraries for leveraging VeriBlock Proof-Of-Proof blockchain technology.
altintegration::FinalizedPayloadsIndex< ContainerIndex > Struct Template Reference

Stores a mapping "payload id -> containing block" hash of payloads that are stored in finalized blocks. More...

Detailed Description

template<typename ContainerIndex>
struct altintegration::FinalizedPayloadsIndex< ContainerIndex >
Invariant
KV are never removed from this index.

Definition at line 17 of file payloads_index.hpp.

#include <payloads_index.hpp>

+ Inheritance diagram for altintegration::FinalizedPayloadsIndex< ContainerIndex >:
+ Collaboration diagram for altintegration::FinalizedPayloadsIndex< ContainerIndex >:

Public Types

using index_t = ContainerIndex
 
using hash_t = typename ContainerIndex::hash_t
 
using payload_id = std::vector< uint8_t >
 

Public Member Functions

const hash_t * find (const payload_id &pid) const
 
bool empty () const
 
size_t size () const
 
void add (const payload_id &pid, const hash_t &hash)
 
void remove (const payload_id &pid)
 
void addBlock (const index_t &block)
 
const std::unordered_map< payload_id, hash_t > & getAll () const
 

Member Typedef Documentation

◆ hash_t

template<typename ContainerIndex >
using altintegration::FinalizedPayloadsIndex< ContainerIndex >::hash_t = typename ContainerIndex::hash_t

Definition at line 19 of file payloads_index.hpp.

◆ index_t

template<typename ContainerIndex >
using altintegration::FinalizedPayloadsIndex< ContainerIndex >::index_t = ContainerIndex

Definition at line 18 of file payloads_index.hpp.

◆ payload_id

template<typename ContainerIndex >
using altintegration::FinalizedPayloadsIndex< ContainerIndex >::payload_id = std::vector<uint8_t>

Definition at line 20 of file payloads_index.hpp.

Member Function Documentation

◆ add()

template<typename ContainerIndex >
void altintegration::FinalizedPayloadsIndex< ContainerIndex >::add ( const payload_id &  pid,
const hash_t &  hash 
)
inline

Definition at line 35 of file payloads_index.hpp.

35 {
36 auto it = map_.find(pid);
37 VBK_ASSERT(it == map_.end());
38 map_.insert(std::make_pair(pid, hash));
39 }

◆ addBlock()

template<typename ContainerIndex >
void altintegration::FinalizedPayloadsIndex< ContainerIndex >::addBlock ( const index_t &  block)
inline

Definition at line 47 of file payloads_index.hpp.

47 {
48 // in FinalizedPayloadsIndex we can add only finalized payloads!
49 VBK_ASSERT_MSG(block.finalized, block.toPrettyString());
50 detail::PLIAddBlock(*this, block);
51 }

◆ empty()

template<typename ContainerIndex >
bool altintegration::FinalizedPayloadsIndex< ContainerIndex >::empty ( ) const
inline

Definition at line 31 of file payloads_index.hpp.

31{ return map_.empty(); }

◆ find()

template<typename ContainerIndex >
const hash_t * altintegration::FinalizedPayloadsIndex< ContainerIndex >::find ( const payload_id &  pid) const
inline

Definition at line 22 of file payloads_index.hpp.

22 {
23 auto it = map_.find(pid);
24 if (it == map_.end()) {
25 return nullptr;
26 }
27
28 return &it->second;
29 }

◆ getAll()

template<typename ContainerIndex >
const std::unordered_map< payload_id, hash_t > & altintegration::FinalizedPayloadsIndex< ContainerIndex >::getAll ( ) const
inline

Definition at line 53 of file payloads_index.hpp.

53{ return map_; }

◆ remove()

template<typename ContainerIndex >
void altintegration::FinalizedPayloadsIndex< ContainerIndex >::remove ( const payload_id &  pid)
inline

Definition at line 41 of file payloads_index.hpp.

41 {
42 auto it = map_.find(pid);
43 VBK_ASSERT(it != map_.end());
44 map_.erase(pid);
45 }

◆ size()

template<typename ContainerIndex >
size_t altintegration::FinalizedPayloadsIndex< ContainerIndex >::size ( ) const
inline

Definition at line 33 of file payloads_index.hpp.

33{ return map_.size(); }

The documentation for this struct was generated from the following file: