Non-owning partial chain view similar to std::span.
More...
template<typename BlockIndexT>
struct altintegration::ChainSlice< BlockIndexT >
API-compatible with Chain.
- Template Parameters
-
Definition at line 20 of file chain_slice.hpp.
#include <chain_slice.hpp>
◆ block_t
template<typename BlockIndexT >
◆ chain_t
template<typename BlockIndexT >
◆ const_iterator_t
template<typename BlockIndexT >
◆ const_reverse_iterator_t
template<typename BlockIndexT >
◆ hash_t
template<typename BlockIndexT >
◆ height_t
template<typename BlockIndexT >
◆ index_t
template<typename BlockIndexT >
◆ ChainSlice() [1/3]
template<typename BlockIndexT >
Definition at line 30 of file chain_slice.hpp.
30: ChainSlice(chain, chain.firstHeight()) {}
◆ ChainSlice() [2/3]
template<typename BlockIndexT >
Definition at line 32 of file chain_slice.hpp.
33 : ChainSlice(chain,
34 firstHeight,
35 chain.firstHeight() + chain.blocksCount() - firstHeight) {}
◆ ChainSlice() [3/3]
template<typename BlockIndexT >
Definition at line 37 of file chain_slice.hpp.
38 : chain_(chain), firstHeight_(firstHeight), size_(size) {
39 VBK_ASSERT(firstHeight >= chain.firstHeight());
40 VBK_ASSERT(firstHeight + size <= chain.firstHeight() + chain.blocksCount());
41 }
◆ begin()
template<typename BlockIndexT >
Definition at line 85 of file chain_slice.hpp.
85{ return chain_.begin() + firstOffset(); }
◆ blocksCount()
template<typename BlockIndexT >
◆ chainHeight()
template<typename BlockIndexT >
◆ contains()
template<typename BlockIndexT >
Definition at line 46 of file chain_slice.hpp.
46 {
47 return index != nullptr && this->operator[](index->getHeight()) == index;
48 }
◆ empty()
template<typename BlockIndexT >
◆ end()
template<typename BlockIndexT >
Definition at line 86 of file chain_slice.hpp.
86{ return chain_.end() - tipOffset(); }
◆ first()
template<typename BlockIndexT >
Definition at line 73 of file chain_slice.hpp.
73{ return empty() ? nullptr : chain_[firstHeight()]; }
◆ firstHeight()
template<typename BlockIndexT >
◆ firstOffset()
template<typename BlockIndexT >
Definition at line 75 of file chain_slice.hpp.
75{ return firstHeight() - chain_.firstHeight(); }
◆ getStartHeight()
template<typename BlockIndexT >
◆ next()
template<typename BlockIndexT >
Definition at line 55 of file chain_slice.hpp.
55 {
56 return !contains(index) ? nullptr : (*this)[index->getHeight() + 1];
57 }
◆ operator[]()
template<typename BlockIndexT >
Definition at line 50 of file chain_slice.hpp.
50 {
51 return height < firstHeight() || height > tipHeight() ? nullptr
52 : chain_[height];
53 }
◆ rbegin()
template<typename BlockIndexT >
Definition at line 78 of file chain_slice.hpp.
78 {
79 return chain_.rbegin() + tipOffset();
80 }
◆ rend()
template<typename BlockIndexT >
Definition at line 81 of file chain_slice.hpp.
81 {
82 return chain_.rend() - firstOffset();
83 }
◆ size()
template<typename BlockIndexT >
◆ tip()
template<typename BlockIndexT >
Definition at line 72 of file chain_slice.hpp.
72{ return empty() ? nullptr : chain_[tipHeight()]; }
◆ tipHeight()
template<typename BlockIndexT >
Definition at line 61 of file chain_slice.hpp.
61{ return (int)(firstHeight() + size()) - 1; }
◆ tipOffset()
template<typename BlockIndexT >
Definition at line 76 of file chain_slice.hpp.
76{ return chain_.chainHeight() - tipHeight(); }
◆ operator!=
template<typename BlockIndexT >
◆ operator==
template<typename BlockIndexT >
Definition at line 88 of file chain_slice.hpp.
88 {
89
90 if (a.empty() != b.empty()) return false;
91
92 if (a.empty()) return true;
93 return a.tip()->getHash() == b.tip()->getHash();
94 }
The documentation for this struct was generated from the following file: