Ethereum  PoC-8
The C++ Implementation of Ethereum
dev::eth::BlockQueue Class Reference

A queue of blocks. Sits between network or other I/O and the BlockChain. Sorts them ready for blockchain insertion (with the BlockChain::sync() method). @threadsafe. More...

#include <BlockQueue.h>

Inheritance diagram for dev::eth::BlockQueue:
dev::HasInvariants

Public Member Functions

 BlockQueue ()
 
 ~BlockQueue ()
 
void setChain (BlockChain const &_bc)
 
ImportResult import (bytesConstRef _block, bool _isOurs=false)
 Import a block into the queue. More...
 
void tick ()
 Notes that time has moved on and some blocks that used to be "in the future" may no be valid. More...
 
void drain (std::vector< VerifiedBlock > &o_out, unsigned _max)
 
bool doneDrain (h256s const &_knownBad=h256s())
 
void noteReady (h256 const &_b)
 Notify the queue that the chain has changed and a new block has attained 'ready' status (i.e. is in the chain). More...
 
void retryAllUnknown ()
 Force a retry of all the blocks with unknown parents. More...
 
std::pair< unsigned, unsigned > items () const
 Get information on the items queued. More...
 
void clear ()
 Clear everything. More...
 
void stop ()
 Stop all activity, leaves the class in limbo, waiting for destruction. More...
 
h256 firstUnknown () const
 Return first block with an unknown parent. More...
 
BlockQueueStatus status () const
 Get some infomration on the current status. More...
 
QueueStatus blockStatus (h256 const &_h) const
 Get some infomration on the given block's status regarding us. More...
 
Handler onReady (std::function< void(void)> _t)
 
Handler onRoomAvailable (std::function< void(void)> _t)
 
template<class T >
void setOnBad (T const &_t)
 
bool knownFull () const
 
bool unknownFull () const
 
u256 difficulty () const
 
bool isActive () const
 

Detailed Description

A queue of blocks. Sits between network or other I/O and the BlockChain. Sorts them ready for blockchain insertion (with the BlockChain::sync() method). @threadsafe.

Definition at line 223 of file BlockQueue.h.

Constructor & Destructor Documentation

◆ BlockQueue()

BlockQueue::BlockQueue ( )

Definition at line 40 of file BlockQueue.cpp.

◆ ~BlockQueue()

BlockQueue::~BlockQueue ( )

Definition at line 51 of file BlockQueue.cpp.

Member Function Documentation

◆ blockStatus()

QueueStatus BlockQueue::blockStatus ( h256 const &  _h) const

Get some infomration on the given block's status regarding us.

Definition at line 387 of file BlockQueue.cpp.

◆ clear()

void BlockQueue::clear ( )

Clear everything.

Definition at line 67 of file BlockQueue.cpp.

◆ difficulty()

u256 BlockQueue::difficulty ( ) const

Definition at line 530 of file BlockQueue.cpp.

◆ doneDrain()

bool BlockQueue::doneDrain ( h256s const &  _knownBad = h256s())

Must be called after a drain() call. Notes that the drained blocks have been imported into the blockchain, so we can forget about them.

Returns
true iff there are additional blocks ready to be processed.

Definition at line 332 of file BlockQueue.cpp.

◆ drain()

void BlockQueue::drain ( std::vector< VerifiedBlock > &  o_out,
unsigned  _max 
)

Grabs at most _max of the blocks that are ready, giving them in the correct order for insertion into the chain. Don't forget to call doneDrain() once you're done importing.

Definition at line 434 of file BlockQueue.cpp.

◆ firstUnknown()

h256 dev::eth::BlockQueue::firstUnknown ( ) const
inline

Return first block with an unknown parent.

Definition at line 261 of file BlockQueue.h.

◆ import()

ImportResult BlockQueue::import ( bytesConstRef  _block,
bool  _isOurs = false 
)

Import a block into the queue.

Definition at line 169 of file BlockQueue.cpp.

◆ isActive()

bool BlockQueue::isActive ( ) const

Definition at line 536 of file BlockQueue.cpp.

◆ items()

std::pair<unsigned, unsigned> dev::eth::BlockQueue::items ( ) const
inline

Get information on the items queued.

Definition at line 252 of file BlockQueue.h.

◆ knownFull()

bool BlockQueue::knownFull ( ) const

Definition at line 402 of file BlockQueue.cpp.

◆ noteReady()

void dev::eth::BlockQueue::noteReady ( h256 const &  _b)
inline

Notify the queue that the chain has changed and a new block has attained 'ready' status (i.e. is in the chain).

Definition at line 246 of file BlockQueue.h.

◆ onReady()

Handler dev::eth::BlockQueue::onReady ( std::function< void(void)>  _t)
inline

Definition at line 269 of file BlockQueue.h.

◆ onRoomAvailable()

Handler dev::eth::BlockQueue::onRoomAvailable ( std::function< void(void)>  _t)
inline

Definition at line 270 of file BlockQueue.h.

◆ retryAllUnknown()

void BlockQueue::retryAllUnknown ( )

Force a retry of all the blocks with unknown parents.

Definition at line 497 of file BlockQueue.cpp.

◆ setChain()

void dev::eth::BlockQueue::setChain ( BlockChain const &  _bc)
inline

Definition at line 229 of file BlockQueue.h.

◆ setOnBad()

template<class T >
void dev::eth::BlockQueue::setOnBad ( T const &  _t)
inline

Definition at line 272 of file BlockQueue.h.

◆ status()

BlockQueueStatus BlockQueue::status ( ) const

Get some infomration on the current status.

Definition at line 379 of file BlockQueue.cpp.

◆ stop()

void BlockQueue::stop ( )

Stop all activity, leaves the class in limbo, waiting for destruction.

Definition at line 56 of file BlockQueue.cpp.

◆ tick()

void BlockQueue::tick ( )

Notes that time has moved on and some blocks that used to be "in the future" may no be valid.

Definition at line 349 of file BlockQueue.cpp.

◆ unknownFull()

bool BlockQueue::unknownFull ( ) const

Definition at line 418 of file BlockQueue.cpp.


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