25 #include <unordered_map> 78 void onPeerNewHashes(std::shared_ptr<EthereumPeer> _peer, std::vector<std::pair<h256, u256>>
const& _hashes);
102 void syncPeer(std::shared_ptr<EthereumPeer> _peer,
bool _force);
135 boost::hash_combine(seed, hasher(_k.
uncles));
151 std::map<std::weak_ptr<EthereumPeer>, std::vector<unsigned>, std::owner_less<std::weak_ptr<EthereumPeer>>>
m_headerSyncPeers;
152 std::map<std::weak_ptr<EthereumPeer>, std::vector<unsigned>, std::owner_less<std::weak_ptr<EthereumPeer>>>
m_bodySyncPeers;
Inheritable for classes that have invariants.
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
void restartSync()
Restart sync.
h256Hash m_knownNewHashes
New hashes we know about use for logging only.
void onPeerNewHashes(std::shared_ptr< EthereumPeer > _peer, std::vector< std::pair< h256, u256 >> const &_hashes)
void onPeerBlockHeaders(std::shared_ptr< EthereumPeer > _peer, RLP const &_r)
Called by peer once it has new block headers during sync.
bool invariants() const override
Reimplement to specify the invariants.
bool m_haveCommonHeader
True if common block for our and remote chain has been found.
unsigned m_startingBlock
Last block number for the start of sync.
Handler m_bqRoomAvailable
Triggered once block queue has space for more blocks.
void completeSync()
Called after all blocks have been downloaded Public only for test mode.
void abortSync()
Abort all sync activity.
std::ostream & operator<<(std::ostream &_out, BlockHeader const &_bi)
EthereumHost const & host() const
h256 m_lastImportedBlockHash
Last imported block hash.
unsigned m_lastImportedBlock
Last imported block number.
std::unordered_set< unsigned > m_downloadingHeaders
Set of block body numbers being downloaded.
u256 m_syncingTotalDifficulty
Highest peer difficulty.
SyncState m_state
Current sync state.
std::map< std::weak_ptr< EthereumPeer >, std::vector< unsigned >, std::owner_less< std::weak_ptr< EthereumPeer > > > m_headerSyncPeers
Peers to m_downloadingSubchain number map.
SyncStatus status() const
std::map< unsigned, std::vector< Header > > m_headers
Downloaded headers.
Initial chain sync complete. Waiting for new packets.
std::recursive_mutex RecursiveMutex
void continueSync()
Resume downloading after witing state.
static char const *const s_stateNames[static_cast< int >(SyncState::Size)]
unsigned m_highestBlock
Highest block number seen.
std::shared_ptr< typename Signal< Args... >::HandlerAux > Handler
void pauseSync()
Enter waiting state.
std::unordered_set< unsigned > m_downloadingBodies
Set of block header numbers being downloaded.
BlockChainSync(EthereumHost &_host)
std::vector< byte > bytes
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void >> u256
static char const * stateName(SyncState _s)
void onPeerAborting()
Called by peer when it is disconnecting.
Base BlockChain synchronization strategy class.
void onPeerBlockBodies(std::shared_ptr< EthereumPeer > _peer, RLP const &_r)
Called by peer once it has new block bodies.
void syncPeer(std::shared_ptr< EthereumPeer > _peer, bool _force)
std::map< std::weak_ptr< EthereumPeer >, std::vector< unsigned >, std::owner_less< std::weak_ptr< EthereumPeer > > > m_bodySyncPeers
Peers to m_downloadingSubchain number map.
void onPeerStatus(std::shared_ptr< EthereumPeer > _peer)
Called by peer to report status.
std::unordered_set< h256 > h256Hash
std::map< unsigned, std::vector< bytes > > m_bodies
Downloaded block bodies.
void logNewBlock(h256 const &_h)
void onBlockImported(BlockHeader const &_info)
Called when a blockchain has imported a new block onto the DB.
Class for interpreting Recursive Linear-Prefix Data.
void onPeerNewBlock(std::shared_ptr< EthereumPeer > _peer, RLP const &_r)
Called by peer once it has new block bodies.
void requestBlocks(std::shared_ptr< EthereumPeer > _peer)
std::unordered_map< HeaderId, unsigned, HeaderIdHash > m_headerIdToNumber