mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
The OpenLedger class encapsulates the functionality of maintaining the open ledger. It uses an OpenView with the last closed ledger as its base. Routines are provided to modify the open ledger to add new transactions, and to accept a new last closed ledger. Business logic for performing transaction retries is rewritten to fit this framework and used in the implementation of accept. When the RIPPLE_OPEN_LEDGER macro is set to 1 (BeastConfig.h), the global Application OpenLedger singleton maintains its open ledger in parallel by applying new transactions and accepting new last closed ledgers. In the current implementation this does not affect transaction processing but logs any differences in the results as compared to the original code. Logging shows an occasional mismatch in what the OpenLedger builds versus the original code, usually an OfferCreate which gets a terINSUF_RESERVE instead of tesSUCCESS.
97 lines
2.6 KiB
C++
97 lines
2.6 KiB
C++
//------------------------------------------------------------------------------
|
|
/*
|
|
This file is part of rippled: https://github.com/ripple/rippled
|
|
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
purpose with or without fee is hereby granted, provided that the above
|
|
copyright notice and this permission notice appear in all copies.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
*/
|
|
//==============================================================================
|
|
|
|
#include <BeastConfig.h>
|
|
#include <ripple/app/misc/CanonicalTXSet.h>
|
|
|
|
namespace ripple {
|
|
|
|
bool CanonicalTXSet::Key::operator< (Key const& rhs) const
|
|
{
|
|
if (mAccount < rhs.mAccount) return true;
|
|
|
|
if (mAccount > rhs.mAccount) return false;
|
|
|
|
if (mSeq < rhs.mSeq) return true;
|
|
|
|
if (mSeq > rhs.mSeq) return false;
|
|
|
|
return mTXid < rhs.mTXid;
|
|
}
|
|
|
|
bool CanonicalTXSet::Key::operator> (Key const& rhs) const
|
|
{
|
|
if (mAccount > rhs.mAccount) return true;
|
|
|
|
if (mAccount < rhs.mAccount) return false;
|
|
|
|
if (mSeq > rhs.mSeq) return true;
|
|
|
|
if (mSeq < rhs.mSeq) return false;
|
|
|
|
return mTXid > rhs.mTXid;
|
|
}
|
|
|
|
bool CanonicalTXSet::Key::operator<= (Key const& rhs) const
|
|
{
|
|
if (mAccount < rhs.mAccount) return true;
|
|
|
|
if (mAccount > rhs.mAccount) return false;
|
|
|
|
if (mSeq < rhs.mSeq) return true;
|
|
|
|
if (mSeq > rhs.mSeq) return false;
|
|
|
|
return mTXid <= rhs.mTXid;
|
|
}
|
|
|
|
bool CanonicalTXSet::Key::operator>= (Key const& rhs)const
|
|
{
|
|
if (mAccount > rhs.mAccount) return true;
|
|
|
|
if (mAccount < rhs.mAccount) return false;
|
|
|
|
if (mSeq > rhs.mSeq) return true;
|
|
|
|
if (mSeq < rhs.mSeq) return false;
|
|
|
|
return mTXid >= rhs.mTXid;
|
|
}
|
|
|
|
void CanonicalTXSet::insert (std::shared_ptr<STTx const> const& txn)
|
|
{
|
|
uint256 effectiveAccount = mSetHash;
|
|
|
|
effectiveAccount ^= to256 (txn->getAccountID(sfAccount));
|
|
|
|
mMap.insert (std::make_pair (
|
|
Key (effectiveAccount, txn->getSequence (), txn->getTransactionID ()),
|
|
txn));
|
|
}
|
|
|
|
CanonicalTXSet::iterator CanonicalTXSet::erase (iterator const& it)
|
|
{
|
|
iterator tmp = it;
|
|
++tmp;
|
|
mMap.erase (it);
|
|
return tmp;
|
|
}
|
|
|
|
} // ripple
|