BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet software
Public Types | Public Member Functions | Static Public Attributes | List of all members
graphene::chain::fork_database Class Reference

#include <fork_database.hpp>

Public Types

typedef vector< item_ptrbranch_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 > >, 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 (shared_ptr< fork_item > h)
 
bool is_known_block (const block_id_type &id) const
 
shared_ptr< fork_itemfetch_block (const block_id_type &id) const
 
vector< item_ptrfetch_block_by_number (uint32_t n) const
 
shared_ptr< fork_itempush_block (const signed_block &b)
 
shared_ptr< fork_itemhead () const
 
void pop_block ()
 
pair< branch_type, branch_typefetch_branch_from (block_id_type first, block_id_type second) const
 
void set_max_size (uint32_t s)
 

Static Public Attributes

const static int MAX_BLOCK_REORDERING = 1024
 The maximum number of blocks that may be skipped in an out-of-order push. More...
 

Detailed Description

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 70 of file fork_database.hpp.

Member Typedef Documentation

◆ branch_type

Definition at line 73 of file fork_database.hpp.

◆ fork_multi_index_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> >, ordered_non_unique<tag<block_num>, member<fork_item,uint32_t,&fork_item::num> > > > graphene::chain::fork_database::fork_multi_index_type

Definition at line 102 of file fork_database.hpp.

Constructor & Destructor Documentation

◆ fork_database()

graphene::chain::fork_database::fork_database ( )

Definition at line 28 of file fork_database.cpp.

Member Function Documentation

◆ fetch_block()

item_ptr graphene::chain::fork_database::fetch_block ( const block_id_type id) const

Definition at line 124 of file fork_database.cpp.

◆ fetch_block_by_number()

vector< item_ptr > graphene::chain::fork_database::fetch_block_by_number ( uint32_t  n) const

Definition at line 133 of file fork_database.cpp.

◆ fetch_branch_from()

pair< fork_database::branch_type, fork_database::branch_type > graphene::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 149 of file fork_database.cpp.

◆ head()

shared_ptr<fork_item> graphene::chain::fork_database::head ( ) const
inline

Definition at line 91 of file fork_database.hpp.

◆ is_known_block()

bool graphene::chain::fork_database::is_known_block ( const block_id_type id) const

Definition at line 117 of file fork_database.cpp.

◆ pop_block()

void graphene::chain::fork_database::pop_block ( )

Definition at line 37 of file fork_database.cpp.

◆ push_block()

shared_ptr< fork_item > graphene::chain::fork_database::push_block ( const signed_block b)
Returns
the new head block ( the longest fork )

Pushes the block into the fork database

Definition at line 56 of file fork_database.cpp.

◆ remove()

void graphene::chain::fork_database::remove ( block_id_type  b)

Definition at line 197 of file fork_database.cpp.

◆ reset()

void graphene::chain::fork_database::reset ( )

Definition at line 31 of file fork_database.cpp.

◆ set_head()

void graphene::chain::fork_database::set_head ( shared_ptr< fork_item h)

Definition at line 192 of file fork_database.cpp.

◆ set_max_size()

void graphene::chain::fork_database::set_max_size ( uint32_t  s)

Definition at line 100 of file fork_database.cpp.

◆ start_block()

void graphene::chain::fork_database::start_block ( signed_block  b)

Definition at line 45 of file fork_database.cpp.

Member Data Documentation

◆ MAX_BLOCK_REORDERING

const static int graphene::chain::fork_database::MAX_BLOCK_REORDERING = 1024
static

The maximum number of blocks that may be skipped in an out-of-order push.

Definition at line 75 of file fork_database.hpp.


The documentation for this class was generated from the following files: