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

Main entrypoint into the veriblock-pop library. More...

Detailed Description

Definition at line 27 of file pop_context.hpp.

#include <pop_context.hpp>

+ Collaboration diagram for altintegration::PopContext:

Public Member Functions

 PopContext (const PopContext &)=delete
 
PopContextoperator= (const PopContext &)=delete
 
 PopContext (PopContext &&)=default
 
PopContextoperator= (PopContext &&)=default
 
VBK_CHECK_RETURN bool check (const ATV &payload, ValidationState &state)
 Checks ATV (stateless check). More...
 
VBK_CHECK_RETURN bool check (const VTB &payload, ValidationState &state)
 Checks VTB (stateless check). More...
 
VBK_CHECK_RETURN bool check (const VbkBlock &payload, ValidationState &state)
 Checks VbkBlock (stateless check). More...
 
VBK_CHECK_RETURN bool check (const PopData &payload, ValidationState &state)
 Checks PopData (stateless check). More...
 
void saveAllTrees (BlockBatch &batch) const
 Save ALT/VBK/BTC trees on disk via adapter BlockBatch. More...
 
VBK_CHECK_RETURN bool loadAllTrees (bool fast_load, ValidationState &state)
 Load ALT/VBK/BTC trees from disk via adapter BlockReader. More...
 
VBK_CHECK_RETURN bool getPopPayout (const AltBlockTree::hash_t &prev, PopPayouts &rewards, ValidationState &state)
 Calculates POP rewards that should be paid in the next block after prev. More...
 
VBK_CHECK_RETURN PopData generatePopData ()
 Generate PopData for the block next to the current tip. More...
 
VBK_CHECK_RETURN bool generatePublicationData (PublicationData &output, const std::vector< uint8_t > &endorsedBlockHeader, const std::vector< uint8_t > &txMerkleRoot, const PopData &popData, const std::vector< uint8_t > &payoutInfo)
 Create PublicationData given required input parameters. More...
 
VBK_CHECK_RETURN const ConfiggetConfig () const
 
VBK_CHECK_RETURN MemPoolgetMemPool ()
 
VBK_CHECK_RETURN AltBlockTreegetAltBlockTree ()
 
VBK_CHECK_RETURN const AltBlockTreegetAltBlockTree () const
 
VBK_CHECK_RETURN const VbkBlockTreegetVbkBlockTree () const
 
VBK_CHECK_RETURN const BtcBlockTreegetBtcBlockTree () const
 
void shutdown ()
 stops PopContext internal thread pool used for stateless validation.
 

Static Public Member Functions

static std::shared_ptr< PopContextcreate (std::shared_ptr< Config > config, std::shared_ptr< PayloadsStorage > payloadsProvider, std::shared_ptr< BlockReader > blockProvider, std::unique_ptr< EthashCache > ethashCache, std::unique_ptr< ProgpowHeaderCache > progpowHeaderCache, size_t validatorWorkers=0)
 Factory function for PopContext. More...
 

Member Function Documentation

◆ check() [1/4]

VBK_CHECK_RETURN bool altintegration::PopContext::check ( const ATV payload,
ValidationState state 
)
Parameters
[in]payloadATV to be checked
[out]state
Returns
true if ATV is statelessly valid, false otherwise

◆ check() [2/4]

VBK_CHECK_RETURN bool altintegration::PopContext::check ( const PopData payload,
ValidationState state 
)
Parameters
[in]payloadPopData to be checked
[out]state
Returns
true if PopData is statelessly valid, false otherwise

◆ check() [3/4]

VBK_CHECK_RETURN bool altintegration::PopContext::check ( const VbkBlock payload,
ValidationState state 
)
Parameters
[in]payloadVbkBlock to be checked
[out]state
Returns
true if VbkBlock is statelessly valid, false otherwise

◆ check() [4/4]

VBK_CHECK_RETURN bool altintegration::PopContext::check ( const VTB payload,
ValidationState state 
)
Parameters
[in]payloadVTB to be checked
[out]state
Returns
true if VTB is statelessly valid, false otherwise

◆ create()

static std::shared_ptr< PopContext > altintegration::PopContext::create ( std::shared_ptr< Config config,
std::shared_ptr< PayloadsStorage payloadsProvider,
std::shared_ptr< BlockReader blockProvider,
std::unique_ptr< EthashCache ethashCache,
std::unique_ptr< ProgpowHeaderCache progpowHeaderCache,
size_t  validatorWorkers = 0 
)
static
Parameters
[in]config
[in]payloadsProvider
[in]blockProvider
[in]ethashCache
[in]progpowHeaderCache
[in]validatorWorkers
Returns

◆ generatePopData()

VBK_CHECK_RETURN PopData altintegration::PopContext::generatePopData ( )
Returns
empty or non-empty PopData instance that must be inserted into next block body.

◆ generatePublicationData()

VBK_CHECK_RETURN bool altintegration::PopContext::generatePublicationData ( PublicationData output,
const std::vector< uint8_t > &  endorsedBlockHeader,
const std::vector< uint8_t > &  txMerkleRoot,
const PopData popData,
const std::vector< uint8_t > &  payoutInfo 
)
Parameters
[out]outputgenerated publication data output. Valid only if this func returned true.
[in]endorsedBlockHeaderserialized altchain header of endorsed block (for BTC it is 80 bytes).
[in]txMerkleRoottransaction merkle root (used original merkle root value from the block header).
[in]popDatapopData that is stored in endorsed block.
[in]payoutInfobytes that will then be interpreted by altchain as payout information (for BTC can be a script...).
Returns
true if endorsed block exists, false otherwise.

◆ getPopPayout()

VBK_CHECK_RETURN bool altintegration::PopContext::getPopPayout ( const AltBlockTree::hash_t &  prev,
PopPayouts rewards,
ValidationState state 
)
Parameters
[in]prevAltchain has to supply prev block of a block that will contain POP reward.
[out]rewardsa map where key=payoutInfo from PublicationData, value=amount to be paid.
[out]statevalidation state.
Returns
true if rewards are obtained; false otherwise.

◆ loadAllTrees()

VBK_CHECK_RETURN bool altintegration::PopContext::loadAllTrees ( bool  fast_load,
ValidationState state 
)
Parameters
[in]fast_loadflag
[out]statevalidation state

◆ saveAllTrees()

void altintegration::PopContext::saveAllTrees ( BlockBatch batch) const
Parameters
[out]batchadaptor for writing blocks on disk.

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