|
7 | 7 | #include <evo/dmnstate.h> |
8 | 8 | #include <evo/evodb.h> |
9 | 9 | #include <evo/providertx.h> |
| 10 | +#include <evo/simplifiedmns.h> |
10 | 11 | #include <evo/specialtx.h> |
11 | 12 | #include <index/txindex.h> |
12 | 13 |
|
@@ -258,6 +259,14 @@ std::vector<CDeterministicMNCPtr> CDeterministicMNList::GetProjectedMNPayees(gsl |
258 | 259 | return result; |
259 | 260 | } |
260 | 261 |
|
| 262 | +gsl::not_null<std::shared_ptr<const CSimplifiedMNList>> CDeterministicMNList::GetSML() const |
| 263 | +{ |
| 264 | + if (!m_cached_sml) { |
| 265 | + m_cached_sml = std::make_shared<const CSimplifiedMNList>(*this); |
| 266 | + } |
| 267 | + return m_cached_sml; |
| 268 | +} |
| 269 | + |
261 | 270 | int CDeterministicMNList::CalcMaxPoSePenalty() const |
262 | 271 | { |
263 | 272 | // Maximum PoSe penalty is dynamic and equals the number of registered MNs |
@@ -443,6 +452,7 @@ void CDeterministicMNList::AddMN(const CDeterministicMNCPtr& dmn, bool fBumpTota |
443 | 452 |
|
444 | 453 | mnMap = mnMap.set(dmn->proTxHash, dmn); |
445 | 454 | mnInternalIdMap = mnInternalIdMap.set(dmn->GetInternalId(), dmn->proTxHash); |
| 455 | + m_cached_sml = nullptr; |
446 | 456 | if (fBumpTotalCount) { |
447 | 457 | // nTotalRegisteredCount acts more like a checkpoint, not as a limit, |
448 | 458 | nTotalRegisteredCount = std::max(dmn->GetInternalId() + 1, (uint64_t)nTotalRegisteredCount); |
@@ -514,6 +524,9 @@ void CDeterministicMNList::UpdateMN(const CDeterministicMN& oldDmn, const std::s |
514 | 524 |
|
515 | 525 | dmn->pdmnState = pdmnState; |
516 | 526 | mnMap = mnMap.set(oldDmn.proTxHash, dmn); |
| 527 | + if (m_cached_sml && CSimplifiedMNListEntry{oldDmn} != CSimplifiedMNListEntry{*dmn}) { |
| 528 | + m_cached_sml = nullptr; |
| 529 | + } |
517 | 530 | } |
518 | 531 |
|
519 | 532 | void CDeterministicMNList::UpdateMN(const uint256& proTxHash, const std::shared_ptr<const CDeterministicMNState>& pdmnState) |
@@ -585,6 +598,7 @@ void CDeterministicMNList::RemoveMN(const uint256& proTxHash) |
585 | 598 |
|
586 | 599 | mnMap = mnMap.erase(proTxHash); |
587 | 600 | mnInternalIdMap = mnInternalIdMap.erase(dmn->GetInternalId()); |
| 601 | + m_cached_sml = nullptr; |
588 | 602 | } |
589 | 603 |
|
590 | 604 | bool CDeterministicMNManager::ProcessBlock(const CBlock& block, gsl::not_null<const CBlockIndex*> pindex, |
|
0 commit comments