• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ ledger::pointer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ledger::pointer的典型用法代码示例。如果您正苦于以下问题:C++ pointer类的具体用法?C++ pointer怎么用?C++ pointer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: getledgerhash

 ledgerhash getledgerhash(ledger::pointer ledger, ledgerindex index)
 {
     ledgerhash hash;
     try
     {
         hash = ledger->getledgerhash(index);
     }
     catch (shamapmissingnode &)
     {
         m_journal.warning <<
             "node missing from ledger " << ledger->getledgerseq();
         getapp().getinboundledgers().findcreate (
             ledger->gethash(), ledger->getledgerseq(), inboundledger::fcgeneric);
     }
     return hash;
 }
开发者ID:moorecoin,项目名称:MooreCoinService,代码行数:16,代码来源:LedgerCleaner.cpp


示例2: gethash

    /** returns the hash of the specified ledger.
        @param ledgerindex the index of the desired ledger.
        @param referenceledger [out] an optional known good subsequent ledger.
        @return the hash of the ledger. this will be all-bits-zero if not found.
    */
    ledgerhash gethash(
        ledgerindex const& ledgerindex,
        ledger::pointer& referenceledger)
    {
        ledgerhash ledgerhash;

        if (!referenceledger || (referenceledger->getledgerseq() < ledgerindex))
        {
            referenceledger = getapp().getledgermaster().getvalidatedledger();
            if (!referenceledger)
            {
                m_journal.warning << "no validated ledger";
                return ledgerhash; // nothing we can do. no validated ledger.
            }
        }

        if (referenceledger->getledgerseq() >= ledgerindex)
        {
            // see if the hash for the ledger we need is in the reference ledger
            ledgerhash = getledgerhash(referenceledger, ledgerindex);
            if (ledgerhash.iszero())
            {
                // no, try to get another ledger that might have the hash we need
                // compute the index and hash of a ledger that will have the hash we need
                ledgerindex refindex = (ledgerindex + 255) & (~255);
                ledgerhash refhash = getledgerhash (referenceledger, refindex);

                bool const nonzero (refhash.isnonzero ());
                assert (nonzero);
                if (nonzero)
                {
                    // we found the hash and sequence of a better reference ledger
                    referenceledger = getapp().getledgermaster().findacquireledger (refindex, refhash);
                    if (referenceledger)
                        ledgerhash = getledgerhash(referenceledger, ledgerindex);
                }
            }
        }
        else
            m_journal.warning << "validated ledger is prior to target ledger";

        return ledgerhash;
    }
开发者ID:moorecoin,项目名称:MooreCoinService,代码行数:48,代码来源:LedgerCleaner.cpp


示例3: asyncAccept

void LedgerMaster::asyncAccept(Ledger::pointer ledger)
{
	uint32 seq = ledger->getLedgerSeq();
	uint256 prevHash = ledger->getParentHash();

	while (seq > 0)
	{
		{
			boost::recursive_mutex::scoped_lock ml(mLock);
			mCompleteLedgers.setValue(seq);
			--seq;
			if (mCompleteLedgers.hasValue(seq))
				break;
		}

		uint256 tHash, pHash;
		if (!Ledger::getHashesByIndex(seq, tHash, pHash) || (tHash != prevHash))
			break;
		prevHash = pHash;
	}

	resumeAcquiring();
}
开发者ID:Criptomonedas,项目名称:rippled,代码行数:23,代码来源:LedgerMaster.cpp


示例4: runtime_error

SLE::pointer
getLedgerEntryRippleState(Ledger::pointer ledger,
    TestAccount const& account1, TestAccount const& account2,
    Currency currency)
{
    auto uNodeIndex = getRippleStateIndex(
        account1.pk.getAccountID(), account2.pk.getAccountID(),
        to_currency(currency.getCurrency()));

    if (!uNodeIndex.isNonZero())
        throw std::runtime_error(
        "!uNodeIndex.isNonZero()");

    return ledger->getSLEi(uNodeIndex);
}
开发者ID:Joke-Dk,项目名称:rippled,代码行数:15,代码来源:common_ledger.cpp


示例5: doLedger

    /** Process a single ledger
        @param ledgerIndex The index of the ledger to process.
        @param ledgerHash  The known correct hash of the ledger.
        @param doNodes Ensure all ledger nodes are in the node db.
        @param doTxns Reprocess (account) transactions to SQL databases.
        @return `true` if the ledger was cleaned.
    */
    bool doLedger(
        LedgerIndex const& ledgerIndex,
        LedgerHash const& ledgerHash,
        bool doNodes,
        bool doTxns)
    {
        Ledger::pointer nodeLedger =
            getApp().getInboundLedgers().acquire (
                ledgerHash, ledgerIndex, InboundLedger::fcGENERIC);
        if (!nodeLedger)
        {
            m_journal.debug << "Ledger " << ledgerIndex << " not available";
            return false;
        }

        Ledger::pointer dbLedger = Ledger::loadByIndex(ledgerIndex);
        if (! dbLedger ||
            (dbLedger->getHash() != ledgerHash) ||
            (dbLedger->getParentHash() != nodeLedger->getParentHash()))
        {
            // Ideally we'd also check for more than one ledger with that index
            m_journal.debug <<
                "Ledger " << ledgerIndex << " mismatches SQL DB";
            doTxns = true;
        }

        if(! getApp().getLedgerMaster().fixIndex(ledgerIndex, ledgerHash))
        {
            m_journal.debug << "ledger " << ledgerIndex << " had wrong entry in history";
            doTxns = true;
        }

        if (doNodes && !nodeLedger->walkLedger())
        {
            m_journal.debug << "Ledger " << ledgerIndex << " is missing nodes";
            getApp().getInboundLedgers().acquire(
                ledgerHash, ledgerIndex, InboundLedger::fcGENERIC);
            return false;
        }

        if (doTxns && !nodeLedger->pendSaveValidated(true, false))
        {
            m_journal.debug << "Failed to save ledger " << ledgerIndex;
            return false;
        }

        return true;
    }
开发者ID:reecer,项目名称:rippled,代码行数:55,代码来源:LedgerCleaner.cpp


示例6: lookupLedgerDeprecated

// The previous version of the lookupLedger command would accept the
// "ledger_index" argument as a string and silently treat it as a request to
// return the current ledger which, while not strictly wrong, could cause a lot
// of confusion.
//
// The code now robustly validates the input and ensures that the only possible
// values for the "ledger_index" parameter are the index of a ledger passed as
// an integer or one of the strings "current", "closed" or "validated".
// Additionally, the code ensures that the value passed in "ledger_hash" is a
// string and a valid hash. Invalid values will return an appropriate error
// code.
//
// In the absence of the "ledger_hash" or "ledger_index" parameters, the code
// assumes that "ledger_index" has the value "current".
//
// Returns a Json::objectValue.  If there was an error, it will be in that
// return value.  Otherwise, the object contains the field "validated" and
// optionally the fields "ledger_hash", "ledger_index" and
// "ledger_current_index", if they are defined.
Status lookupLedgerDeprecated (
    Ledger::pointer& ledger, Context& context, Json::Value& result)
{
    if (auto status = ledgerFromRequest (ledger, context))
        return status;

    auto& info = ledger->info();

    if (!info.open)
    {
        result[jss::ledger_hash] = to_string (info.hash);
        result[jss::ledger_index] = info.seq;
    }
    else
    {
        result[jss::ledger_current_index] = info.seq;
    }

    result[jss::validated] = getApp().getLedgerMaster().isValidLedger(info);
    return Status::OK;
}
开发者ID:referjs,项目名称:rippled,代码行数:40,代码来源:LookupLedger.cpp


示例7: getLineCache

/** Get the current RippleLineCache, updating it if necessary.
    Get the correct ledger to use.
*/
RippleLineCache::pointer PathRequests::getLineCache (Ledger::pointer& ledger, bool authoritative)
{
    ScopedLockType sl (mLock, __FILE__, __LINE__);

    uint32 lineSeq = mLineCache ? mLineCache->getLedger()->getLedgerSeq() : 0;
    uint32 lgrSeq = ledger->getLedgerSeq();

    if ( (lineSeq == 0) ||                                 // no ledger
         (authoritative && (lgrSeq > lineSeq)) ||          // newer authoritative ledger
         (authoritative && ((lgrSeq + 8)  < lineSeq)) ||   // we jumped way back for some reason
         (lgrSeq > (lineSeq + 8)))                         // we jumped way forward for some reason
    {
        ledger = boost::make_shared<Ledger>(*ledger, false); // Take a snapshot of the ledger
        mLineCache = boost::make_shared<RippleLineCache> (ledger);
    }
    else
    {
        ledger = mLineCache->getLedger();
    }
    return mLineCache;
}
开发者ID:12w21,项目名称:rippled,代码行数:24,代码来源:PathRequests.cpp


示例8: autofill_fee

/** Fill in the fee on behalf of the client.
    This is called when the client does not explicitly specify the fee.
    The client may also put a ceiling on the amount of the fee. This ceiling
    is expressed as a multiplier based on the current ledger's fee schedule.

    JSON fields

    "Fee"   The fee paid by the transaction. Omitted when the client
            wants the fee filled in.

    "fee_mult_max"  A multiplier applied to the current ledger's transaction
                    fee that caps the maximum the fee server should auto fill.
                    If this optional field is not specified, then a default
                    multiplier is used.

    @param tx       The JSON corresponding to the transaction to fill in
    @param ledger   A ledger for retrieving the current fee schedule
    @param result   A JSON object for injecting error results, if any
    @param admin    `true` if this is called by an administrative endpoint.
*/
static void autofill_fee (Json::Value& request,
    Ledger::pointer ledger, Json::Value& result, bool admin)
{
    Json::Value& tx (request["tx_json"]);
    if (tx.isMember ("Fee"))
        return;

    int mult = DEFAULT_AUTO_FILL_FEE_MULTIPLIER;
    if (request.isMember ("fee_mult_max"))
    {
        if (request["fee_mult_max"].isNumeric ())
        {
            mult = request["fee_mult_max"].asInt();
        }
        else
        {
            RPC::inject_error (rpcHIGH_FEE, RPC::expected_field_message (
                "fee_mult_max", "a number"), result);
            return;
        }
    }

    std::uint64_t const feeDefault = getConfig().FEE_DEFAULT;

    // Administrative endpoints are exempt from local fees
    std::uint64_t const fee = ledger->scaleFeeLoad (feeDefault, admin);
    std::uint64_t const limit = mult * feeDefault;

    if (fee > limit)
    {
        std::stringstream ss;
        ss <<
            "Fee of " << fee <<
            " exceeds the requested tx limit of " << limit;
        RPC::inject_error (rpcHIGH_FEE, ss.str(), result);
        return;
    }

    tx ["Fee"] = static_cast<int>(fee);
}
开发者ID:naumenkogs,项目名称:blockverify-core,代码行数:60,代码来源:TransactionSign.cpp


示例9: update

void OrderBookDB::update (Ledger::pointer ledger)
{
    hash_set< uint256 > seen;
    OrderBookDB::IssueToOrderBook destMap;
    OrderBookDB::IssueToOrderBook sourceMap;
    hash_set< Issue > XDVBooks;

    WriteLog (lsDEBUG, OrderBookDB) << "OrderBookDB::update>";

    // walk through the entire ledger looking for orderbook entries
    int books = 0;

    try
    {
        ledger->visitStateItems(std::bind(&updateHelper, std::placeholders::_1,
                                          std::ref(seen), std::ref(destMap),
            std::ref(sourceMap), std::ref(XDVBooks), std::ref(books)));
    }
    catch (const SHAMapMissingNode&)
    {
        WriteLog (lsINFO, OrderBookDB)
            << "OrderBookDB::update encountered a missing node";
        ScopedLockType sl (mLock);
        mSeq = 0;
        return;
    }

    WriteLog (lsDEBUG, OrderBookDB)
        << "OrderBookDB::update< " << books << " books found";
    {
        ScopedLockType sl (mLock);

        mXDVBooks.swap(XDVBooks);
        mSourceMap.swap(sourceMap);
        mDestMap.swap(destMap);
    }
    getApp().getLedgerMaster().newOrderBookDB();
}
开发者ID:xdv,项目名称:divvyd,代码行数:38,代码来源:OrderBookDB.cpp


示例10: getLedgerByHash

Ledger::pointer LedgerHistory::getLedgerByHash (uint256 const& hash)
{
    Ledger::pointer ret = m_ledgers_by_hash.fetch (hash);

    if (ret)
    {
        assert (ret->isImmutable ());
        assert (ret->getHash () == hash);
        return ret;
    }

    ret = Ledger::loadByHash (hash);

    if (!ret)
        return ret;

    assert (ret->isImmutable ());
    assert (ret->getHash () == hash);
    m_ledgers_by_hash.canonicalize (ret->getHash (), ret);
    assert (ret->getHash () == hash);

    return ret;
}
开发者ID:BattleProgrammer,项目名称:stellard,代码行数:23,代码来源:LedgerHistory.cpp


示例11: in

/**
 * Instantiate an application and replay a ledger history out
 * of the dump file `filename`.
 */
void
LedgerDump::loadTransactions (std::string const& filename)
{
    std::ifstream in (filename);
    require ((bool)in, "opening file");

    std::unique_ptr <Application> app (make_Application ());
    app->setup ();
    auto &lm = app->getLedgerMaster ();
    WriteLog (lsINFO, LedgerDump) << "Loading ledgers from " << filename;

    auto nTxs = 0;

    // app->setup() when called with START_UP == Config::FRESH calls
    // ApplicationImp::startNewLedger(). Unfortunately it starts the new
    // ledger at the wrong timestamp, so we call it again once we've read
    // the first ledger we're going to apply. However, it's worth
    // understanding that startNewLedger() establishes 3 ledgers:
    //
    // Ledger 0 is the genesis ledger, it's not a real ledger, just a
    //          number.
    //
    // Ledger 1 is the root-account deposit ledger, with a single pile of
    //          currency owned by a single account generated by the seed
    //          "masterpassword".
    //
    // Ledger 2 is created and closed immediately on start, not sure why.
    //
    // Ledger 3 is a new ledger chained to #2 and left open in
    //          ledgermaster.
    //
    // Ledger 3 is where replay should be starting, so (once we call
    // startNewLedger() again) we pull out ledger #2 and use it as the
    // parent of the new ledger 3 we're replaying, and throw away the #3
    // that was made by startNewLedger().

    Ledger::pointer parentLedger;

    while (in)
    {
        if ((gLedgerSeq & 0xfff) == 0) {
            Job j;
            app->doSweep (j);
        }

        Json::Value j = loadJsonRecord (in);

        Ledger::pointer deserializedLedger;
        SHAMap::pointer txSet;
        std::vector<uint256> txOrder;
        std::tie (deserializedLedger, txSet, txOrder) =
            loadLedgerAndTransactionsFromJSON (*app, j);

        if (!parentLedger)
        {
            if (getConfig ().START_LEDGER.empty ())
            {
                require (deserializedLedger->getLedgerSeq () == 3,
                         "Initial ledger isn't seq #3");

                // On first iteration, restart the app's view of the ledger
                // history at the same instant as the parent close time of the
                // first ledger (ledger #3).
                app->startNewLedger (deserializedLedger->getParentCloseTimeNC ());
                parentLedger = lm.getClosedLedger ();
                require (parentLedger->getLedgerSeq () == 2,
                         "Initial ledger parent isn't seq #2");
            }
            else
            {
                // We're being invoked with --ledger, which is where we
                // will start replay from.
                require (app->loadOldLedger (getConfig ().START_LEDGER, false),
                         "Reloading old ledger failed.");
                parentLedger = lm.getClosedLedger ();
            }

            auto const parentSeq = parentLedger->getLedgerSeq ();
            auto seq = j["seq"].asUInt ();
            while (parentSeq + 1 > seq)
            {
                // Fast-scan JSON records until we hit the right one.
                WriteLog (lsINFO, LedgerDump) << "scanning past ledger: "
                                              << seq;
                j = loadJsonRecord (in);
                seq = j["seq"].asUInt ();
                if (parentSeq + 1 <= seq)
                {
                    require (parentSeq + 1 == seq,
                             "Missing ledgers between loaded and replay-start");
                    std::tie (deserializedLedger, txSet, txOrder) =
                        loadLedgerAndTransactionsFromJSON (*app, j);
                }
            }
            gLedgerSeq = parentSeq;
            require(parentLedger->getLedgerSeq () + 1 ==
//.........这里部分代码省略.........
开发者ID:naumenkogs,项目名称:blockverify-core,代码行数:101,代码来源:LedgerDump.cpp


示例12: main

int main (){
	std::string db_name = "/home/ivanzjj/radix_tree";
	RocksdbInstance::set_db_name (db_name);
	Ledger::pointer ledger = std::make_shared <Ledger> ();
	
	std::string db_name2 = "/home/ivanzjj/ledger.db";
	SqliteInstance::set_db_name (db_name2);

	uint256 hash;
	char hash_ch[32];
	for (int i=0;i<32;i++)
		hash_ch[i] = i;
	hash.init (hash_ch);
	hash.to_string ();

	Serializer ss;
	char ch[100];
	for (int i=0;i<100;i++)	ch[i] = i;
	ss.add_raw (ch, 100);

	if (!ledger->add_account_tree_entry (hash, ss)){
		printf ("add_account_tree_entry error!\n");
		return 1;
	}
//	dfs (ledger->get_account_tree ()->get_root (), 0);

	for (int i = 0; i < 32; i++){
		hash_ch[i] = i;
	}
	hash_ch[0] = 1;
	hash.init (hash_ch);
	hash.to_string ();
	if (!ledger->add_account_tree_entry (hash, ss)){
		printf ("add_account_tree_entry error2\n");
		return 1;
	}
//	dfs (ledger->get_account_tree ()->get_root (), 0);

	
	for (int i = 0; i < 32; i++)	hash_ch[i] = i;
	hash_ch[0] = 1;
	hash_ch[1] = 2;

	hash.init (hash_ch);
	hash.to_string ();
	if (!ledger->add_account_tree_entry (hash, ss)){
		printf ("add_account_tree_entry error2\n");
		return 1;
	}
//	dfs (ledger->get_account_tree ()->get_root (), 0);
	
	for (int i = 0; i < 32; i++){
		hash_ch[i] = i;
	}
	hash.init (hash_ch);
	if (ledger->has_account (hash)){
		hash.to_string ();
		printf ("YES\n");
	
		ch[0] = 10;
		ss.peek_data ().clear();
		ss.add_raw (ch, 100);
		RadixMerkleTreeLeaf::pointer new_item = std::make_shared<RadixMerkleTreeLeaf> (hash, ss);
		if (!ledger->update_account_tree_entry (new_item)){
			printf ("update_account_tree_entry error!\n");
			return 1;
		}
	}
	else {
		printf ("NO\n");
	}	
//	dfs (ledger->get_account_tree ()->get_root (), 0);
	return 0;
}
开发者ID:ivanzjj,项目名称:digital,代码行数:74,代码来源:main.cpp


示例13: doAccountOffers

// {
//   account: <account>|<account_public_key>
//   account_index: <number>        // optional, defaults to 0.
//   ledger_hash : <ledger>
//   ledger_index : <ledger_index>
//   limit: integer                 // optional
//   marker: opaque                 // optional, resume previous query
// }
Json::Value doAccountOffers (RPC::Context& context)
{
    auto const& params (context.params);
    if (! params.isMember (jss::account))
        return RPC::missing_field_error (jss::account);

    Ledger::pointer ledger;
    Json::Value result (RPC::lookupLedger (params, ledger, context.netOps));
    if (! ledger)
        return result;

    std::string strIdent (params[jss::account].asString ());
    bool bIndex (params.isMember (jss::account_index));
    int const iIndex (bIndex ? params[jss::account_index].asUInt () : 0);
    DivvyAddress divvyAddress;

    Json::Value const jv = RPC::accountFromString (
        divvyAddress, bIndex, strIdent, iIndex, false);
    if (! jv.empty ())
    {
        for (Json::Value::const_iterator it (jv.begin ()); it != jv.end (); ++it)
            result[it.memberName ()] = it.key ();

        return result;
    }

    // Get info on account.
    result[jss::account] = divvyAddress.humanAccountID ();

    if (bIndex)
        result[jss::account_index] = iIndex;

    if (! ledger->exists(getAccountRootIndex(
            divvyAddress.getAccountID())))
        return rpcError (rpcACT_NOT_FOUND);

    unsigned int limit;
    if (params.isMember (jss::limit))
    {
        auto const& jvLimit (params[jss::limit]);
        if (! jvLimit.isIntegral ())
            return RPC::expected_field_error (jss::limit, "unsigned integer");

        limit = jvLimit.isUInt () ? jvLimit.asUInt () :
            std::max (0, jvLimit.asInt ());

        if (context.role != Role::ADMIN)
        {
            limit = std::max (RPC::Tuning::minOffersPerRequest,
                std::min (limit, RPC::Tuning::maxOffersPerRequest));
        }
    }
    else
    {
        limit = RPC::Tuning::defaultOffersPerRequest;
    }

    AccountID const& raAccount (divvyAddress.getAccountID ());
    Json::Value& jsonOffers (result[jss::offers] = Json::arrayValue);
    std::vector <std::shared_ptr<SLE const>> offers;
    unsigned int reserve (limit);
    uint256 startAfter;
    std::uint64_t startHint;

    if (params.isMember(jss::marker))
    {
        // We have a start point. Use limit - 1 from the result and use the
        // very last one for the resume.
        Json::Value const& marker (params[jss::marker]);

        if (! marker.isString ())
            return RPC::expected_field_error (jss::marker, "string");

        startAfter.SetHex (marker.asString ());
        auto const sleOffer = fetch (*ledger, startAfter,
            getApp().getSLECache());

        if (sleOffer == nullptr ||
            sleOffer->getType () != ltOFFER ||
            raAccount != sleOffer->getFieldAccount160 (sfAccount))
        {
            return rpcError (rpcINVALID_PARAMS);
        }

        startHint = sleOffer->getFieldU64(sfOwnerNode);

        // Caller provided the first offer (startAfter), add it as first result
        Json::Value& obj (jsonOffers.append (Json::objectValue));
        sleOffer->getFieldAmount (sfTakerPays).setJson (obj[jss::taker_pays]);
        sleOffer->getFieldAmount (sfTakerGets).setJson (obj[jss::taker_gets]);
        obj[jss::seq] = sleOffer->getFieldU32 (sfSequence);
        obj[jss::flags] = sleOffer->getFieldU32 (sfFlags);
//.........这里部分代码省略.........
开发者ID:xdv,项目名称:divvyd,代码行数:101,代码来源:AccountOffers.cpp


示例14: handleMismatch

void LedgerHistory::handleMismatch (LedgerHash const& built, LedgerHash  const& valid)
{
    assert (built != valid);
    ++mismatch_counter_;

    Ledger::pointer builtLedger = getLedgerByHash (built);
    Ledger::pointer validLedger = getLedgerByHash (valid);

    if (builtLedger && validLedger)
    {
        assert (builtLedger->getLedgerSeq() == validLedger->getLedgerSeq());

        // Determine the mismatch reason
        // Distinguish Byzantine failure from transaction processing difference

        if (builtLedger->getParentHash() != validLedger->getParentHash())
        {
            // Disagreement over prior ledger indicates sync issue
            WriteLog (lsERROR, LedgerMaster) << "MISMATCH on prior ledger";
        }
        else if (builtLedger->getCloseTimeNC() != validLedger->getCloseTimeNC())
        {
            // Disagreement over close time indicates Byzantine failure
            WriteLog (lsERROR, LedgerMaster) << "MISMATCH on close time";
        }
        else
        {
            std::vector <uint256> builtTx, validTx;
            builtLedger->peekTransactionMap()->visitLeaves(
                std::bind (&addLeaf, std::ref (builtTx), std::placeholders::_1));
            validLedger->peekTransactionMap()->visitLeaves(
                std::bind (&addLeaf, std::ref (validTx), std::placeholders::_1));
            std::sort (builtTx.begin(), builtTx.end());
            std::sort (validTx.begin(), validTx.end());

            if (builtTx == validTx)
            {
                // Disagreement with same prior ledger, close time, and transactions
                // indicates a transaction processing difference
                WriteLog (lsERROR, LedgerMaster) <<
                    "MISMATCH with same " << builtTx.size() << " tx";
            }
            else
            {
                std::vector <uint256> notBuilt, notValid;
                std::set_difference (
                    validTx.begin(), validTx.end(),
                    builtTx.begin(), builtTx.end(),
                    std::inserter (notBuilt, notBuilt.begin()));
                std::set_difference (
                    builtTx.begin(), builtTx.end(),
                    validTx.begin(), validTx.end(),
                    std::inserter (notValid, notValid.begin()));

                // This can be either a disagreement over the consensus
                // set or difference in which transactions were rejected
                // as invalid

                WriteLog (lsERROR, LedgerMaster) << "MISMATCH tx differ "
                    << builtTx.size() << " built, " << validTx.size() << " valid";
                for (auto const& t : notBuilt)
                {
                    WriteLog (lsERROR, LedgerMaster) << "MISMATCH built without " << t;
                }
                for (auto const& t : notValid)
                {
                    WriteLog (lsERROR, LedgerMaster) << "MISMATCH valid without " << t;
                }
            }
        }
    }
    else
        WriteLog (lsERROR, LedgerMaster) << "MISMATCH cannot be analyzed";
}
开发者ID:619213152,项目名称:vpal20,代码行数:74,代码来源:LedgerHistory.cpp


示例15: doAccountTxOld

// {
//   account: account,
//   ledger_index_min: ledger_index,
//   ledger_index_max: ledger_index,
//   binary: boolean,              // optional, defaults to false
//   count: boolean,               // optional, defaults to false
//   descending: boolean,          // optional, defaults to false
//   offset: integer,              // optional, defaults to 0
//   limit: integer                // optional
// }
Json::Value doAccountTxOld (RPC::Context& context)
{
    RippleAddress   raAccount;
    std::uint32_t offset
            = context.params_.isMember ("offset")
            ? context.params_["offset"].asUInt () : 0;
    int limit = context.params_.isMember ("limit")
            ? context.params_["limit"].asUInt () : -1;
    bool bBinary = context.params_.isMember ("binary")
            && context.params_["binary"].asBool ();
    bool bDescending = context.params_.isMember ("descending")
            && context.params_["descending"].asBool ();
    bool bCount = context.params_.isMember ("count")
            && context.params_["count"].asBool ();
    std::uint32_t   uLedgerMin;
    std::uint32_t   uLedgerMax;
    std::uint32_t   uValidatedMin;
    std::uint32_t   uValidatedMax;
    bool bValidated  = context.netOps_.getValidatedRange (
        uValidatedMin, uValidatedMax);

    if (!context.params_.isMember ("account"))
        return rpcError (rpcINVALID_PARAMS);

    if (!raAccount.setAccountID (context.params_["account"].asString ()))
        return rpcError (rpcACT_MALFORMED);

    if (offset > 3000)
        return rpcError (rpcATX_DEPRECATED);

    context.loadType_ = Resource::feeHighBurdenRPC;

    // DEPRECATED
    if (context.params_.isMember ("ledger_min"))
    {
        context.params_["ledger_index_min"]   = context.params_["ledger_min"];
        bDescending = true;
    }

    // DEPRECATED
    if (context.params_.isMember ("ledger_max"))
    {
        context.params_["ledger_index_max"]   = context.params_["ledger_max"];
        bDescending = true;
    }

    if (context.params_.isMember ("ledger_index_min")
        || context.params_.isMember ("ledger_index_max"))
    {
        std::int64_t iLedgerMin  = context.params_.isMember ("ledger_index_min")
                ? context.params_["ledger_index_min"].asInt () : -1;
        std::int64_t iLedgerMax  = context.params_.isMember ("ledger_index_max")
                ? context.params_["ledger_index_max"].asInt () : -1;

        if (!bValidated && (iLedgerMin == -1 || iLedgerMax == -1))
        {
            // Don't have a validated ledger range.
            return rpcError (rpcLGR_IDXS_INVALID);
        }

        uLedgerMin  = iLedgerMin == -1 ? uValidatedMin : iLedgerMin;
        uLedgerMax  = iLedgerMax == -1 ? uValidatedMax : iLedgerMax;

        if (uLedgerMax < uLedgerMin)
        {
            return rpcError (rpcLGR_IDXS_INVALID);
        }
    }
    else
    {
        Ledger::pointer l;
        Json::Value ret = RPC::lookupLedger (context.params_, l, context.netOps_);

        if (!l)
            return ret;

        uLedgerMin = uLedgerMax = l->getLedgerSeq ();
    }

    int count = 0;

#ifndef BEAST_DEBUG

    try
    {
#endif

        Json::Value ret (Json::objectValue);

        ret["account"] = raAccount.humanAccountID ();
//.........这里部分代码省略.........
开发者ID:619213152,项目名称:vpal20,代码行数:101,代码来源:AccountTxOld.cpp


示例16: doTx

// {
//   transaction: <hex>
// }
Json::Value doTx (RPC::Context& context)
{
    context.lock_.unlock ();

    if (!context.params_.isMember (jss::transaction))
        return rpcError (rpcINVALID_PARAMS);

    bool binary = context.params_.isMember (jss::binary) && context.params_[jss::binary].asBool ();

    std::string strTransaction  = context.params_[jss::transaction].asString ();

    if (Transaction::isHexTxID (strTransaction))
    {
        // transaction by ID
        uint256 txid (strTransaction);

        Transaction::pointer txn = getApp().getMasterTransaction ().fetch (txid, true);

        if (!txn)
            return rpcError (rpcTXN_NOT_FOUND);

#ifdef READY_FOR_NEW_TX_FORMAT
        Json::Value ret;
        ret[jss::transaction] = txn->getJson (0, binary);
#else
        Json::Value ret = txn->getJson (0, binary);
#endif

        if (txn->getLedger () != 0)
        {
            Ledger::pointer lgr = context.netOps_.getLedgerBySeq (txn->getLedger ());

            if (lgr)
            {
                bool okay = false;

                if (binary)
                {
                    std::string meta;

                    if (lgr->getMetaHex (txid, meta))
                    {
                        ret[jss::meta] = meta;
                        okay = true;
                    }
                }
                else
                {
                    TransactionMetaSet::pointer set;

                    if (lgr->getTransactionMeta (txid, set))
                    {
                        okay = true;
                        ret[jss::meta] = set->getJson (0);
                    }
                }

                if (okay)
                    ret[jss::validated] = context.netOps_.isValidated (lgr);
            }
        }

        return ret;
    }

    return rpcError (rpcNOT_IMPL);
}
开发者ID:RagnarDanneskjold,项目名称:rippled,代码行数:70,代码来源:Tx.cpp


示例17: doLedgerData

// Get state nodes from a ledger
//   Inputs:
//     limit:        integer, maximum number of entries
//     marker:       opaque, resume point
//     binary:       boolean, format
//   Outputs:
//     ledger_hash:  chosen ledger's hash
//     ledger_index: chosen ledger's index
//     state:        array of state nodes
//     marker:       resume point, if any
Json::Value doLedgerData (RPC::Context& context)
{
    context.lock_.unlock ();

    int const BINARY_PAGE_LENGTH = 256;
    int const JSON_PAGE_LENGTH = 2048;

    Ledger::pointer lpLedger;

    Json::Value jvResult = RPC::lookupLedger (context.params_, lpLedger, context.netOps_);
    if (!lpLedger)
        return jvResult;

    uint256 resumePoint;
    if (context.params_.isMember ("marker"))
    {
        Json::Value const& jMarker = context.params_["marker"];
        if (!jMarker.isString ())
            return RPC::expected_field_error ("marker", "valid");
        if (!resumePoint.SetHex (jMarker.asString ()))
            return RPC::expected_field_error ("marker", "valid");
    }

    bool isBinary = false;
    if (context.params_.isMember ("binary"))
    {
        Json::Value const& jBinary = context.params_["binary"];
        if (!jBinary.isBool ())
            return RPC::expected_field_error ("binary", "bool");
        isBinary = jBinary.asBool ();
    }

    int limit = -1;
    int maxLimit = isBinary ? BINARY_PAGE_LENGTH : JSON_PAGE_LENGTH;

    if (context.params_.isMember ("limit"))
    {
        Json::Value const& jLimit = context.params_["limit"];
        if (!jLimit.isIntegral ())
            return RPC::expected_field_error ("limit", "integer");

        limit = jLimit.asInt ();
    }

    if ((limit < 0) || ((limit > maxLimit) && (context.role_ != Config::ADMIN)))
        limit = maxLimit;

    Json::Value jvReply = Json::objectValue;

    jvReply["ledger_hash"] = to_string (lpLedger->getHash());
    jvReply["ledger_index"] = beast::lexicalCastThrow <std::string> (lpLedger->getLedgerSeq ());

    Json::Value& nodes = (jvReply["state"] = Json::arrayValue);
    SHAMap& map = *(lpLedger->peekAccountStateMap ());

    for (;;)
    {
       SHAMapItem::pointer item = map.peekNextItem (resumePoint);
       if (!item)
           break;
       resumePoint = item->getTag();

       if (limit-- <= 0)
       {
           --resumePoint;
           jvReply["marker"] = to_string (resumePoint);
           break;
       }

       if (isBinary)
       {
           Json::Value& entry = nodes.append (Json::objectValue);
           entry["data"] = strHex (item->peekData().begin(), item->peekData().size());
           entry["index"] = to_string (item->getTag ());
       }
       else
       {
           SLE sle (item->peekSerializer(), item->getTag ());
           Json::Value& entry = nodes.append (sle.getJson (0));
           entry["index"] = to_string (item->getTag ());
       }
    }

    return jvReply;
}
开发者ID:RagnarDanneskjold,项目名称:rippled,代码行数:95,代码来源:LedgerData.cpp


示例18: doAccountLines

// {
//   account: <account>|<account_public_key>
//   account_index: <number>        // optional, defaults to 0.
//   ledger_hash : <ledger>
//   ledger_index : <ledger_index>
//   limit: integer                 // optional
//   marker: opaque                 // optional, resume previous query
// }
Json::Value doAccountLines (RPC::Context& context)
{
    auto const& params (context.params);
    if (! params.isMember (jss::account))
        return RPC::missing_field_error (jss::account);

    Ledger::pointer ledger;
    Json::Value result (RPC::lookupLedger (params, ledger, context.netOps));
    if (! ledger)
        return result;

    std::string strIdent (params[jss::account].asString ());
    bool bIndex (params.isMember (jss::account_index));
    int iIndex (bIndex ? params[jss::account_index].asUInt () : 0);
    DivvyAddress divvyAddress;

    auto jv = RPC::accountFromString (
        divvyAddress, bIndex, strIdent, iIndex, false);
    if (! jv.empty ())
    {
        for (auto it = jv.begin (); it != jv.end (); ++it)
            result[it.memberName ()] = it.key ();

        return result;
    }

    if (! ledger->exists(getAccountRootIndex(
            divvyAddress.getAccountID())))
        return rpcError (rpcACT_NOT_FOUND);

    std::string strPeer (params.isMember (jss::peer)
        ? params[jss::peer].asString () : "");
    bool bPeerIndex (params.isMember (jss::peer_index));
    int iPeerIndex (bIndex ? params[jss::peer_index].asUInt () : 0);

    DivvyAddress divvyAddressPeer;

    if (! strPeer.empty ())
    {
        result[jss::peer] = divvyAddress.humanAccountID ();

        if (bPeerIndex)
            result[jss::peer_index] = iPeerIndex;

        result = RPC::accountFromString (
            divvyAddressPeer, bPeerIndex, strPeer, iPeerIndex, false);

        if (! result.empty ())
            return result;
    }

    AccountID raPeerAccount;
    if (divvyAddressPeer.isValid ())
        raPeerAccount = divvyAddressPeer.getAccountID ();

    unsigned int limit;
    if (params.isMember (jss::limit))
    {
        auto const& jvLimit (params[jss::limit]);
        if (! jvLimit.isIntegral ())
            return RPC::expected_field_error (jss::limit, "unsigned integer");

        limit = jvLimit.isUInt () ? jvLimit.asUInt () :
            std::max (0, jvLimit.asInt ());

        if (context.role != Role::ADMIN)
        {
            limit = std::max (RPC::Tuning::minLinesPerRequest,
                std::min (limit, RPC::Tuning::maxLinesPerRequest));
        }
    }
    else
    {
        limit = RPC::Tuning::defaultLinesPerRequest;
    }

    Json::Value& jsonLines (result[jss::lines] = Json::arrayValue);
    AccountID const& raAccount(divvyAddress.getAccountID ());
    VisitData visitData = { {}, raAccount, divvyAddressPeer, raPeerAccount };
    unsigned int reserve (limit);
    uint256 startAfter;
    std::uint64_t startHint;

    if (params.isMember (jss::marker))
    {
        // We have a start point. Use limit - 1 from the result and use the
        // very last one for the resume.
        Json::Value const& marker (params[jss::marker]);

        if (! marker.isString ())
            return RPC::expected_field_error (jss::marker, "string");

//.........这里部分代码省略.........
开发者ID:xdv,项目名称:divvyd,代码行数:101,代码来源:AccountLines.cpp


示例19: doLedger

// ledger [id|index|current|closed] [full]
// {
//    ledger: 'current' | 'closed' | <uint256> | <number>,  // optional
//    full: true | false    // optional, defaults to false.
// }
Json::Value doLedger (RPC::Context& context)
{
    if (!context.params_.isMember ("ledger")
        && !context.params_.isMember ("ledger_hash")
        && !context.params_.isMember ("ledger_index"))
    {
        Json::Value ret (Json::objectValue), current (Json::objectValue),
                closed (Json::objectValue);

        getApp().getLedgerMaster ().getCurrentL 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ledger::ref类代码示例发布时间:2022-05-31
下一篇:
C++ leapsdk::DeviceRef类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap