Beispiel #1
0
bool
RawStateTable::exists (ReadView const& base,
    Keylet const& k) const
{
    assert(k.key.isNonZero());
    auto const iter = items_.find(k.key);
    if (iter == items_.end())
        return base.exists(k);
    auto const& item = iter->second;
    if (item.first == Action::erase)
        return false;
    if (! k.check(*item.second))
        return false;
    return true;
}
Beispiel #2
0
void
fill_fee (Json::Value& jv,
    ReadView const& view)
{
    if (jv.isMember(jss::Fee))
        return;
    auto fee = view.fees().base;
    if (jv.isMember (jss::TransactionType) &&
        (jv[jss::TransactionType].asString () == "Payment" ||
         jv[jss::TransactionType].asString () == "ActiveAccount"))
    {
        if (jv.isMember (jss::Amount))
        {
            STAmount amount;
            amountFromJsonNoThrow (amount, jv[jss::Amount]);
            if (amount.native ())
                fee = std::max (multiply (amount, amountFromRate (Config ().FEE_DEFAULT_RATE_NATIVE),
                                          amount.issue ())
                                    .mantissa (),
                                Config ().FEE_DEFAULT_MIN_NATIVE);
        }
        if (jv.isMember (jv[jss::TransactionType].asString () == "ActiveAccount" ?
                             jss::Reference :
                             jss::Destination))
        {
            auto const account =
                parseBase58<AccountID> (
                    jv[jv[jss::TransactionType].asString () == "ActiveAccount" ?
                           jss::Reference :
                           jss::Destination]
                        .asString ());
            if (!account)
                throw parse_error (
                    "unexpected invalid Destination");
            if (!view.exists (keylet::account (*account)))
                fee += Config ().FEE_DEFAULT_CREATE;
        }
    }
    jv[jss::Fee] = std::to_string(
        fee);
}