예제 #1
0
SequenceNumber
getAccountSeqNum(SecretKey const& k, Application& app)
{
    AccountFrame account;
    REQUIRE(AccountFrame::loadAccount(k.getPublicKey(), account,
                                      app.getDatabase()));
    return account.getSeqNum();
}
예제 #2
0
bool
Simulation::loadAccount(AccountInfo& account)
{
    // assumes all nodes are in sync
    auto app = mNodes.begin()->second;

    AccountFrame ret;
    if (!AccountFrame::loadAccount(account.mKey.getPublicKey(), ret,
                                   app->getDatabase()))
    {
        return false;
    }

    account.mBalance = ret.getBalance();
    account.mSeq = ret.getSeqNum();
    return true;
}
예제 #3
0
vector<Simulation::AccountInfoPtr>
Simulation::accountsOutOfSyncWithDb()
{
    vector<AccountInfoPtr> result;
    int iApp = 0;
    int64_t totalOffsets = 0;
    for (auto pair : mNodes)
    {
        iApp++;
        auto app = pair.second;
        for (auto accountIt = mAccounts.begin() + 1;
             accountIt != mAccounts.end(); accountIt++)
        {
            auto account = *accountIt;
            AccountFrame accountFrame;
            bool res = AccountFrame::loadAccount(
                account->mKey.getPublicKey(), accountFrame, app->getDatabase());
            int64_t offset;
            if (res)
            {
                offset = accountFrame.getBalance() -
                         static_cast<int64_t>(account->mBalance);
                account->mSeq = accountFrame.getSeqNum();
            }
            else
            {
                offset = -1;
            }
            if (offset != 0)
            {
                LOG(DEBUG) << "On node " << iApp << ", account " << account->mId
                           << " is off by " << (offset) << "\t(has "
                           << accountFrame.getBalance() << " should have "
                           << account->mBalance << ")";
                totalOffsets += abs(offset);
                result.push_back(account);
            }
        }
    }
    LOG(INFO)
        << "Ledger has not yet caught up to the simulation. totalOffsets: "
        << totalOffsets;
    return result;
}