本文整理汇总了C++中Identifier::CalculateDigest方法的典型用法代码示例。如果您正苦于以下问题:C++ Identifier::CalculateDigest方法的具体用法?C++ Identifier::CalculateDigest怎么用?C++ Identifier::CalculateDigest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Identifier
的用法示例。
在下文中一共展示了Identifier::CalculateDigest方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ID
const Identifier PaymentCode::ID() const
{
uint8_t core[65]{};
OTData pubkey = Pubkey();
OTPassword::safe_memcpy(
&core[0],
33,
pubkey.GetPointer(),
pubkey.GetSize(),
false);
if (chain_code_.GetSize() == 32) {
OTPassword::safe_memcpy(
&core[33],
32,
chain_code_.GetPointer(),
chain_code_.GetSize(),
false);
}
OTData dataVersion(core, sizeof(core));
Identifier paymentCodeID;
paymentCodeID.CalculateDigest(dataVersion);
return paymentCodeID;
}
示例2: blah
/*
Let's say you wanted to add an Offer to a Market. But you don't know
which market. There are different markets for different combinations
of asset and currency. There are also higher and lower level markets
for different trade minimums.
The server has to be able to match up your Offer to the Right Market,
so that it can trade with similar offers.
So in this method, I combine the Instrument Definition ID, the Currency Type
ID,
and the minimum increment, and use them to generate a UNIQUE ID, which
will also be the same, given the same input.
That is the ID I will use for looking up the offers on the market.
Basically it's the Market ID, and the Offer just has the SAME ID,
and that's how you match it up to the market.
(This is analogous to how Transactions and Transaction Items have the
same transaction number.)
THIS MEANS that the user cannot simply set his minimum increment to
a "divide-into equally" with the market minimum increment. Why not?
Because since his number will be different from the next guy, they
will calculate different IDs and thus end up on different markets.
TODO: therefore the user MUST SUPPLY the EXACT SAME minimum increment
of the market he wishes to trade on. There's no other way. However,
I CAN allow the user to ALSO provide a second minimum, which must be
a multiple of the first.
TODO: Should add this same method to the Market object as well.
To use OTOffer::GetIdentifier is simple:
void blah (OTOffer& theOffer)
{
OTIdentifier MARKET_ID(theOffer); // the magic happens right here.
// (Done.)
}
*/
void OTOffer::GetIdentifier(Identifier& theIdentifier) const
{
String strTemp, strAsset(GetInstrumentDefinitionID()),
strCurrency(GetCurrencyID());
int64_t lScale = GetScale();
// In this way we generate a unique ID that will always be consistent
// for the same instrument definition id, currency ID, and market scale.
strTemp.Format(
"ASSET TYPE:\n%s\nCURRENCY TYPE:\n%s\nMARKET SCALE:\n%" PRId64 "\n",
strAsset.Get(), strCurrency.Get(), lScale);
theIdentifier.CalculateDigest(strTemp);
}