MCPcopy Create free account
hub / github.com/LUX-Core/lux / syncPeer

Method syncPeer

src/cpp-ethereum/libethereum/BlockChainSync.cpp:226–259  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

224}
225
226void BlockChainSync::syncPeer(std::shared_ptr<EthereumPeer> _peer, bool _force)
227{
228 if (_peer->m_asking != Asking::Nothing)
229 {
230 clog(NetAllDetail) << "Can't sync with this peer - outstanding asks.";
231 return;
232 }
233
234 if (m_state == SyncState::Waiting)
235 return;
236
237 u256 td = host().chain().details().totalDifficulty;
238 if (host().bq().isActive())
239 td += host().bq().difficulty();
240
241 u256 syncingDifficulty = std::max(m_syncingTotalDifficulty, td);
242
243 if (_force || _peer->m_totalDifficulty > syncingDifficulty)
244 {
245 // start sync
246 m_syncingTotalDifficulty = _peer->m_totalDifficulty;
247 if (m_state == SyncState::Idle || m_state == SyncState::NotSynced)
248 m_state = SyncState::Blocks;
249 _peer->requestBlockHeaders(_peer->m_latestHash, 1, 0, false);
250 _peer->m_requireTransactions = true;
251 return;
252 }
253
254 if (m_state == SyncState::Blocks)
255 {
256 requestBlocks(_peer);
257 return;
258 }
259}
260
261void BlockChainSync::continueSync()
262{

Callers

nothing calls this directly

Calls 5

maxFunction · 0.85
detailsMethod · 0.80
isActiveMethod · 0.80
difficultyMethod · 0.80
requestBlockHeadersMethod · 0.80

Tested by

no test coverage detected