![]() |
Ethereum
PoC-8
The C++ Implementation of Ethereum
|
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>
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 |
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.
| BlockQueue::BlockQueue | ( | ) |
Definition at line 40 of file BlockQueue.cpp.
| BlockQueue::~BlockQueue | ( | ) |
Definition at line 51 of file BlockQueue.cpp.
| 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.
| void BlockQueue::clear | ( | ) |
Clear everything.
Definition at line 67 of file BlockQueue.cpp.
| u256 BlockQueue::difficulty | ( | ) | const |
Definition at line 530 of file BlockQueue.cpp.
Must be called after a drain() call. Notes that the drained blocks have been imported into the blockchain, so we can forget about them.
Definition at line 332 of file BlockQueue.cpp.
| 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.
|
inline |
Return first block with an unknown parent.
Definition at line 261 of file BlockQueue.h.
| ImportResult BlockQueue::import | ( | bytesConstRef | _block, |
| bool | _isOurs = false |
||
| ) |
Import a block into the queue.
Definition at line 169 of file BlockQueue.cpp.
| bool BlockQueue::isActive | ( | ) | const |
Definition at line 536 of file BlockQueue.cpp.
|
inline |
Get information on the items queued.
Definition at line 252 of file BlockQueue.h.
| bool BlockQueue::knownFull | ( | ) | const |
Definition at line 402 of file BlockQueue.cpp.
|
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.
|
inline |
Definition at line 269 of file BlockQueue.h.
|
inline |
Definition at line 270 of file BlockQueue.h.
| void BlockQueue::retryAllUnknown | ( | ) |
Force a retry of all the blocks with unknown parents.
Definition at line 497 of file BlockQueue.cpp.
|
inline |
Definition at line 229 of file BlockQueue.h.
|
inline |
Definition at line 272 of file BlockQueue.h.
| BlockQueueStatus BlockQueue::status | ( | ) | const |
Get some infomration on the current status.
Definition at line 379 of file BlockQueue.cpp.
| void BlockQueue::stop | ( | ) |
Stop all activity, leaves the class in limbo, waiting for destruction.
Definition at line 56 of file BlockQueue.cpp.
| 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.
| bool BlockQueue::unknownFull | ( | ) | const |
Definition at line 418 of file BlockQueue.cpp.