Skip to content

Instantly share code, notes, and snippets.

@xotonic
Last active January 29, 2019 19:08
Show Gist options
  • Save xotonic/51ffc8d8400c93e552c94115c1d51396 to your computer and use it in GitHub Desktop.
Save xotonic/51ffc8d8400c93e552c94115c1d51396 to your computer and use it in GitHub Desktop.
OrderId COrder::ComputeId()
{
if (cachedOrderId == 0) {
std::vector<unsigned char> vchId;
vchId.resize(256);
auto it = vchId.begin();
*it = base == "LUX" ? 0 : 1;
it++;
*it = rel == "LUX" ? 0 : 1;
it++;
std::copy_n(&baseAmount, sizeof(uint64_t), it);
it = std::next(it, sizeof(uint64_t));
std::copy_n(&relAmount, sizeof(uint64_t), it);
it = std::next(it, sizeof(uint64_t));
std::copy_n(&orderCreationTime, sizeof(uint64_t), it);
cachedOrderId = uint256(vchId);
LogPrintf("ComputeId: %s %s %s %s %s = %s\n", base, rel, baseAmount, relAmount, orderCreationTime, cachedOrderId.ToString());
}
return cachedOrderId;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment