Skip to content

Commit

Permalink
CAsset: GetIdentifier to get label or hex id
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-jr authored and instagibbs committed Apr 9, 2019
1 parent d81c9f7 commit 047799c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
7 changes: 7 additions & 0 deletions src/assetsdir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ std::string CAssetsDir::GetLabel(const CAsset& asset) const
return GetMetadata(asset).GetLabel();
}

std::string CAssetsDir::GetIdentifier(const CAsset& asset) const
{
const std::string label = GetMetadata(asset).GetLabel();
if (!label.empty()) return label;
return asset.GetHex();
}

std::vector<CAsset> CAssetsDir::GetKnownAssets() const
{
std::vector<CAsset> knownAssets;
Expand Down
3 changes: 3 additions & 0 deletions src/assetsdir.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ class CAssetsDir
/** @return the label associated to the asset id */
std::string GetLabel(const CAsset& asset) const;

/** @return the label associated to the asset id, or some other identifier */
std::string GetIdentifier(const CAsset& asset) const;

std::vector<CAsset> GetKnownAssets() const;
};

Expand Down
6 changes: 1 addition & 5 deletions src/qt/guiutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -790,12 +790,8 @@ QString formatAssetAmount(const CAsset& asset, const CAmount& amount, const int
if (fraction) {
str += QString(".%1").arg(fraction, 8, 10, QLatin1Char('0'));
}
std::string asset_label = gAssetsDir.GetLabel(asset);
if (asset_label.empty()) {
asset_label = asset.GetHex();
}
if (include_asset_name) {
str += QString(" ") + QString::fromStdString(asset_label);
str += QString(" ") + QString::fromStdString(gAssetsDir.GetIdentifier(asset));
}
return str;
}
Expand Down

0 comments on commit 047799c

Please sign in to comment.