pub struct BlockManager { /* private fields */ }
Expand description

| Maintains a tree of blocks (stored in | m_block_index) which is consulted | to determine where the most-work tip | is. | | This data is used mostly in ChainState | - information about, e.g., candidate | tips is not maintained here. |

Implementations§

source§

impl BlockManager

source

pub fn add_to_block_index(&mut self, block: &BlockHeader) -> *mut BlockIndex

source

pub fn get_last_checkpoint(&mut self, data: &CheckpointData) -> *mut BlockIndex

| Returns last CBlockIndex* that is a | checkpoint |

source

pub fn accept_block_header( &mut self, block: &BlockHeader, state: &mut BlockValidationState, chainparams: &ChainParams, ppindex: *mut *mut BlockIndex ) -> bool

| If a block header hasn’t already been | seen, call CheckBlockHeader on it, | ensure that it doesn’t descend from | an invalid block, and then add it to m_block_index. |

source

pub fn find_files_to_prune( &mut self, set_files_to_prune: &mut HashSet<i32>, n_prune_after_height: u64, chain_tip_height: i32, prune_height: i32, is_ibd: bool )

| Prune block and undo files (blk???.dat | and undo???.dat) so that the disk space | used is less than a user-defined target. | | The user sets the target (in MB) on the | command line or in config file. This | will be run on startup and whenever new | space is allocated in a block or undo | file, staying below the target. Changing | back to unpruned requires a reindex | (which in this case means the blockchain | must be re-downloaded.) | | Pruning functions are called from FlushStateToDisk | when the global fCheckForPruning flag | has been set. | | Block and undo files are deleted in lock-step | (when blk00003.dat is deleted, so is | rev00003.dat.) | | Pruning cannot take place until the | longest chain is at least a certain length | (100000 on mainnet, 1000 on testnet, | 1000 on regtest). | | Pruning will never delete a block within | a defined distance (currently 288) | from the active chain’s tip. | | The block index is updated by unsetting | HAVE_DATA and HAVE_UNDO for any blocks | that were stored in the deleted files. | | A db flag records the fact that at least | some block files have been pruned. | | ———– | @param[out] setFilesToPrune | | The set of file indices that can be unlinked | will be returned |

source

pub fn insert_block_index(&mut self, hash: &u256) -> *mut BlockIndex

| Create a new block index entry for a given | block hash |

source

pub fn load_block_index( &mut self, consensus_params: &ChainConsensusParams, block_index_candidates: &mut HashSet<*mut BlockIndex, BlockIndexWorkComparator> ) -> bool

| Load the blocktree off disk and into | memory. Populate certain metadata | per index entry (nStatus, nChainWork, | nTimeMax, etc.) as well as peripheral | collections like setDirtyBlockIndex. | | ———– | @param[out] block_index_candidates | | Fill this set with any valid blocks for | which we’ve downloaded all transactions. |

source

pub fn unload(&mut self)

| Clear all data members. |

source

pub fn load_block_indexdb( &mut self, set_block_index_candidates: &mut HashSet<*mut BlockIndex, BlockIndexWorkComparator> ) -> bool

source

pub fn prune_one_block_file(&mut self, file_number: i32)

| Mark one block file as pruned (modify | associated database entries) |

source

pub fn find_files_to_prune_manual( &mut self, set_files_to_prune: &mut HashSet<i32>, n_manual_prune_height: i32, chain_tip_height: i32 )

| Calculate the block/rev files to delete | based on height specified by user with | RPC command pruneblockchain |

source

pub fn get_spend_height(&mut self, inputs: &CoinsViewCache) -> i32

| Return the spend height, which is one | more than the inputs.GetBestBlock(). | | While checking, GetBestBlock() refers | to the parent block. (protected by cs_main) | | This is also true for mempool checks. |

source

pub fn lookup_block_index(&self, hash: &u256) -> Option<Arc<BlockIndex>>

Trait Implementations§

source§

impl Drop for BlockManager

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T, U> CastInto<U> for Twhere U: CastFrom<T>,

§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> StaticUpcast<T> for T

§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V