当前位置: 首页>>代码示例>>C++>>正文


C++ TransactionFramePtr::getSourceAccount方法代码示例

本文整理汇总了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);
                }
            }
        }
    }
}
开发者ID:nullstyle,项目名称:stellar-core,代码行数:55,代码来源:TxSetFrame.cpp

示例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;
}
开发者ID:hanxueming126,项目名称:stellar-core,代码行数:62,代码来源:TxSetFrame.cpp


注:本文中的TransactionFramePtr::getSourceAccount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。