@@ -957,6 +957,35 @@ class MinerImpl : public Mining
957957 return BlockRef{chainman ().ActiveChain ().Tip ()->GetBlockHash (), chainman ().ActiveChain ().Tip ()->nHeight };
958958 }
959959
960+ bool waitFeesChanged (uint256 current_tip, CAmount fee_threshold, const BlockCreateOptions& options, MillisecondsDouble timeout) override
961+ {
962+ if (timeout > std::chrono::years{100 }) timeout = std::chrono::years{100 }; // Upper bound to avoid UB in std::chrono
963+ auto now{std::chrono::steady_clock::now ()};
964+ const auto deadline = now + timeout;
965+ const MillisecondsDouble tick{1000 };
966+
967+ unsigned int last_mempool_update{context ()->mempool ->GetTransactionsUpdated ()};
968+
969+ BlockAssembler::Options assemble_options{options};
970+ ApplyArgsManOptions (*Assert (m_node.args ), assemble_options);
971+
972+ while (!chainman ().m_interrupt ) {
973+ now = std::chrono::steady_clock::now ();
974+ if (now >= deadline) break ;
975+
976+ if (getTip ().value ().hash != current_tip) {
977+ return false ;
978+ }
979+
980+ // TODO: when cluster mempool is available, actually calculate
981+ // fees for the next block. This is currently too expensive.
982+ if (context ()->mempool ->GetTransactionsUpdated () > last_mempool_update) return true ;
983+
984+ std::this_thread::sleep_until (std::min (deadline, now + tick));
985+ }
986+ return false ;
987+ }
988+
960989 bool processNewBlock (const std::shared_ptr<const CBlock>& block, bool * new_block) override
961990 {
962991 return chainman ().ProcessNewBlock (block, /* force_processing=*/ true , /* min_pow_checked=*/ true , /* new_block=*/ new_block);
0 commit comments