| 665 | } |
| 666 | |
| 667 | void Client::doWork(bool _doWait) |
| 668 | { |
| 669 | bool t = true; |
| 670 | if (m_syncBlockQueue.compare_exchange_strong(t, false)) |
| 671 | syncBlockQueue(); |
| 672 | |
| 673 | if (m_needStateReset) |
| 674 | { |
| 675 | resetState(); |
| 676 | m_needStateReset = false; |
| 677 | } |
| 678 | |
| 679 | t = true; |
| 680 | bool isSealed = false; |
| 681 | DEV_READ_GUARDED(x_working) |
| 682 | isSealed = m_working.isSealed(); |
| 683 | if (!isSealed && !isSyncing() && !m_remoteWorking && m_syncTransactionQueue.compare_exchange_strong(t, false)) |
| 684 | syncTransactionQueue(); |
| 685 | |
| 686 | tick(); |
| 687 | |
| 688 | rejigSealing(); |
| 689 | |
| 690 | callQueuedFunctions(); |
| 691 | |
| 692 | DEV_READ_GUARDED(x_working) |
| 693 | isSealed = m_working.isSealed(); |
| 694 | // If the block is sealed, we have to wait for it to tickle through the block queue |
| 695 | // (which only signals as wanting to be synced if it is ready). |
| 696 | if (!m_syncBlockQueue && !m_syncTransactionQueue && (_doWait || isSealed)) |
| 697 | { |
| 698 | std::unique_lock<std::mutex> l(x_signalled); |
| 699 | m_signalled.wait_for(l, chrono::seconds(1)); |
| 700 | } |
| 701 | } |
| 702 | |
| 703 | void Client::tick() |
| 704 | { |
nothing calls this directly
no test coverage detected