Line data Source code
1 : // Copyright (c) 2014-2021 The Dash Core developers 2 : // Copyright (c) 2021 The PIVX Core developers 3 : // Distributed under the X11 software license, see the accompanying 4 : // file COPYING or https://www.opensource.org/licenses/mit-license.php. 5 : 6 : #include "tiertwo/masternode_meta_manager.h" 7 : #include <sstream> 8 : 9 : CMasternodeMetaMan g_mmetaman; 10 : 11 : const std::string CMasternodeMetaMan::SERIALIZATION_VERSION_STRING = "CMasternodeMetaMan-Version-2"; 12 : 13 951 : CMasternodeMetaInfoPtr CMasternodeMetaMan::GetMetaInfo(const uint256& proTxHash, bool fCreate) 14 : { 15 1902 : LOCK(cs_metaman); 16 951 : auto it = metaInfos.find(proTxHash); 17 951 : if (it != metaInfos.end()) { 18 848 : return it->second; 19 : } 20 103 : if (!fCreate) { 21 0 : return nullptr; 22 : } 23 206 : it = metaInfos.emplace(proTxHash, std::make_shared<CMasternodeMetaInfo>(proTxHash)).first; 24 951 : return it->second; 25 : } 26 : 27 : 28 76 : void CMasternodeMetaMan::Clear() 29 : { 30 76 : LOCK(cs_metaman); 31 76 : metaInfos.clear(); 32 76 : } 33 : 34 461 : std::string CMasternodeMetaMan::ToString() 35 : { 36 461 : LOCK(cs_metaman); 37 922 : std::ostringstream info; 38 : 39 461 : info << "Masternodes: meta infos object count: " << (int)metaInfos.size(); 40 922 : return info.str(); 41 : }