|
veriblock-pop-cpp
C++11 Libraries for leveraging VeriBlock Proof-Of-Proof blockchain technology.
|
BlockTree is a tree of blocks with single "bootstrap" block as root. More...
| Block |
Definition at line 30 of file blocktree.hpp.
#include <blocktree.hpp>
Inheritance diagram for altintegration::BlockTree< Block, ChainParams >:
Collaboration diagram for altintegration::BlockTree< Block, ChainParams >:Public Types | |
| using | base = BaseBlockTree< Block > |
| using | block_t = Block |
| using | params_t = ChainParams |
| using | index_t = typename base::index_t |
| using | stored_index_t = typename base::stored_index_t |
| using | hash_t = typename Block::hash_t |
| using | prev_block_hash_t = typename Block::prev_hash_t |
| using | height_t = typename Block::height_t |
Public Types inherited from altintegration::BaseBlockTree< Block > | |
| using | block_t = Block |
| using | block_height_t = typename block_t::height_t |
| using | hash_t = typename Block::hash_t |
| using | prev_block_hash_t = typename Block::prev_hash_t |
| using | index_t = BlockIndex< Block > |
| using | stored_index_t = StoredBlockIndex< Block > |
| using | on_invalidate_t = void(const index_t &) |
| using | block_index_t = std::unordered_map< prev_block_hash_t, std::unique_ptr< index_t > > |
Public Member Functions | |
| BlockTree (const ChainParams ¶m, const BlockReader &blockProvider) | |
| const ChainParams & | getParams () const |
| virtual void | bootstrapWithGenesis (const block_t &block) |
| Bootstrap blockchain with a single genesis block. More... | |
| virtual void | bootstrapWithChain (height_t startHeight, const std::vector< block_t > &chain) |
| Bootstrap network with a chain that starts at 'startHeight'. More... | |
| bool | acceptBlockHeader (const block_t &block, ValidationState &state) |
| bool | acceptBlockHeader (const std::shared_ptr< block_t > &block, ValidationState &state) |
| std::string | toPrettyString (size_t level=0) const |
| bool | loadBlockForward (const stored_index_t &index, bool fast_load, ValidationState &state) override |
| bool | isBlockOld (height_t height) const |
| block is considered old if it is behind current tip further than 'old blocks window' blocks More... | |
| bool | isBlockOld (const hash_t &hash) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
| void | finalizeBlocks () |
Public Member Functions inherited from altintegration::BaseBlockTree< Block > | |
| const std::unordered_set< index_t * > & | getTips () const |
| std::vector< index_t * > | getBlocks () const |
| std::vector< index_t * > | getAllBlocks () const |
| const BlockReader & | getBlockProvider () const |
| BaseBlockTree (const BlockReader &blockProvider) | |
| BaseBlockTree (const BaseBlockTree &)=delete | |
| BaseBlockTree & | operator= (const BaseBlockTree &)=delete |
| BaseBlockTree (BaseBlockTree &&)=default | |
| BaseBlockTree & | operator= (BaseBlockTree &&)=default |
| const Chain< index_t > & | getBestChain () const |
| Getter for currently Active Chain. More... | |
| template<typename T > | |
| prev_block_hash_t | makePrevHash (const T &h) const |
| template<typename T , typename = typename std::enable_if< std::is_same<T, hash_t>::value || std::is_same<T, prev_block_hash_t>::value>::type> | |
| index_t * | getBlockIndex (const T &hash) |
| Get BlockIndex by block hash. More... | |
| template<typename T , typename = typename std::enable_if< std::is_same<T, hash_t>::value || std::is_same<T, prev_block_hash_t>::value>::type> | |
| const index_t * | getBlockIndex (const T &hash) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
| template<typename T , typename = typename std::enable_if< std::is_same<T, hash_t>::value || std::is_same<T, prev_block_hash_t>::value>::type> | |
| index_t * | findBlockIndex (const T &hash) |
| Get BlockIndex by block hash. More... | |
| template<typename T , typename = typename std::enable_if< std::is_same<T, hash_t>::value || std::is_same<T, prev_block_hash_t>::value>::type> | |
| const index_t * | findBlockIndex (const T &hash) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
| virtual bool | loadTip (const hash_t &hash, ValidationState &state) |
| virtual bool | loadBlockForward (const stored_index_t &index, bool fast_load, ValidationState &state) |
| Efficiently connects BlockIndex to this tree as a leaf, when it is loaded from disk. More... | |
| void | removeSubtree (index_t &toRemove) |
| Removes block and all its successors. More... | |
| void | removeSubtree (const hash_t &toRemove) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
| void | removeLeaf (index_t &toRemove) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
| void | invalidateSubtree (index_t &toBeInvalidated, enum BlockValidityStatus reason, bool shouldDetermineBestChain=true) |
| Mark given block as invalid. More... | |
| void | invalidateSubtree (const hash_t &toBeInvalidated, enum BlockValidityStatus reason, bool shouldDetermineBestChain=true) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
| void | revalidateSubtree (const hash_t &hash, enum BlockValidityStatus reason, bool shouldDetermineBestChain=true) |
| void | revalidateSubtree (index_t &toBeValidated, enum BlockValidityStatus reason, bool shouldDetermineBestChain=true) |
| bool | isBootstrapped () const |
| Check if the blockchain is bootstrapped. More... | |
| virtual bool | setState (const hash_t &block, ValidationState &state) |
| virtual bool | setState (index_t &index, ValidationState &) |
| virtual void | overrideTip (index_t &to) |
| index_t & | getRoot () const |
| const FinalizedPayloadsIndex< index_t > & | getFinalizedPayloadsIndex () const |
| const PayloadsIndex< index_t > & | getPayloadsIndex () const |
| DeferForkResolutionGuard | deferForkResolutionGuard () |
| BaseBlockTree< VbkBlock >::prev_block_hash_t | makePrevHash (const hash_t &h) const |
| HACK: getBlockIndex accepts either hash_t or prev_block_hash_t then, depending on what it received, it should do trim LE on full hash to receive short hash, which is stored inside a map. More... | |
Protected Member Functions | |
| bool | acceptBlockHeaderImpl (const std::shared_ptr< block_t > &block, ValidationState &state, bool shouldContextuallyCheck) |
| void | bootstrap (height_t height, const block_t &block, ValidationState &state) |
| void | bootstrap (height_t height, std::shared_ptr< block_t > block, ValidationState &state) |
| bool | validateAndAddBlock (const std::shared_ptr< block_t > &block, ValidationState &state, bool shouldContextuallyCheck, index_t **ret) |
| void | determineBestChain (index_t &candidate, ValidationState &state) override |
| void | onBlockInserted (index_t *newIndex) final |
| whenever new block is inserted, BlockTree has to update its ChainWork More... | |
Protected Member Functions inherited from altintegration::BaseBlockTree< Block > | |
| void | deallocateBlock (index_t &block) |
| Permanently erases block from a block tree. More... | |
| std::string | toPrettyString (size_t level=0) const |
| void | decreaseAppliedBlockCount (size_t erasedBlocks) |
| void | decreaseAppliedBlockCount (size_t) |
Protected Attributes | |
| const ChainParams * | param_ = nullptr |
Protected Attributes inherited from altintegration::BaseBlockTree< Block > | |
| bool | isLoadingBlocks_ = false |
| if true, we're in "loading blocks" state More... | |
| bool | isLoaded_ = false |
| if true, we can no longer execute loadBlock/loadTip on this tree. More... | |
| block_index_t | blocks_ |
| stores ALL blocks, including valid and invalid More... | |
| std::unordered_set< index_t * > | tips_ |
| stores ONLY VALID tips, including currently active tip More... | |
| Chain< index_t > | activeChain_ |
| currently applied chain More... | |
| FinalizedPayloadsIndex< index_t > | finalizedPayloadsIndex_ |
| stores mapping of payload id -> its containing ALT/VBK block which are already finalized. More... | |
| PayloadsIndex< index_t > | payloadsIndex_ |
| stores mapping of payload id -> its containing ALT/VBK blocks which are not yet finalized. More... | |
| const BlockReader & | blockProvider_ |
Additional Inherited Members | |
Public Attributes inherited from altintegration::BaseBlockTree< Block > | |
| signals::Signal< void(const index_t &)> | onBlockBeforeDeallocated |
| before we deallocate any block index we emit it to this signal More... | |
| signals::Signal< on_invalidate_t > | onBlockValidityChanged |
| signals to the end user that block have been invalidated More... | |
| signals::Signal< void(const index_t &index)> | onBeforeOverrideTip |
| chain reorg signal - the tip is being changed More... | |
| using altintegration::BlockTree< Block, ChainParams >::base = BaseBlockTree<Block> |
Definition at line 31 of file blocktree.hpp.
| using altintegration::BlockTree< Block, ChainParams >::block_t = Block |
Definition at line 32 of file blocktree.hpp.
| using altintegration::BlockTree< Block, ChainParams >::hash_t = typename Block::hash_t |
Definition at line 36 of file blocktree.hpp.
| using altintegration::BlockTree< Block, ChainParams >::height_t = typename Block::height_t |
Definition at line 38 of file blocktree.hpp.
| using altintegration::BlockTree< Block, ChainParams >::index_t = typename base::index_t |
Definition at line 34 of file blocktree.hpp.
| using altintegration::BlockTree< Block, ChainParams >::params_t = ChainParams |
Definition at line 33 of file blocktree.hpp.
| using altintegration::BlockTree< Block, ChainParams >::prev_block_hash_t = typename Block::prev_hash_t |
Definition at line 37 of file blocktree.hpp.
| using altintegration::BlockTree< Block, ChainParams >::stored_index_t = typename base::stored_index_t |
Definition at line 35 of file blocktree.hpp.
|
inline |
Definition at line 42 of file blocktree.hpp.
|
inline |
Definition at line 103 of file blocktree.hpp.
|
inline |
Definition at line 107 of file blocktree.hpp.
|
inlineprotected |
Definition at line 191 of file blocktree.hpp.
|
inlineprotected |
Definition at line 214 of file blocktree.hpp.
|
inlineprotected |
Definition at line 220 of file blocktree.hpp.
|
inlinevirtual |
This function does all blockchain integrity checks, does blockchain cleanup and in general, very slow.
| [in] | startHeight | start height of the chain |
| [in] | chain | bootstrap chain |
Definition at line 68 of file blocktree.hpp.
|
inlinevirtual |
Definition at line 50 of file blocktree.hpp.
|
inlineoverrideprotectedvirtual |
important to use this->setState for proper vtable resolution
Implements altintegration::BaseBlockTree< Block >.
Definition at line 293 of file blocktree.hpp.
|
inline |
Definition at line 182 of file blocktree.hpp.
|
inline |
Definition at line 45 of file blocktree.hpp.
|
inline |
Definition at line 172 of file blocktree.hpp.
|
inline |
Definition at line 164 of file blocktree.hpp.
|
inlineoverridevirtual |
Reimplemented from altintegration::BaseBlockTree< Block >.
Definition at line 123 of file blocktree.hpp.
|
inlinefinalprotectedvirtual |
Reimplemented from altintegration::BaseBlockTree< Block >.
Definition at line 313 of file blocktree.hpp.
|
inline |
Definition at line 112 of file blocktree.hpp.
|
inlineprotected |
Definition at line 251 of file blocktree.hpp.
|
protected |
Definition at line 189 of file blocktree.hpp.