veriblock-pop-cpp
C++11 Libraries for leveraging VeriBlock Proof-Of-Proof blockchain technology.
|
Data structure, that stores in memory all valid payloads (ATV, VTB, VbkBlock) submitted by other peers through p2p or by users through rpc. More...
Definition at line 41 of file mempool.hpp.
#include <mempool.hpp>
Classes | |
struct | SubmitResult |
Result of submission to mempool. More... | |
Public Types | |
enum | Status { VALID = 0 , FAILED_STATEFUL = 1 , FAILED_STATELESS = 2 } |
using | vbk_hash_t = typename VbkBlock::prev_hash_t |
template<typename Payload > | |
using | payload_map = std::unordered_map< typename Payload::id_t, std::shared_ptr< Payload > > |
template<typename Payload > | |
using | payload_value_sorted_map = ValueSortedMap< typename Payload::id_t, std::shared_ptr< Payload > > |
using | vbk_map_t = payload_map< VbkBlock > |
using | atv_map_t = payload_map< ATV > |
using | vtb_map_t = payload_map< VTB > |
using | relations_map_t = payload_map< VbkPayloadsRelations > |
using | vbk_value_sorted_map_t = payload_value_sorted_map< VbkBlock > |
using | vtb_value_sorted_map_t = payload_value_sorted_map< VTB > |
using | atv_value_sorted_map_t = payload_value_sorted_map< ATV > |
Public Member Functions | |
MemPool (AltBlockTree &tree) | |
template<typename T , typename = typename std::enable_if<IsPopPayload<T>::value>::type> | |
VBK_CHECK_RETURN bool | isKnown (const typename T::id_t &id, const bool onlyInMempool=false) const |
Use this method to determine if payload of type T with id id is already known to active chain. More... | |
template<typename T , typename = typename std::enable_if<IsPopPayload<T>::value>::type> | |
VBK_CHECK_RETURN const T * | get (const typename T::id_t &id) const |
getter for payloads stored in mempool More... | |
template<typename T , typename = typename std::enable_if<IsPopPayload<T>::value>::type> | |
VBK_CHECK_RETURN SubmitResult | submit (Slice< const uint8_t > bytes, bool doIsBlockOldCheck, ValidationState &state) |
Add new payload to mempool. More... | |
template<typename T , typename = typename std::enable_if<IsPopPayload<T>::value>::type> | |
VBK_CHECK_RETURN SubmitResult | submit (const T &pl, bool doIsBlockOldCheck, ValidationState &state) |
Add new payload to mempool. More... | |
template<typename T , typename = typename std::enable_if<IsPopPayload<T>::value>::type> | |
VBK_CHECK_RETURN SubmitResult | submit (const std::shared_ptr< T > &pl, bool doIsBlockOldCheck, ValidationState &state) |
Add new payload to mempool. More... | |
std::vector< BtcBlock::hash_t > | getMissingBtcBlocks () const |
VBK_CHECK_RETURN PopData | generatePopData () |
(POW) Miners should execute this to get POP content for "next block". More... | |
VBK_CHECK_RETURN PopData | generatePopData (const std::function< void(const ATV &, const ValidationState &)> &onATV, const std::function< void(const VTB &, const ValidationState &)> &onVTB, const std::function< void(const VbkBlock &, const ValidationState &)> &onVBK) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
void | removeAll (const PopData &popData) |
Remove payloads from mempool by their IDs. More... | |
void | cleanUp () |
Remove paylaods that are statefully invalid anymore (duplicated, staled payloads) | |
void | clear () |
Clear mempool from all payloads. | |
template<typename T , typename = typename std::enable_if<IsPopPayload<T>::value>::type> | |
size_t | onAccepted (std::function< void(const T &p)> f) |
Subscribe on "accepted" event - fires whenever new payload is added into mempool. More... | |
template<> | |
MemPool::SubmitResult | submit (const std::shared_ptr< ATV > &atv, bool doIsBlockOldCheck, ValidationState &state) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
template<> | |
MemPool::SubmitResult | submit (const std::shared_ptr< VTB > &vtb, bool doIsBlockOldCheck, ValidationState &state) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
template<> | |
MemPool::SubmitResult | submit (const std::shared_ptr< VbkBlock > &block, bool doIsBlockOldCheck, ValidationState &state) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
template<> | |
const MemPool::payload_map< VbkBlock > & | getMap () const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
template<> | |
const MemPool::payload_value_sorted_map< VbkBlock > & | getInFlightMap () const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
Public Attributes | |
signals::Signal< void(const ATV &atv)> | on_atv_accepted |
fires when new valid ATV is accepted to mempool More... | |
signals::Signal< void(const VTB &atv)> | on_vtb_accepted |
fires when new valid VTB is accepted to mempool More... | |
signals::Signal< void(const VbkBlock &atv)> | on_vbkblock_accepted |
fires when new valid VbkBlock is accepted to mempool More... | |
using altintegration::MemPool::atv_map_t = payload_map<ATV> |
Definition at line 82 of file mempool.hpp.
using altintegration::MemPool::atv_value_sorted_map_t = payload_value_sorted_map<ATV> |
Definition at line 88 of file mempool.hpp.
using altintegration::MemPool::payload_map = std::unordered_map<typename Payload::id_t, std::shared_ptr<Payload> > |
Definition at line 74 of file mempool.hpp.
using altintegration::MemPool::payload_value_sorted_map = ValueSortedMap<typename Payload::id_t, std::shared_ptr<Payload> > |
Definition at line 78 of file mempool.hpp.
using altintegration::MemPool::relations_map_t = payload_map<VbkPayloadsRelations> |
Definition at line 84 of file mempool.hpp.
using altintegration::MemPool::vbk_hash_t = typename VbkBlock::prev_hash_t |
Definition at line 71 of file mempool.hpp.
using altintegration::MemPool::vbk_map_t = payload_map<VbkBlock> |
Definition at line 81 of file mempool.hpp.
using altintegration::MemPool::vbk_value_sorted_map_t = payload_value_sorted_map<VbkBlock> |
Definition at line 86 of file mempool.hpp.
using altintegration::MemPool::vtb_map_t = payload_map<VTB> |
Definition at line 83 of file mempool.hpp.
using altintegration::MemPool::vtb_value_sorted_map_t = payload_value_sorted_map<VTB> |
Definition at line 87 of file mempool.hpp.
enum altintegration::MemPool::Status |
Definition at line 42 of file mempool.hpp.
VBK_CHECK_RETURN PopData altintegration::MemPool::generatePopData | ( | ) |
VBK_CHECK_RETURN PopData altintegration::MemPool::generatePopData | ( | const std::function< void(const ATV &, const ValidationState &)> & | onATV, |
const std::function< void(const VTB &, const ValidationState &)> & | onVTB, | ||
const std::function< void(const VbkBlock &, const ValidationState &)> & | onVBK | ||
) |
|
inline |
Definition at line 155 of file mempool.hpp.
|
inline |
[in] | id | payload id |
[in] | onlyInMempool | if true, blockchain won't be searched for "known" payloads. |
Definition at line 104 of file mempool.hpp.
|
inline |
f | callback |
Definition at line 329 of file mempool.hpp.
void altintegration::MemPool::removeAll | ( | const PopData & | popData | ) |
Use it when new block arrives and it contains PopData. Doing this, mempool also executes clean() method.
[in] | popData | altintegration::PopData |
|
inline |
Does stateless validation, and conditionally contextual validation.
[in] | pl | payload |
[in] | doIsBlockOldCheck | flag |
[out] | state | validation state |
Definition at line 249 of file mempool.hpp.
|
inline |
Does stateless validation, and conditionally contextual validation.
[in] | pl | payload |
[in] | doIsBlockOldCheck | flag |
[out] | state | validation state validation |
Definition at line 224 of file mempool.hpp.
|
inline |
Does stateless validation, and conditionally contextual validation.
[in] | bytes | payload`s bytes |
[in] | doIsBlockOldCheck | flag |
[out] | state | validation state validation |
Definition at line 191 of file mempool.hpp.
signals::Signal<void(const ATV& atv)> altintegration::MemPool::on_atv_accepted |
Definition at line 335 of file mempool.hpp.
signals::Signal<void(const VbkBlock& atv)> altintegration::MemPool::on_vbkblock_accepted |
Definition at line 339 of file mempool.hpp.
signals::Signal<void(const VTB& atv)> altintegration::MemPool::on_vtb_accepted |
Definition at line 337 of file mempool.hpp.