本文整理汇总了C++中cryptonote::WalletGreen::getUnconfirmedTransactions方法的典型用法代码示例。如果您正苦于以下问题:C++ WalletGreen::getUnconfirmedTransactions方法的具体用法?C++ WalletGreen::getUnconfirmedTransactions怎么用?C++ WalletGreen::getUnconfirmedTransactions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cryptonote::WalletGreen
的用法示例。
在下文中一共展示了WalletGreen::getUnconfirmedTransactions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: optimize
bool optimize(CryptoNote::WalletGreen &wallet, uint64_t threshold)
{
std::vector<Crypto::Hash> fusionTransactionHashes;
while (true)
{
/* Create as many fusion transactions until we can't send anymore,
either because balance is locked too much or we can no longer
optimize anymore transactions */
const size_t tmpFusionTxID = makeFusionTransaction(wallet, threshold);
if (tmpFusionTxID == CryptoNote::WALLET_INVALID_TRANSACTION_ID)
{
break;
}
else
{
const CryptoNote::WalletTransaction w
= wallet.getTransaction(tmpFusionTxID);
fusionTransactionHashes.push_back(w.hash);
if (fusionTransactionHashes.size() == 1)
{
std::cout << SuccessMsg("Created 1 fusion transaction!")
<< std::endl;
}
else
{
std::cout << SuccessMsg("Created "
+ std::to_string(fusionTransactionHashes.size())
+ " fusion transactions!") << std::endl;
}
}
}
if (fusionTransactionHashes.empty())
{
return false;
}
/* Hurr durr grammar */
if (fusionTransactionHashes.size() == 1)
{
std::cout << SuccessMsg("1 fusion transaction has been sent, waiting "
"for balance to return and unlock")
<< std::endl << std::endl;
}
else
{
std::cout << SuccessMsg(std::to_string(fusionTransactionHashes.size()) +
" fusion transactions have been sent, waiting "
"for balance to return and unlock")
<< std::endl << std::endl;
}
wallet.updateInternalCache();
/* Short sleep to ensure it's in the transaction pool when we poll it */
std::this_thread::sleep_for(std::chrono::seconds(1));
while (true)
{
const std::vector<CryptoNote::WalletTransactionWithTransfers>
unconfirmedTransactions = wallet.getUnconfirmedTransactions();
std::vector<Crypto::Hash> unconfirmedTxHashes;
for (const auto &t : unconfirmedTransactions)
{
unconfirmedTxHashes.push_back(t.transaction.hash);
}
bool fusionCompleted = true;
/* Is our fusion transaction still unconfirmed? We can't gain the
benefits of fusioning if the balance hasn't unlocked, so we can
send this new optimized balance */
for (const auto &tx : fusionTransactionHashes)
{
/* If the fusion transaction hash is present in the unconfirmed
transactions pool, we need to wait for it to complete. */
if (std::find(unconfirmedTxHashes.begin(),
unconfirmedTxHashes.end(), tx)
!= unconfirmedTxHashes.end())
{
fusionCompleted = false;
}
else
{
/* We can't find this transaction in the unconfirmed
transaction pool anymore, so it has been confirmed. Remove
it so we both have to check less transactions each time,
and we can easily update the transactions left to confirm
output message */
fusionTransactionHashes.erase(std::remove
(fusionTransactionHashes.begin(),
fusionTransactionHashes.end(), tx),
fusionTransactionHashes.end());
}
//.........这里部分代码省略.........