Wire Sysio Wire Sysion 1.0.0
|
manages light-weight state for all potential unconfirmed forks More...
#include <fork_database.hpp>
Static Public Attributes | |
static const uint32_t | magic_number = 0x30510FDB |
static const uint32_t | min_supported_version = 1 |
static const uint32_t | max_supported_version = 1 |
As new blocks are received, they are pushed into the fork database. The fork database tracks the longest chain and the last irreversible block number. All blocks older than the last irreversible block are freed after emitting the irreversible signal.
An internal mutex is used to provide thread-safety.
Definition at line 22 of file fork_database.hpp.
|
explicit |
Definition at line 100 of file fork_database.cpp.
sysio::chain::fork_database::~fork_database | ( | ) |
Definition at line 259 of file fork_database.cpp.
void sysio::chain::fork_database::add | ( | const block_state_ptr & | next_block, |
bool | ignore_duplicate = false ) |
Add block state to fork database. Must link to existing block in fork database or the root.
Definition at line 385 of file fork_database.cpp.
void sysio::chain::fork_database::advance_root | ( | const block_id_type & | id | ) |
Advance root block forward to some other block in the tree.
Definition at line 293 of file fork_database.cpp.
void sysio::chain::fork_database::close | ( | ) |
Definition at line 191 of file fork_database.cpp.
branch_type sysio::chain::fork_database::fetch_branch | ( | const block_id_type & | h, |
uint32_t | trim_after_block_num = std::numeric_limits<uint32_t>::max() ) const |
Returns the sequence of block states resulting from trimming the branch from the root block (exclusive) to the block with an id of h
(inclusive) by removing any block states corresponding to block numbers greater than trim_after_block_num
.
The order of the sequence is in descending block number order. A block with an id of h
must exist in the fork database otherwise this method will throw an exception.
Definition at line 418 of file fork_database.cpp.
pair< branch_type, branch_type > sysio::chain::fork_database::fetch_branch_from | ( | const block_id_type & | first, |
const 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 451 of file fork_database.cpp.
block_state_ptr sysio::chain::fork_database::get_block | ( | const block_id_type & | id | ) | const |
Definition at line 568 of file fork_database.cpp.
block_header_state_ptr sysio::chain::fork_database::get_block_header | ( | const block_id_type & | id | ) | const |
Definition at line 331 of file fork_database.cpp.
block_state_ptr sysio::chain::fork_database::head | ( | ) | const |
Definition at line 400 of file fork_database.cpp.
void sysio::chain::fork_database::mark_valid | ( | const block_state_ptr & | h | ) |
Definition at line 543 of file fork_database.cpp.
void sysio::chain::fork_database::open | ( | const std::function< void(block_timestamp_type, const flat_set< digest_type > &, const vector< digest_type > &)> & | validator | ) |
Definition at line 105 of file fork_database.cpp.
block_state_ptr sysio::chain::fork_database::pending_head | ( | ) | const |
Definition at line 405 of file fork_database.cpp.
void sysio::chain::fork_database::remove | ( | const block_id_type & | id | ) |
remove all of the invalid forks built off of this id including this id
Definition at line 517 of file fork_database.cpp.
void sysio::chain::fork_database::reset | ( | const block_header_state & | root_bhs | ) |
Purges any existing blocks from the fork database and resets the root block_header_state to the provided value. The head will also be reset to point to the root.
Definition at line 263 of file fork_database.cpp.
void sysio::chain::fork_database::rollback_head_to_root | ( | ) |
Removes validated flag from all blocks in fork database and resets head to point to the root.
Definition at line 276 of file fork_database.cpp.
block_state_ptr sysio::chain::fork_database::root | ( | ) | const |
Definition at line 395 of file fork_database.cpp.
block_state_ptr sysio::chain::fork_database::search_on_branch | ( | const block_id_type & | h, |
uint32_t | block_num ) const |
Returns the block state with a block number of block_num
that is on the branch that contains a block with an id ofh
, or the empty shared pointer if no such block can be found.
Definition at line 433 of file fork_database.cpp.
|
static |
Definition at line 91 of file fork_database.hpp.
|
static |
Definition at line 94 of file fork_database.hpp.
|
static |
Definition at line 93 of file fork_database.hpp.