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

Method resyncStateFromChain

src/cpp-ethereum/libethereum/Client.cpp:497–539  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

495}
496
497void Client::resyncStateFromChain()
498{
499 // RESTART MINING
500
501// ctrace << "resyncStateFromChain()";
502
503 if (!isMajorSyncing())
504 {
505 bool preChanged = false;
506 Block newPreMine(chainParams().accountStartNonce);
507 DEV_READ_GUARDED(x_preSeal)
508 newPreMine = m_preSeal;
509
510 // TODO: use m_postSeal to avoid re-evaluating our own blocks.
511 preChanged = newPreMine.sync(bc());
512
513 if (preChanged || m_postSeal.author() != m_preSeal.author())
514 {
515 DEV_WRITE_GUARDED(x_preSeal)
516 m_preSeal = newPreMine;
517 DEV_WRITE_GUARDED(x_working)
518 m_working = newPreMine;
519 DEV_READ_GUARDED(x_postSeal)
520 if (!m_postSeal.isSealed() || m_postSeal.info().hash() != newPreMine.info().parentHash())
521 for (auto const& t: m_postSeal.pending())
522 {
523 clog(ClientTrace) << "Resubmitting post-seal transaction " << t;
524// ctrace << "Resubmitting post-seal transaction " << t;
525 auto ir = m_tq.import(t, IfDropped::Retry);
526 if (ir != ImportResult::Success)
527 onTransactionQueueReady();
528 }
529 DEV_READ_GUARDED(x_working) DEV_WRITE_GUARDED(x_postSeal)
530 m_postSeal = m_working;
531
532 onPostStateChanged();
533 }
534
535 // Quick hack for now - the TQ at this point already has the prior pending transactions in it;
536 // we should resync with it manually until we are stricter about what constitutes "knowing".
537 onTransactionQueueReady();
538 }
539}
540
541void Client::resetState()
542{

Callers

nothing calls this directly

Calls 9

isSealedMethod · 0.80
pendingMethod · 0.80
DEV_READ_GUARDEDFunction · 0.70
DEV_WRITE_GUARDEDFunction · 0.70
syncMethod · 0.45
authorMethod · 0.45
hashMethod · 0.45
infoMethod · 0.45
importMethod · 0.45

Tested by

no test coverage detected