veriblock-pop-cpp
C++11 Libraries for leveraging VeriBlock Proof-Of-Proof blockchain technology.
altintegration::adaptors::BlockReaderImpl Struct Reference

Detailed Description

Definition at line 143 of file block_provider_impl.hpp.

+ Inheritance diagram for altintegration::adaptors::BlockReaderImpl:
+ Collaboration diagram for altintegration::adaptors::BlockReaderImpl:

Public Member Functions

 BlockReaderImpl (Storage &storage, const AltChainParams &params)
 
bool getAltTip (AltBlock::hash_t &out) const override
 
bool getVbkTip (VbkBlock::hash_t &out) const override
 
bool getBtcTip (BtcBlock::hash_t &out) const override
 
bool getBlock (const AltBlock::prev_hash_t &hash, StoredBlockIndex< AltBlock > &out) const override
 
bool getBlock (const VbkBlock::prev_hash_t &hash, StoredBlockIndex< VbkBlock > &out) const override
 
bool getBlock (const BtcBlock::prev_hash_t &hash, StoredBlockIndex< BtcBlock > &out) const override
 
std::shared_ptr< BlockIterator< AltBlock > > getAltBlockIterator () const override
 
std::shared_ptr< BlockIterator< VbkBlock > > getVbkBlockIterator () const override
 
std::shared_ptr< BlockIterator< BtcBlock > > getBtcBlockIterator () const override
 
- Public Member Functions inherited from altintegration::BlockReader
virtual bool getAltTip (AltBlock::hash_t &out) const =0
 
virtual bool getVbkTip (VbkBlock::hash_t &out) const =0
 
virtual bool getBtcTip (BtcBlock::hash_t &out) const =0
 
virtual bool getBlock (const AltBlock::prev_hash_t &hash, StoredBlockIndex< AltBlock > &out) const =0
 
virtual bool getBlock (const VbkBlock::prev_hash_t &hash, StoredBlockIndex< VbkBlock > &out) const =0
 
virtual bool getBlock (const BtcBlock::prev_hash_t &hash, StoredBlockIndex< BtcBlock > &out) const =0
 
virtual std::shared_ptr< BlockIterator< AltBlock > > getAltBlockIterator () const =0
 
virtual std::shared_ptr< BlockIterator< VbkBlock > > getVbkBlockIterator () const =0
 
virtual std::shared_ptr< BlockIterator< BtcBlock > > getBtcBlockIterator () const =0
 
template<typename Block >
std::shared_ptr< BlockIterator< Block > > getBlockIterator () const
 
template<typename Block >
bool getTip (typename Block::hash_t &out) const
 
template<>
std::shared_ptr< BlockIterator< AltBlock > > getBlockIterator () const
 
template<>
bool getTip (AltBlock::hash_t &out) const
 
template<>
bool getTip (VbkBlock::hash_t &out) const
 
template<>
bool getTip (BtcBlock::hash_t &out) const
 

Constructor & Destructor Documentation

◆ BlockReaderImpl()

altintegration::adaptors::BlockReaderImpl::BlockReaderImpl ( Storage storage,
const AltChainParams params 
)
inline

Definition at line 146 of file block_provider_impl.hpp.

147 : storage_(storage), params_(params) {}

Member Function Documentation

◆ getAltBlockIterator()

std::shared_ptr< BlockIterator< AltBlock > > altintegration::adaptors::BlockReaderImpl::getAltBlockIterator ( ) const
inlineoverridevirtual

Implements altintegration::BlockReader.

Definition at line 189 of file block_provider_impl.hpp.

190 {
191 return std::make_shared<BlockIteratorImpl<AltBlock>>(
192 storage_.generateIterator(), params_);
193 }

◆ getAltTip()

bool altintegration::adaptors::BlockReaderImpl::getAltTip ( AltBlock::hash_t &  out) const
inlineoverridevirtual

Implements altintegration::BlockReader.

Definition at line 149 of file block_provider_impl.hpp.

149 {
150 std::vector<uint8_t> bytes_out;
151 if (!storage_.read(tip_key<AltBlock>(), bytes_out)) {
152 return false;
153 }
154 out = bytes_out;
155 return true;
156 }

◆ getBlock() [1/3]

bool altintegration::adaptors::BlockReaderImpl::getBlock ( const AltBlock::prev_hash_t &  hash,
StoredBlockIndex< AltBlock > &  out 
) const
inlineoverridevirtual

Implements altintegration::BlockReader.

Definition at line 174 of file block_provider_impl.hpp.

175 {
176 return getBlock<AltBlock>(hash, out);
177 }

◆ getBlock() [2/3]

bool altintegration::adaptors::BlockReaderImpl::getBlock ( const BtcBlock::prev_hash_t hash,
StoredBlockIndex< BtcBlock > &  out 
) const
inlineoverridevirtual

Implements altintegration::BlockReader.

Definition at line 184 of file block_provider_impl.hpp.

185 {
186 return getBlock<BtcBlock>(hash, out);
187 }

◆ getBlock() [3/3]

bool altintegration::adaptors::BlockReaderImpl::getBlock ( const VbkBlock::prev_hash_t hash,
StoredBlockIndex< VbkBlock > &  out 
) const
inlineoverridevirtual

Implements altintegration::BlockReader.

Definition at line 179 of file block_provider_impl.hpp.

180 {
181 return getBlock<VbkBlock>(hash, out);
182 }

◆ getBtcBlockIterator()

std::shared_ptr< BlockIterator< BtcBlock > > altintegration::adaptors::BlockReaderImpl::getBtcBlockIterator ( ) const
inlineoverridevirtual

Implements altintegration::BlockReader.

Definition at line 199 of file block_provider_impl.hpp.

200 {
201 return std::make_shared<BlockIteratorImpl<BtcBlock>>(
202 storage_.generateIterator(), params_);
203 }

◆ getBtcTip()

bool altintegration::adaptors::BlockReaderImpl::getBtcTip ( BtcBlock::hash_t out) const
inlineoverridevirtual

Implements altintegration::BlockReader.

Definition at line 165 of file block_provider_impl.hpp.

165 {
166 std::vector<uint8_t> bytes_out;
167 if (!storage_.read(tip_key<BtcBlock>(), bytes_out)) {
168 return false;
169 }
170 out = bytes_out;
171 return true;
172 }

◆ getVbkBlockIterator()

std::shared_ptr< BlockIterator< VbkBlock > > altintegration::adaptors::BlockReaderImpl::getVbkBlockIterator ( ) const
inlineoverridevirtual

Implements altintegration::BlockReader.

Definition at line 194 of file block_provider_impl.hpp.

195 {
196 return std::make_shared<BlockIteratorImpl<VbkBlock>>(
197 storage_.generateIterator(), params_);
198 }

◆ getVbkTip()

bool altintegration::adaptors::BlockReaderImpl::getVbkTip ( VbkBlock::hash_t out) const
inlineoverridevirtual

Implements altintegration::BlockReader.

Definition at line 157 of file block_provider_impl.hpp.

157 {
158 std::vector<uint8_t> bytes_out;
159 if (!storage_.read(tip_key<VbkBlock>(), bytes_out)) {
160 return false;
161 }
162 out = bytes_out;
163 return true;
164 }

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