Scorum
|
#include <fork_database.hpp>
Public Types | |
typedef std::vector< item_ptr > | branch_type |
typedef multi_index_container< item_ptr, indexed_by< hashed_unique< tag< block_id >, member< fork_item, block_id_type, &fork_item::id >, std::hash< fc::ripemd160 > >, hashed_non_unique< tag< by_previous >, const_mem_fun< fork_item, block_id_type, &fork_item::previous_id >, std::hash< fc::ripemd160 > >, ordered_non_unique< tag< block_num >, member< fork_item, uint32_t, &fork_item::num > > > > | fork_multi_index_type |
Public Member Functions | |
fork_database () | |
void | reset () |
void | start_block (signed_block b) |
void | remove (block_id_type b) |
void | set_head (std::shared_ptr< fork_item > h) |
bool | is_known_block (const block_id_type &id) const |
std::shared_ptr< fork_item > | fetch_block (const block_id_type &id) const |
std::vector< item_ptr > | fetch_block_by_number (uint32_t n) const |
std::shared_ptr< fork_item > | push_block (const signed_block &b) |
std::shared_ptr< fork_item > | head () const |
void | pop_block () |
std::pair< branch_type, branch_type > | fetch_branch_from (block_id_type first, block_id_type second) const |
std::shared_ptr< fork_item > | walk_main_branch_to_num (uint32_t block_num) const |
std::shared_ptr< fork_item > | fetch_block_on_main_branch_by_number (uint32_t block_num) const |
void | set_max_size (uint32_t s) |
Static Public Attributes | |
static const int | MAX_BLOCK_REORDERING = 1024 |
The maximum number of blocks that may be skipped in an out-of-order push. More... | |
As long as blocks are pushed in order the fork database will maintain a linked tree of all blocks that branch from the start_block. The tree will have a maximum depth of 1024 blocks after which the database will start lopping off forks.
Every time a block is pushed into the fork DB the block with the highest block_num will be returned.
Definition at line 54 of file fork_database.hpp.
typedef std::vector<item_ptr> scorum::chain::fork_database::branch_type |
Definition at line 57 of file fork_database.hpp.
typedef multi_index_container<item_ptr, indexed_by<hashed_unique<tag<block_id>, member<fork_item, block_id_type, &fork_item::id>, std::hash<fc::ripemd160> >, hashed_non_unique<tag<by_previous>, const_mem_fun<fork_item, block_id_type, &fork_item::previous_id>, std::hash<fc::ripemd160> >, ordered_non_unique<tag<block_num>, member<fork_item, uint32_t, &fork_item::num> > > > scorum::chain::fork_database::fork_multi_index_type |
Definition at line 103 of file fork_database.hpp.
scorum::chain::fork_database::fork_database | ( | ) |
Definition at line 8 of file fork_database.cpp.
item_ptr scorum::chain::fork_database::fetch_block | ( | const block_id_type & | id | ) | const |
Definition at line 140 of file fork_database.cpp.
std::vector< item_ptr > scorum::chain::fork_database::fetch_block_by_number | ( | uint32_t | n | ) | const |
Definition at line 153 of file fork_database.cpp.
std::shared_ptr< fork_item > scorum::chain::fork_database::fetch_block_on_main_branch_by_number | ( | uint32_t | block_num | ) | const |
Definition at line 230 of file fork_database.cpp.
std::pair< fork_database::branch_type, fork_database::branch_type > scorum::chain::fork_database::fetch_branch_from | ( | block_id_type | first, |
block_id_type | second | ||
) | const |
Given two head blocks, return two branches of the fork graph that end with a common ancestor (same prior block)
Definition at line 173 of file fork_database.cpp.
|
inline |
Definition at line 75 of file fork_database.hpp.
bool scorum::chain::fork_database::is_known_block | ( | const block_id_type & | id | ) | const |
Definition at line 129 of file fork_database.cpp.
void scorum::chain::fork_database::pop_block | ( | ) |
Definition at line 17 of file fork_database.cpp.
std::shared_ptr< fork_item > scorum::chain::fork_database::push_block | ( | const signed_block & | b | ) |
Pushes the block into the fork database and caches it if it doesn't link
Definition at line 36 of file fork_database.cpp.
void scorum::chain::fork_database::remove | ( | block_id_type | b | ) |
Definition at line 245 of file fork_database.cpp.
void scorum::chain::fork_database::reset | ( | ) |
Definition at line 11 of file fork_database.cpp.
void scorum::chain::fork_database::set_head | ( | std::shared_ptr< fork_item > | h | ) |
Definition at line 240 of file fork_database.cpp.
void scorum::chain::fork_database::set_max_size | ( | uint32_t | s | ) |
void scorum::chain::fork_database::start_block | ( | signed_block | b | ) |
Definition at line 25 of file fork_database.cpp.
std::shared_ptr< fork_item > scorum::chain::fork_database::walk_main_branch_to_num | ( | uint32_t | block_num | ) | const |
Definition at line 219 of file fork_database.cpp.
|
static |
The maximum number of blocks that may be skipped in an out-of-order push.
Definition at line 59 of file fork_database.hpp.