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


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

本文整理汇总了C++中TransactionFramePtr::getFee方法的典型用法代码示例。如果您正苦于以下问题:C++ TransactionFramePtr::getFee方法的具体用法?C++ TransactionFramePtr::getFee怎么用?C++ TransactionFramePtr::getFee使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TransactionFramePtr的用法示例。


在下文中一共展示了TransactionFramePtr::getFee方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: delta

static void
doInflation(Application& app, int nbAccounts,
            std::function<int64(int)> getBalance,
            std::function<int(int)> getVote, int expectedWinnerCount)
{
    // simulate the expected inflation based off the current ledger state
    std::map<int, int64> balances;

    // load account balances
    for (int i = 0; i < nbAccounts; i++)
    {
        AccountFrame act;
        if (getBalance(i) < 0)
        {
            balances[i] = -1;
            REQUIRE(!AccountFrame::loadAccount(getTestAccount(i).getPublicKey(),
                                               act, app.getDatabase()));
        }
        else
        {
            REQUIRE(AccountFrame::loadAccount(getTestAccount(i).getPublicKey(),
                                              act, app.getDatabase()));
            balances[i] = act.getBalance();
            // double check that inflationDest is setup properly
            if (act.getAccount().inflationDest)
            {
                REQUIRE(getTestAccount(getVote(i)).getPublicKey() ==
                        *act.getAccount().inflationDest);
            }
            else
            {
                REQUIRE(getVote(i) < 0);
            }
        }
    }
    LedgerManager& lm = app.getLedgerManager();
    LedgerHeader& cur = lm.getCurrentLedgerHeader();
    cur.feePool = 10000;

    int64 expectedTotcoins = cur.totalCoins;
    int64 expectedFees = cur.feePool;

    std::vector<int64> expectedBalances;

    auto root = getRoot();
    TransactionFramePtr txFrame =
        createInflation(root, getAccountSeqNum(root, app) + 1);

    expectedFees += txFrame->getFee(app);

    expectedBalances =
        simulateInflation(nbAccounts, expectedTotcoins, expectedFees,
                          [&](int i)
                          {
                              return balances[i];
                          },
                          getVote);

    // perform actual inflation
    {
        LedgerDelta delta(lm.getCurrentLedgerHeader());
        REQUIRE(txFrame->apply(delta, app));
        delta.commit();
    }

    // verify ledger state
    LedgerHeader& cur2 = lm.getCurrentLedgerHeader();

    REQUIRE(cur2.totalCoins == expectedTotcoins);
    REQUIRE(cur2.feePool == expectedFees);

    // verify balances
    InflationResult const& infResult =
        getFirstResult(*txFrame).tr().inflationResult();
    auto const& payouts = infResult.payouts();
    int actualChanges = 0;

    for (int i = 0; i < nbAccounts; i++)
    {
        AccountFrame act;
        auto const& pk = getTestAccount(i).getPublicKey();
        if (expectedBalances[i] < 0)
        {
            REQUIRE(!AccountFrame::loadAccount(pk, act, app.getDatabase()));
            REQUIRE(balances[i] < 0); // account didn't get deleted
        }
        else
        {
            REQUIRE(AccountFrame::loadAccount(pk, act, app.getDatabase()));
            REQUIRE(expectedBalances[i] == act.getBalance());

            if (expectedBalances[i] != balances[i])
            {
                REQUIRE(balances[i] >= 0);
                actualChanges++;
                bool found = false;
                for (auto const& p : payouts)
                {
                    if (p.destination == pk)
                    {
//.........这里部分代码省略.........
开发者ID:gmarceau,项目名称:stellar-core,代码行数:101,代码来源:InflationTests.cpp


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