Raven Core  3.0.0
P2P Digital Currency
Public Member Functions | Public Attributes | Private Member Functions | List of all members
CAssetsCache Class Reference

#include <assets.h>

Inheritance diagram for CAssetsCache:
[legend]
Collaboration diagram for CAssetsCache:
[legend]

Public Member Functions

 CAssetsCache ()
 
 CAssetsCache (const CAssetsCache &cache)
 
CAssetsCacheoperator= (const CAssetsCache &cache)
 
bool RemoveNewAsset (const CNewAsset &asset, const std::string address)
 Cache only undo functions. More...
 
bool RemoveTransfer (const CAssetTransfer &transfer, const std::string &address, const COutPoint &out)
 Changes Memory Only. More...
 
bool RemoveOwnerAsset (const std::string &assetsName, const std::string address)
 Changes Memory Only. More...
 
bool RemoveReissueAsset (const CReissueAsset &reissue, const std::string address, const COutPoint &out, const std::vector< std::pair< std::string, CBlockAssetUndo > > &vUndoIPFS)
 Changes Memory Only. More...
 
bool UndoAssetCoin (const Coin &coin, const COutPoint &out)
 
bool RemoveQualifierAddress (const std::string &assetName, const std::string &address, const QualifierType type)
 Changes Memory Only, this is only called when undoing a block from the chain. More...
 
bool RemoveRestrictedAddress (const std::string &assetName, const std::string &address, const RestrictedType type)
 Changes Memory Only, this is only called when undoing a block from the chain. More...
 
bool RemoveGlobalRestricted (const std::string &assetName, const RestrictedType type)
 Changes Memory Only, this is only called when undoing a block from the chain. More...
 
bool RemoveRestrictedVerifier (const std::string &assetName, const std::string &verifier, const bool fUndoingReissue=false)
 Changes Memory Only. More...
 
bool AddNewAsset (const CNewAsset &asset, const std::string address, const int &nHeight, const uint256 &blockHash)
 Cache only add asset functions. More...
 
bool AddTransferAsset (const CAssetTransfer &transferAsset, const std::string &address, const COutPoint &out, const CTxOut &txOut)
 
bool AddOwnerAsset (const std::string &assetsName, const std::string address)
 Changes Memory Only. More...
 
bool AddReissueAsset (const CReissueAsset &reissue, const std::string address, const COutPoint &out)
 Changes Memory Only. More...
 
bool AddQualifierAddress (const std::string &assetName, const std::string &address, const QualifierType type)
 Changes Memory Only, this only called when adding a block to the chain. More...
 
bool AddRestrictedAddress (const std::string &assetName, const std::string &address, const RestrictedType type)
 Changes Memory Only, this only called when adding a block to the chain. More...
 
bool AddGlobalRestricted (const std::string &assetName, const RestrictedType type)
 Changes Memory Only, this only called when adding a block to the chain. More...
 
bool AddRestrictedVerifier (const std::string &assetName, const std::string &verifier)
 Changes Memory Only. More...
 
bool TrySpendCoin (const COutPoint &out, const CTxOut &coin)
 Cache only validation functions. More...
 
bool ContainsAsset (const CNewAsset &asset)
 Help functions. More...
 
bool ContainsAsset (const std::string &assetName)
 
bool CheckIfAssetExists (const std::string &name, bool fForceDuplicateCheck=true)
 Returns true if an asset with this name already exists. More...
 
bool GetAssetMetaDataIfExists (const std::string &name, CNewAsset &asset)
 Returns true if an asset with the name exists, and it was able to get the asset metadata from database. More...
 
bool GetAssetMetaDataIfExists (const std::string &name, CNewAsset &asset, int &nHeight, uint256 &blockHash)
 
bool GetAssetVerifierStringIfExists (const std::string &name, CNullAssetTxVerifierString &verifier, bool fSkipTempCache=false)
 Returns true if the Asset Verifier String was found for an asset_name, if fSkipTempCache is true, it will only search passets pointer and databases. More...
 
bool CheckForAddressQualifier (const std::string &qualifier_name, const std::string &address, bool fSkipTempCache=false)
 Return true if the address has the given qualifier assigned to it. More...
 
bool CheckForAddressRestriction (const std::string &restricted_name, const std::string &address, bool fSkipTempCache=false)
 Return true if the address is marked as frozen. More...
 
bool CheckForGlobalRestriction (const std::string &restricted_name, bool fSkipTempCache=false)
 Return true if the restricted asset is globally freezing trading. More...
 
size_t DynamicMemoryUsage () const
 Calculate the size of the CAssets (in bytes) More...
 
size_t GetCacheSize () const
 Get the size of the none databased cache. More...
 
size_t GetCacheSizeV2 () const
 Get an estimated size of the cache in bytes that will be needed inorder to save to database. More...
 
bool Flush ()
 Flush all new cache entries into the passets global cache. More...
 
bool DumpCacheToDatabase ()
 Write asset cache data to database. More...
 
void ClearDirtyCache ()
 Clear all dirty cache sets, vetors, and maps. More...
 
std::string CacheToString () const
 
- Public Member Functions inherited from CAssets
 CAssets (const CAssets &assets)
 
CAssetsoperator= (const CAssets &other)
 
 CAssets ()
 
void SetNull ()
 

Public Attributes

std::vector< CAssetCacheUndoAssetAmountvUndoAssetAmount
 These are memory only containers that show dirty entries that will be databased when flushed. More...
 
std::vector< CAssetCacheSpendAssetvSpentAssets
 
std::set< CAssetCacheNewAssetsetNewAssetsToRemove
 New Assets Caches. More...
 
std::set< CAssetCacheNewAssetsetNewAssetsToAdd
 
std::set< CAssetCacheReissueAssetsetNewReissueToRemove
 New Reissue Caches. More...
 
std::set< CAssetCacheReissueAssetsetNewReissueToAdd
 
std::set< CAssetCacheNewOwnersetNewOwnerAssetsToAdd
 Ownership Assets Caches. More...
 
std::set< CAssetCacheNewOwnersetNewOwnerAssetsToRemove
 
std::set< CAssetCacheNewTransfersetNewTransferAssetsToAdd
 Transfer Assets Caches. More...
 
std::set< CAssetCacheNewTransfersetNewTransferAssetsToRemove
 
std::set< CAssetCacheQualifierAddresssetNewQualifierAddressToAdd
 Qualfier Address Asset Caches. More...
 
std::set< CAssetCacheQualifierAddresssetNewQualifierAddressToRemove
 
std::set< CAssetCacheRestrictedAddresssetNewRestrictedAddressToAdd
 Restricted Address Asset Caches. More...
 
std::set< CAssetCacheRestrictedAddresssetNewRestrictedAddressToRemove
 
std::set< CAssetCacheRestrictedGlobalsetNewRestrictedGlobalToAdd
 Restricted Global Asset Caches. More...
 
std::set< CAssetCacheRestrictedGlobalsetNewRestrictedGlobalToRemove
 
std::set< CAssetCacheRestrictedVerifierssetNewRestrictedVerifierToAdd
 Restricted Assets Verifier Caches. More...
 
std::set< CAssetCacheRestrictedVerifierssetNewRestrictedVerifierToRemove
 
std::map< CAssetCacheRootQualifierChecker, std::set< std::string > > mapRootQualifierAddressesAdd
 Root Qualifier Address Map. More...
 
std::map< CAssetCacheRootQualifierChecker, std::set< std::string > > mapRootQualifierAddressesRemove
 
- Public Attributes inherited from CAssets
std::map< std::pair< std::string, std::string >, CAmountmapAssetsAddressAmount
 
std::map< std::string, CNewAssetmapReissuedAssetData
 

Private Member Functions

bool AddBackSpentAsset (const Coin &coin, const std::string &assetName, const std::string &address, const CAmount &nAmount, const COutPoint &out)
 Changes Memory Only. More...
 
void AddToAssetBalance (const std::string &strName, const std::string &address, const CAmount &nAmount)
 
bool UndoTransfer (const CAssetTransfer &transfer, const std::string &address, const COutPoint &outToRemove)
 Changes Memory Only. More...
 

Detailed Description

Definition at line 100 of file assets.h.

Constructor & Destructor Documentation

◆ CAssetsCache() [1/2]

CAssetsCache::CAssetsCache ( )
inline

Definition at line 147 of file assets.h.

Here is the call graph for this function:

◆ CAssetsCache() [2/2]

CAssetsCache::CAssetsCache ( const CAssetsCache cache)
inline

Copy dirty cache also

Transfer Caches

Issue Caches

Reissue Caches

Owner Caches

Qualifier Caches

Restricted Address Caches

Restricted Global Caches

Restricted Verifier Caches

Root Qualifier Address Map

Definition at line 153 of file assets.h.

Member Function Documentation

◆ AddBackSpentAsset()

bool CAssetsCache::AddBackSpentAsset ( const Coin coin,
const std::string &  assetName,
const std::string &  address,
const CAmount nAmount,
const COutPoint out 
)
private

Changes Memory Only.

Definition at line 1769 of file assets.cpp.

Here is the call graph for this function:

◆ AddGlobalRestricted()

bool CAssetsCache::AddGlobalRestricted ( const std::string &  assetName,
const RestrictedType  type 
)

Changes Memory Only, this only called when adding a block to the chain.

Definition at line 2138 of file assets.cpp.

Here is the caller graph for this function:

◆ AddNewAsset()

bool CAssetsCache::AddNewAsset ( const CNewAsset asset,
const std::string  address,
const int &  nHeight,
const uint256 blockHash 
)

Cache only add asset functions.

Changes Memory Only.

Definition at line 1836 of file assets.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddOwnerAsset()

bool CAssetsCache::AddOwnerAsset ( const std::string &  assetsName,
const std::string  address 
)

Changes Memory Only.

Definition at line 1979 of file assets.cpp.

Here is the caller graph for this function:

◆ AddQualifierAddress()

bool CAssetsCache::AddQualifierAddress ( const std::string &  assetName,
const std::string &  address,
const QualifierType  type 
)

Changes Memory Only, this only called when adding a block to the chain.

Definition at line 2031 of file assets.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddReissueAsset()

bool CAssetsCache::AddReissueAsset ( const CReissueAsset reissue,
const std::string  address,
const COutPoint out 
)

Changes Memory Only.

Definition at line 1857 of file assets.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddRestrictedAddress()

bool CAssetsCache::AddRestrictedAddress ( const std::string &  assetName,
const std::string &  address,
const RestrictedType  type 
)

Changes Memory Only, this only called when adding a block to the chain.

Definition at line 2096 of file assets.cpp.

Here is the caller graph for this function:

◆ AddRestrictedVerifier()

bool CAssetsCache::AddRestrictedVerifier ( const std::string &  assetName,
const std::string &  verifier 
)

Changes Memory Only.

Definition at line 2180 of file assets.cpp.

Here is the caller graph for this function:

◆ AddToAssetBalance()

void CAssetsCache::AddToAssetBalance ( const std::string &  strName,
const std::string &  address,
const CAmount nAmount 
)
private

Definition at line 1616 of file assets.cpp.

Here is the call graph for this function:

◆ AddTransferAsset()

bool CAssetsCache::AddTransferAsset ( const CAssetTransfer transferAsset,
const std::string &  address,
const COutPoint out,
const CTxOut txOut 
)

Definition at line 1601 of file assets.cpp.

Here is the caller graph for this function:

◆ CacheToString()

std::string CAssetsCache::CacheToString ( ) const
inline

Definition at line 341 of file assets.h.

◆ CheckForAddressQualifier()

bool CAssetsCache::CheckForAddressQualifier ( const std::string &  qualifier_name,
const std::string &  address,
bool  fSkipTempCache = false 
)

Return true if the address has the given qualifier assigned to it.

There are circumstances where a blocks transactions could be removing or adding a qualifier to an address, While at the same time a transaction is added to the same block that is trying to transfer to the same address. Depending on the ordering of these two transactions. The qualifier database used to verify the validity of the transactions could be different. To fix this all restricted asset transfer validation checks will use only the latest connect block tips caches and databases to validate it. This allows for asset transfers and address qualifier transactions to be added in the same block without failing validation

Definition at line 4514 of file assets.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckForAddressRestriction()

bool CAssetsCache::CheckForAddressRestriction ( const std::string &  restricted_name,
const std::string &  address,
bool  fSkipTempCache = false 
)

Return true if the address is marked as frozen.

There are circumstances where a blocks transactions could be removing or adding a restriction to an address, While at the same time a transaction is added to the same block that is trying to transfer from that address. Depending on the ordering of these two transactions. The address restriction database used to verify the validity of the transactions could be different. To fix this all restricted asset transfer validation checks will use only the latest connect block tips caches and databases to validate it. This allows for asset transfers and address restriction transactions to be added in the same block without failing validation

Definition at line 4593 of file assets.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckForGlobalRestriction()

bool CAssetsCache::CheckForGlobalRestriction ( const std::string &  restricted_name,
bool  fSkipTempCache = false 
)

Return true if the restricted asset is globally freezing trading.

There are circumstances where a blocks transactions could be freezing all asset transfers. While at the same time a transaction is added to the same block that is trying to transfer the same asset that is being frozen. Depending on the ordering of these two transactions. The global restriction database used to verify the validity of the transactions could be different. To fix this all restricted asset transfer validation checks will use only the latest connect block tips caches and databases to validate it. This allows for asset transfers and global restriction transactions to be added in the same block without failing validation

Definition at line 4651 of file assets.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckIfAssetExists()

bool CAssetsCache::CheckIfAssetExists ( const std::string &  name,
bool  fForceDuplicateCheck = true 
)

Returns true if an asset with this name already exists.

Returns a boolean on if the asset exists.

Definition at line 3271 of file assets.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClearDirtyCache()

void CAssetsCache::ClearDirtyCache ( )
inline

Clear all dirty cache sets, vetors, and maps.

Definition at line 305 of file assets.h.

◆ ContainsAsset() [1/2]

bool CAssetsCache::ContainsAsset ( const CNewAsset asset)

Help functions.

Definition at line 1699 of file assets.cpp.

◆ ContainsAsset() [2/2]

bool CAssetsCache::ContainsAsset ( const std::string &  assetName)

Definition at line 1704 of file assets.cpp.

◆ DumpCacheToDatabase()

bool CAssetsCache::DumpCacheToDatabase ( )

Write asset cache data to database.

Definition at line 2207 of file assets.cpp.

Here is the call graph for this function:

◆ DynamicMemoryUsage()

size_t CAssetsCache::DynamicMemoryUsage ( ) const

Calculate the size of the CAssets (in bytes)

Get the amount of memory the cache is using.

Definition at line 2935 of file assets.cpp.

◆ Flush()

bool CAssetsCache::Flush ( )

Flush all new cache entries into the passets global cache.

Do not call this function on the passets pointer.

Definition at line 2750 of file assets.cpp.

Here is the call graph for this function:

◆ GetAssetMetaDataIfExists() [1/2]

bool CAssetsCache::GetAssetMetaDataIfExists ( const std::string &  name,
CNewAsset asset 
)

Returns true if an asset with the name exists, and it was able to get the asset metadata from database.

Definition at line 3340 of file assets.cpp.

Here is the caller graph for this function:

◆ GetAssetMetaDataIfExists() [2/2]

bool CAssetsCache::GetAssetMetaDataIfExists ( const std::string &  name,
CNewAsset asset,
int &  nHeight,
uint256 blockHash 
)

Definition at line 3347 of file assets.cpp.

Here is the call graph for this function:

◆ GetAssetVerifierStringIfExists()

bool CAssetsCache::GetAssetVerifierStringIfExists ( const std::string &  name,
CNullAssetTxVerifierString verifier,
bool  fSkipTempCache = false 
)

Returns true if the Asset Verifier String was found for an asset_name, if fSkipTempCache is true, it will only search passets pointer and databases.

There are circumstances where a blocks transactions could be changing an assets verifier string, While at the same time a transaction is added to the same block that is trying to transfer the assets who verifier string is changing. Depending on the ordering of these two transactions. The verifier string used to verify the validity of the transaction could be different. To fix this all restricted asset transfer validation checks will use only the latest connect block tips caches and databases to validate it. This allows for asset transfers and verify string change transactions to be added in the same block without failing validation

Definition at line 4445 of file assets.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetCacheSize()

size_t CAssetsCache::GetCacheSize ( ) const

Get the size of the none databased cache.

Get an estimated size of the cache in bytes that will be needed inorder to save to database.

Definition at line 2942 of file assets.cpp.

◆ GetCacheSizeV2()

size_t CAssetsCache::GetCacheSizeV2 ( ) const

Get an estimated size of the cache in bytes that will be needed inorder to save to database.

Definition at line 2978 of file assets.cpp.

◆ operator=()

CAssetsCache& CAssetsCache::operator= ( const CAssetsCache cache)
inline

Copy dirty cache also

Transfer Caches

Issue Caches

Reissue Caches

Owner Caches

Qualifier Caches

Restricted Address Caches

Restricted Global Caches

Restricted Verifier Caches

Root Qualifier Address Map

Definition at line 196 of file assets.h.

Here is the call graph for this function:

◆ RemoveGlobalRestricted()

bool CAssetsCache::RemoveGlobalRestricted ( const std::string &  assetName,
const RestrictedType  type 
)

Changes Memory Only, this is only called when undoing a block from the chain.

Definition at line 2159 of file assets.cpp.

◆ RemoveNewAsset()

bool CAssetsCache::RemoveNewAsset ( const CNewAsset asset,
const std::string  address 
)

Cache only undo functions.

Changes Memory Only.

Definition at line 1817 of file assets.cpp.

Here is the call graph for this function:

◆ RemoveOwnerAsset()

bool CAssetsCache::RemoveOwnerAsset ( const std::string &  assetsName,
const std::string  address 
)

Changes Memory Only.

Definition at line 1998 of file assets.cpp.

◆ RemoveQualifierAddress()

bool CAssetsCache::RemoveQualifierAddress ( const std::string &  assetName,
const std::string &  address,
const QualifierType  type 
)

Changes Memory Only, this is only called when undoing a block from the chain.

Definition at line 2062 of file assets.cpp.

Here is the call graph for this function:

◆ RemoveReissueAsset()

bool CAssetsCache::RemoveReissueAsset ( const CReissueAsset reissue,
const std::string  address,
const COutPoint out,
const std::vector< std::pair< std::string, CBlockAssetUndo > > &  vUndoIPFS 
)

Changes Memory Only.

Definition at line 1913 of file assets.cpp.

Here is the call graph for this function:

◆ RemoveRestrictedAddress()

bool CAssetsCache::RemoveRestrictedAddress ( const std::string &  assetName,
const std::string &  address,
const RestrictedType  type 
)

Changes Memory Only, this is only called when undoing a block from the chain.

Definition at line 2117 of file assets.cpp.

◆ RemoveRestrictedVerifier()

bool CAssetsCache::RemoveRestrictedVerifier ( const std::string &  assetName,
const std::string &  verifier,
const bool  fUndoingReissue = false 
)

Changes Memory Only.

Definition at line 2194 of file assets.cpp.

◆ RemoveTransfer()

bool CAssetsCache::RemoveTransfer ( const CAssetTransfer transfer,
const std::string &  address,
const COutPoint out 
)

Changes Memory Only.

Definition at line 2016 of file assets.cpp.

Here is the call graph for this function:

◆ TrySpendCoin()

bool CAssetsCache::TrySpendCoin ( const COutPoint out,
const CTxOut coin 
)

Cache only validation functions.

Definition at line 1634 of file assets.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UndoAssetCoin()

bool CAssetsCache::UndoAssetCoin ( const Coin coin,
const COutPoint out 
)

Definition at line 1709 of file assets.cpp.

Here is the call graph for this function:

◆ UndoTransfer()

bool CAssetsCache::UndoTransfer ( const CAssetTransfer transfer,
const std::string &  address,
const COutPoint outToRemove 
)
private

Changes Memory Only.

Definition at line 1790 of file assets.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ mapRootQualifierAddressesAdd

std::map<CAssetCacheRootQualifierChecker, std::set<std::string> > CAssetsCache::mapRootQualifierAddressesAdd

Root Qualifier Address Map.

Definition at line 144 of file assets.h.

◆ mapRootQualifierAddressesRemove

std::map<CAssetCacheRootQualifierChecker, std::set<std::string> > CAssetsCache::mapRootQualifierAddressesRemove

Definition at line 145 of file assets.h.

◆ setNewAssetsToAdd

std::set<CAssetCacheNewAsset> CAssetsCache::setNewAssetsToAdd

Definition at line 113 of file assets.h.

◆ setNewAssetsToRemove

std::set<CAssetCacheNewAsset> CAssetsCache::setNewAssetsToRemove

New Assets Caches.

Definition at line 112 of file assets.h.

◆ setNewOwnerAssetsToAdd

std::set<CAssetCacheNewOwner> CAssetsCache::setNewOwnerAssetsToAdd

Ownership Assets Caches.

Definition at line 120 of file assets.h.

◆ setNewOwnerAssetsToRemove

std::set<CAssetCacheNewOwner> CAssetsCache::setNewOwnerAssetsToRemove

Definition at line 121 of file assets.h.

◆ setNewQualifierAddressToAdd

std::set<CAssetCacheQualifierAddress> CAssetsCache::setNewQualifierAddressToAdd

Qualfier Address Asset Caches.

Definition at line 128 of file assets.h.

◆ setNewQualifierAddressToRemove

std::set<CAssetCacheQualifierAddress> CAssetsCache::setNewQualifierAddressToRemove

Definition at line 129 of file assets.h.

◆ setNewReissueToAdd

std::set<CAssetCacheReissueAsset> CAssetsCache::setNewReissueToAdd

Definition at line 117 of file assets.h.

◆ setNewReissueToRemove

std::set<CAssetCacheReissueAsset> CAssetsCache::setNewReissueToRemove

New Reissue Caches.

Definition at line 116 of file assets.h.

◆ setNewRestrictedAddressToAdd

std::set<CAssetCacheRestrictedAddress> CAssetsCache::setNewRestrictedAddressToAdd

Restricted Address Asset Caches.

Definition at line 132 of file assets.h.

◆ setNewRestrictedAddressToRemove

std::set<CAssetCacheRestrictedAddress> CAssetsCache::setNewRestrictedAddressToRemove

Definition at line 133 of file assets.h.

◆ setNewRestrictedGlobalToAdd

std::set<CAssetCacheRestrictedGlobal> CAssetsCache::setNewRestrictedGlobalToAdd

Restricted Global Asset Caches.

Definition at line 136 of file assets.h.

◆ setNewRestrictedGlobalToRemove

std::set<CAssetCacheRestrictedGlobal> CAssetsCache::setNewRestrictedGlobalToRemove

Definition at line 137 of file assets.h.

◆ setNewRestrictedVerifierToAdd

std::set<CAssetCacheRestrictedVerifiers> CAssetsCache::setNewRestrictedVerifierToAdd

Restricted Assets Verifier Caches.

Definition at line 140 of file assets.h.

◆ setNewRestrictedVerifierToRemove

std::set<CAssetCacheRestrictedVerifiers> CAssetsCache::setNewRestrictedVerifierToRemove

Definition at line 141 of file assets.h.

◆ setNewTransferAssetsToAdd

std::set<CAssetCacheNewTransfer> CAssetsCache::setNewTransferAssetsToAdd

Transfer Assets Caches.

Definition at line 124 of file assets.h.

◆ setNewTransferAssetsToRemove

std::set<CAssetCacheNewTransfer> CAssetsCache::setNewTransferAssetsToRemove

Definition at line 125 of file assets.h.

◆ vSpentAssets

std::vector<CAssetCacheSpendAsset> CAssetsCache::vSpentAssets

Definition at line 109 of file assets.h.

◆ vUndoAssetAmount

std::vector<CAssetCacheUndoAssetAmount> CAssetsCache::vUndoAssetAmount

These are memory only containers that show dirty entries that will be databased when flushed.

Definition at line 108 of file assets.h.


The documentation for this class was generated from the following files: