@@ -465,10 +465,28 @@ csdb::Address BlockChain::getAddressFromKey(const std::string& key) {
465465
466466void BlockChain::removeLastBlockFromTrxIndex (const csdb::Pool& pool) {
467467 std::set<csdb::Address> uniqueAddresses;
468+ std::vector<std::pair<cs::PublicKey, csdb::TransactionID>> updates;
468469
469- auto lbd = [&uniqueAddresses, this ](const csdb::Address& addr, cs::Sequence sq) {
470+ auto lbd = [&updates, & uniqueAddresses, this ](const csdb::Address& addr, cs::Sequence sq) {
470471 auto key = getAddressByType (addr, AddressType::PublicKey);
472+
471473 if (uniqueAddresses.insert (key).second ) {
474+ auto it = TransactionsIterator (*this , addr);
475+ it.next ();
476+ bool found = false ;
477+
478+ for (; it.isValid (); it.next ()) {
479+ if (it->id ().pool_seq () < sq) {
480+ updates.push_back (std::make_pair (key.public_key (), it->id ()));
481+ found = true ;
482+ break ;
483+ }
484+ }
485+ if (!found) {
486+ updates.push_back (std::make_pair (key.public_key (),
487+ csdb::TransactionID (kWrongSequence , kWrongSequence )));
488+ }
489+
472490 std::lock_guard<decltype (dbLock_)> l (dbLock_);
473491 storage_.remove_last_from_trx_index (key, sq);
474492 }
@@ -485,6 +503,11 @@ void BlockChain::removeLastBlockFromTrxIndex(const csdb::Pool& pool) {
485503 lastNonEmptyBlock_ = previousNonEmpty_[lastNonEmptyBlock_.poolSeq ];
486504 previousNonEmpty_.erase (pool.sequence ());
487505 }
506+
507+ if (updates.size ()) {
508+ std::lock_guard l (cacheMutex_);
509+ walletsCacheUpdater_->updateLastTransactions (updates);
510+ }
488511}
489512
490513void BlockChain::removeWalletsInPoolFromCache (const csdb::Pool& pool) {
0 commit comments