A queue of blocks.
More...
#include <BlockQueue.h>
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).
Definition at line 225 of file BlockQueue.h.
BlockQueue::BlockQueue |
( |
| ) |
|
BlockQueue::~BlockQueue |
( |
| ) |
|
Get some infomration on the given block's status regarding us.
Definition at line 386 of file BlockQueue.cpp.
void BlockQueue::clear |
( |
| ) |
|
void BlockQueue::collectUnknownBad_WITH_BOTH_LOCKS |
( |
h256 const & |
_bad | ) |
|
|
private |
u256 BlockQueue::difficulty |
( |
| ) |
const |
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 333 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 433 of file BlockQueue.cpp.
void BlockQueue::drainVerified_WITH_BOTH_LOCKS |
( |
| ) |
|
|
private |
h256 dev::eth::BlockQueue::firstUnknown |
( |
| ) |
const |
|
inline |
Return first block with an unknown parent.
Definition at line 263 of file BlockQueue.h.
bool BlockQueue::invariants |
( |
| ) |
const |
|
overrideprivatevirtual |
bool BlockQueue::isActive |
( |
| ) |
const |
std::pair<unsigned, unsigned> dev::eth::BlockQueue::items |
( |
| ) |
const |
|
inline |
Get information on the items queued.
Definition at line 254 of file BlockQueue.h.
std::size_t BlockQueue::knownCount |
( |
| ) |
const |
|
private |
bool BlockQueue::knownFull |
( |
| ) |
const |
std::size_t BlockQueue::knownSize |
( |
| ) |
const |
|
private |
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 248 of file BlockQueue.h.
void BlockQueue::noteReady_WITH_LOCK |
( |
h256 const & |
_b | ) |
|
|
private |
template<class T >
Handler dev::eth::BlockQueue::onReady |
( |
T const & |
_t | ) |
|
|
inline |
template<class T >
Handler dev::eth::BlockQueue::onRoomAvailable |
( |
T const & |
_t | ) |
|
|
inline |
void BlockQueue::retryAllUnknown |
( |
| ) |
|
Force a retry of all the blocks with unknown parents.
Definition at line 496 of file BlockQueue.cpp.
void dev::eth::BlockQueue::setChain |
( |
BlockChain const & |
_bc | ) |
|
|
inline |
template<class T >
void dev::eth::BlockQueue::setOnBad |
( |
T const & |
_t | ) |
|
|
inline |
Get some infomration on the current status.
Definition at line 378 of file BlockQueue.cpp.
void BlockQueue::stop |
( |
| ) |
|
Stop all activity, leaves the class in limbo, waiting for destruction.
Definition at line 63 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 350 of file BlockQueue.cpp.
std::size_t BlockQueue::unknownCount |
( |
| ) |
const |
|
private |
bool BlockQueue::unknownFull |
( |
| ) |
const |
std::size_t BlockQueue::unknownSize |
( |
| ) |
const |
|
private |
void BlockQueue::updateBad_WITH_LOCK |
( |
h256 const & |
_bad | ) |
|
|
private |
void BlockQueue::verifierBody |
( |
| ) |
|
|
private |
The blockchain into which our imports go.
Definition at line 303 of file BlockQueue.h.
std::atomic<bool> dev::eth::BlockQueue::m_deleting = {false} |
|
private |
u256 dev::eth::BlockQueue::m_difficulty |
|
private |
Total difficulty of blocks in the queue.
Definition at line 325 of file BlockQueue.h.
u256 dev::eth::BlockQueue::m_drainingDifficulty |
|
private |
Total difficulty of blocks in draining.
Definition at line 326 of file BlockQueue.h.
h256Hash dev::eth::BlockQueue::m_drainingSet |
|
private |
Set of blocks that are not yet valid. Ordered by timestamp.
Definition at line 311 of file BlockQueue.h.
h256Hash dev::eth::BlockQueue::m_knownBad |
|
private |
Set of blocks that we know will never be valid.
Definition at line 310 of file BlockQueue.h.
boost::shared_mutex dev::eth::BlockQueue::m_lock |
|
mutableprivate |
General lock for the sets, m_future and m_unknown.
Definition at line 305 of file BlockQueue.h.
std::condition_variable dev::eth::BlockQueue::m_moreToVerify |
|
private |
Signaled when m_unverified has a new entry.
Definition at line 316 of file BlockQueue.h.
Called if we have a block that doesn't verify.
Definition at line 324 of file BlockQueue.h.
Signal dev::eth::BlockQueue::m_onReady |
|
private |
Called when a subsequent call to import blocks will return a non-empty container. Be nice and exit fast.
Definition at line 312 of file BlockQueue.h.
Signal dev::eth::BlockQueue::m_onRoomAvailable |
|
private |
Called when space for new blocks becomes availabe after a drain. Be nice and exit fast.
Definition at line 313 of file BlockQueue.h.
h256Hash dev::eth::BlockQueue::m_readySet |
|
private |
All blocks ready for chain import.
Definition at line 307 of file BlockQueue.h.
For blocks that have an unknown parent; we map their parent hash to the block stuff, and insert once the block appears.
Definition at line 309 of file BlockQueue.h.
h256Hash dev::eth::BlockQueue::m_unknownSet |
|
private |
Set of all blocks whose parents are not ready/in-chain.
Definition at line 308 of file BlockQueue.h.
List of <block hash, parent hash, block data> in correct order, ready for verification.
Definition at line 319 of file BlockQueue.h.
Mutex dev::eth::BlockQueue::m_verification |
|
mutableprivate |
Mutex that allows writing to m_verified, m_verifying and m_unverified.
Definition at line 315 of file BlockQueue.h.
List of blocks, in correct order, verified and ready for chain-import.
Definition at line 317 of file BlockQueue.h.
std::vector<std::thread> dev::eth::BlockQueue::m_verifiers |
|
private |
List of blocks being verified; as long as the block component (bytes) is empty, it's not finished.
Definition at line 318 of file BlockQueue.h.
The documentation for this class was generated from the following files: