@@ -1384,21 +1384,20 @@ int main(int argc, char* argv[]) {
13841384 mweb_tracker = std::make_unique<ltc::coin::MWEBTracker>();
13851385 embedded_node = std::make_unique<ltc::coin::EmbeddedCoinNode>(
13861386 *embedded_chain, *embedded_pool, settings->m_testnet , mweb_tracker.get ());
1387- // Gate mining until UTXO has coinbase maturity depth (100 blocks).
1387+ // Gate mining until UTXO has coinbase maturity depth (100 blocks for LTC ).
13881388 // Without this, block templates may include TXs spending immature coinbase outputs.
1389- if (ltc_utxo_db) {
1390- auto * db_ptr = ltc_utxo_db. get ();
1391- auto * chain_ptr = embedded_chain .get ();
1389+ // Reference: litecoin/src/consensus/consensus.h COINBASE_MATURITY = 100
1390+ if (ltc_utxo_cache) {
1391+ auto * cache_ptr = ltc_utxo_cache .get ();
13921392 constexpr uint32_t LTC_MATURITY = core::coin::LTC_LIMITS .coinbase_maturity ;
1393- embedded_node->set_utxo_ready_fn ([db_ptr, chain_ptr, LTC_MATURITY ]() {
1394- auto chain_h = chain_ptr->height ();
1395- auto utxo_h = db_ptr->get_best_height ();
1396- bool ready = utxo_h > 0 && chain_h > 0 && (chain_h - utxo_h) < LTC_MATURITY ;
1393+ embedded_node->set_utxo_ready_fn ([cache_ptr, LTC_MATURITY ]() {
1394+ auto connected = cache_ptr->blocks_connected ();
1395+ bool ready = connected >= LTC_MATURITY ;
13971396 if (!ready) {
13981397 static int s_log_ctr = 0 ;
13991398 if (s_log_ctr++ % 20 == 0 )
1400- LOG_INFO << " [EMB-LTC] UTXO maturity gate: chain= " << chain_h
1401- << " utxo= " << utxo_h << " need gap< " << LTC_MATURITY ;
1399+ LOG_INFO << " [EMB-LTC] UTXO maturity gate: blocks_connected= "
1400+ << connected << " need>= " << LTC_MATURITY ;
14021401 }
14031402 return ready;
14041403 });
@@ -1749,6 +1748,10 @@ int main(int argc, char* argv[]) {
17491748 utxo_db->put_block_undo (height, undo);
17501749 utxo->flush (block_hash, height);
17511750
1751+ // Prune old undo data matching litecoind MIN_BLOCKS_TO_KEEP = 288
1752+ // Reference: litecoin/src/validation.h MIN_BLOCKS_TO_KEEP
1753+ utxo->prune_undo (height, core::coin::LTC_MIN_BLOCKS_TO_KEEP );
1754+
17521755 static int utxo_log = 0 ;
17531756 if (utxo_log++ % 10 == 0 ) {
17541757 LOG_INFO << " [EMB-LTC] UTXO: connected block " << height
@@ -3537,21 +3540,20 @@ int main(int argc, char* argv[]) {
35373540 {
35383541 auto backend = std::make_unique<doge::coin::AuxChainEmbedded>(
35393542 *doge_chain, *doge_pool, *doge_params_ptr, cfg);
3540- // Gate mining until UTXO has coinbase maturity depth (240 blocks).
3543+ // Gate mining until UTXO has coinbase maturity depth (240 blocks for DOGE ).
35413544 // Without this, block templates may include TXs spending immature coinbase outputs.
3542- if (doge_utxo_db) {
3543- auto * db_ptr = doge_utxo_db. get ();
3544- auto * chain_ptr = doge_chain .get ();
3545+ // Reference: dogecoin/src/chainparams.cpp digishieldConsensus.nCoinbaseMaturity = 240
3546+ if (doge_utxo_cache) {
3547+ auto * cache_ptr = doge_utxo_cache .get ();
35453548 constexpr uint32_t DOGE_MATURITY = core::coin::DOGE_LIMITS .coinbase_maturity ;
3546- backend->embedded_node ().set_utxo_ready_fn ([db_ptr, chain_ptr, DOGE_MATURITY ]() {
3547- auto chain_h = chain_ptr->height ();
3548- auto utxo_h = db_ptr->get_best_height ();
3549- bool ready = utxo_h > 0 && chain_h > 0 && (chain_h - utxo_h) < DOGE_MATURITY ;
3549+ backend->embedded_node ().set_utxo_ready_fn ([cache_ptr, DOGE_MATURITY ]() {
3550+ auto connected = cache_ptr->blocks_connected ();
3551+ bool ready = connected >= DOGE_MATURITY ;
35503552 if (!ready) {
35513553 static int s_log_ctr = 0 ;
35523554 if (s_log_ctr++ % 20 == 0 )
3553- LOG_INFO << " [EMB-DOGE] UTXO maturity gate: chain= " << chain_h
3554- << " utxo= " << utxo_h << " need gap< " << DOGE_MATURITY ;
3555+ LOG_INFO << " [EMB-DOGE] UTXO maturity gate: blocks_connected= "
3556+ << connected << " need>= " << DOGE_MATURITY ;
35553557 }
35563558 return ready;
35573559 });
@@ -3768,6 +3770,11 @@ int main(int argc, char* argv[]) {
37683770 auto undo = utxo->connect_block (block, height, txid_fn);
37693771 utxo_db->put_block_undo (height, undo);
37703772 utxo->flush (block_hash, height);
3773+
3774+ // Prune old undo data matching dogecoind MIN_BLOCKS_TO_KEEP = 1440
3775+ // Reference: dogecoin/src/validation.h MIN_BLOCKS_TO_KEEP
3776+ utxo->prune_undo (height, core::coin::DOGE_MIN_BLOCKS_TO_KEEP );
3777+
37713778 LOG_INFO << " [EMB-DOGE] UTXO: connected block " << height
37723779 << " hash=" << block_hash.GetHex ().substr (0 , 16 )
37733780 << " txs=" << block.m_txs .size ()
0 commit comments