本文整理汇总了C++中TransactionFramePtr::getSourceAccount方法的典型用法代码示例。如果您正苦于以下问题:C++ TransactionFramePtr::getSourceAccount方法的具体用法?C++ TransactionFramePtr::getSourceAccount怎么用?C++ TransactionFramePtr::getSourceAccount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TransactionFramePtr
的用法示例。
在下文中一共展示了TransactionFramePtr::getSourceAccount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sqltx
// TODO.3 this and checkValid share a lot of code
void
TxSetFrame::trimInvalid(Application& app,
std::vector<TransactionFramePtr>& trimmed)
{
soci::transaction sqltx(app.getDatabase().getSession());
app.getDatabase().setCurrentTransactionReadOnly();
sortForHash();
map<AccountID, vector<TransactionFramePtr>> accountTxMap;
for (auto tx : mTransactions)
{
accountTxMap[tx->getSourceID()].push_back(tx);
}
for (auto& item : accountTxMap)
{
// order by sequence number
std::sort(item.second.begin(), item.second.end(), SeqSorter);
TransactionFramePtr lastTx;
SequenceNumber lastSeq = 0;
int64_t totFee = 0;
for (auto& tx : item.second)
{
if (!tx->checkValid(app, lastSeq))
{
trimmed.push_back(tx);
removeTx(tx);
continue;
}
totFee += tx->getFee();
lastTx = tx;
lastSeq = tx->getSeqNum();
}
if (lastTx)
{
// make sure account can pay the fee for all these tx
int64_t newBalance =
lastTx->getSourceAccount().getBalance() - totFee;
if (newBalance < lastTx->getSourceAccount().getMinimumBalance(
app.getLedgerManager()))
{
for (auto& tx : item.second)
{
trimmed.push_back(tx);
removeTx(tx);
}
}
}
}
}
示例2: CLOG
bool
TxSetFrame::checkOrTrim(
Application& app,
std::function<bool(TransactionFramePtr, SequenceNumber)>
processInvalidTxLambda,
std::function<bool(std::vector<TransactionFramePtr> const&)>
processInsufficientBalance)
{
map<AccountID, vector<TransactionFramePtr>> accountTxMap;
Hash lastHash;
for (auto& tx : mTransactions)
{
if (tx->getFullHash() < lastHash)
{
CLOG(DEBUG, "Herder")
<< "bad txSet: " << hexAbbrev(mPreviousLedgerHash)
<< " not sorted correctly";
return false;
}
accountTxMap[tx->getSourceID()].push_back(tx);
lastHash = tx->getFullHash();
}
for (auto& item : accountTxMap)
{
// order by sequence number
std::sort(item.second.begin(), item.second.end(), SeqSorter);
TransactionFramePtr lastTx;
SequenceNumber lastSeq = 0;
int64_t totFee = 0;
for (auto& tx : item.second)
{
if (!tx->checkValid(app, lastSeq))
{
if (processInvalidTxLambda(tx, lastSeq))
continue;
return false;
}
totFee += tx->getFee();
lastTx = tx;
lastSeq = tx->getSeqNum();
}
if (lastTx)
{
// make sure account can pay the fee for all these tx
int64_t newBalance =
lastTx->getSourceAccount().getBalance() - totFee;
if (newBalance < lastTx->getSourceAccount().getMinimumBalance(
app.getLedgerManager()))
{
if (!processInsufficientBalance(item.second))
return false;
}
}
}
return true;
}