Ejemplo n.º 1
0
Json::Value lookupLedger (
    std::shared_ptr<ReadView const>& ledger, Context& context)
{
    Json::Value result;
    if (auto status = lookupLedger (ledger, context, result))
        status.inject (result);

    return result;
}
Ejemplo n.º 2
0
Json::Value lookupLedger (
    Json::Value const& params,
    Ledger::pointer& ledger,
    NetworkOPs& netOps)
{
    Json::Value value (Json::objectValue);
    if (auto status = lookupLedger (params, ledger, netOps, value))
        status.inject (value);

    return value;
}
Ejemplo n.º 3
0
Status LedgerHandler::check()
{
    auto const& params = context_.params;
    bool needsLedger = params.isMember (jss::ledger) ||
            params.isMember (jss::ledger_hash) ||
            params.isMember (jss::ledger_index);
    if (!needsLedger)
        return Status::OK;

    if (auto s = lookupLedger (ledger_, context_, result_))
        return s;

    bool bFull = params[jss::full].asBool();
    bool bTransactions = params[jss::transactions].asBool();
    bool bAccounts = params[jss::accounts].asBool();
    bool bExpand = params[jss::expand].asBool();
    bool bBinary = params[jss::binary].asBool();
    bool const owner_funds = params[jss::owner_funds].asBool();

    options_ = (bFull ? LedgerFill::full : 0)
            | (bExpand ? LedgerFill::expand : 0)
            | (bTransactions ? LedgerFill::dumpTxrp : 0)
            | (bAccounts ? LedgerFill::dumpState : 0)
            | (bBinary ? LedgerFill::binary : 0)
            | (owner_funds ? LedgerFill::ownerFunds : 0);

    if (bFull || bAccounts)
    {
        // Until some sane way to get full ledgers has been implemented,
        // disallow retrieving all state nodes.
        if (! isUnlimited (context_.role))
            return rpcNO_PERMISSION;

        if (context_.app.getFeeTrack().isLoadedLocal() &&
            !isUnlimited (context_.role))
        {
            return rpcTOO_BUSY;
        }
        context_.loadType = bBinary ? Resource::feeMediumBurdenRPC :
            Resource::feeHighBurdenRPC;
    }

    return Status::OK;
}