mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Metadata is correctly generated for the case where a ledger entry is only changed as a consequence of threading. This changes the result compared to previous versions, which produced more than necessary for these cases.
151 lines
3.9 KiB
C++
151 lines
3.9 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.
|
|
*/
|
|
//==============================================================================
|
|
|
|
#ifndef RIPPLE_LEDGER_APPLYSTATETABLE_H_INCLUDED
|
|
#define RIPPLE_LEDGER_APPLYSTATETABLE_H_INCLUDED
|
|
|
|
#include <ripple/ledger/OpenView.h>
|
|
#include <ripple/ledger/RawView.h>
|
|
#include <ripple/ledger/ReadView.h>
|
|
#include <ripple/protocol/TER.h>
|
|
#include <beast/utility/Journal.h>
|
|
#include <memory>
|
|
// VFALCO TODO Move TxMeta to ripple/ledger/
|
|
#include <ripple/ledger/TxMeta.h>
|
|
|
|
namespace ripple {
|
|
namespace detail {
|
|
|
|
// Helper class that buffers modifications
|
|
class ApplyStateTable
|
|
{
|
|
public:
|
|
using key_type = ReadView::key_type;
|
|
|
|
private:
|
|
enum class Action
|
|
{
|
|
cache,
|
|
erase,
|
|
insert,
|
|
modify,
|
|
};
|
|
|
|
using items_t = std::map<key_type,
|
|
std::pair<Action, std::shared_ptr<SLE>>>;
|
|
|
|
items_t items_;
|
|
std::uint64_t dropsDestroyed_ = 0;
|
|
|
|
public:
|
|
ApplyStateTable() = default;
|
|
ApplyStateTable (ApplyStateTable const&) = delete;
|
|
ApplyStateTable& operator= (ApplyStateTable&&) = delete;
|
|
ApplyStateTable& operator= (ApplyStateTable const&) = delete;
|
|
|
|
#ifdef _MSC_VER
|
|
ApplyStateTable (ApplyStateTable&& other)
|
|
: items_ (std::move(other.items_))
|
|
, dropsDestroyed_ (std::move(other.dropsDestroyed_))
|
|
{
|
|
}
|
|
#else
|
|
ApplyStateTable (ApplyStateTable&&) = default;
|
|
#endif
|
|
|
|
void
|
|
apply (RawView& to) const;
|
|
|
|
void
|
|
apply (OpenView& to, STTx const& tx,
|
|
TER ter, boost::optional<
|
|
STAmount> const& deliver,
|
|
beast::Journal j);
|
|
|
|
bool
|
|
exists (ReadView const& base,
|
|
Keylet const& k) const;
|
|
|
|
boost::optional<key_type>
|
|
succ (ReadView const& base,
|
|
key_type const& key, boost::optional<
|
|
key_type> const& last) const;
|
|
|
|
std::shared_ptr<SLE const>
|
|
read (ReadView const& base,
|
|
Keylet const& k) const;
|
|
|
|
std::shared_ptr<SLE>
|
|
peek (ReadView const& base,
|
|
Keylet const& k);
|
|
|
|
void
|
|
erase (ReadView const& base,
|
|
std::shared_ptr<SLE> const& sle);
|
|
|
|
void
|
|
rawErase (ReadView const& base,
|
|
std::shared_ptr<SLE> const& sle);
|
|
|
|
void
|
|
insert(ReadView const& base,
|
|
std::shared_ptr<SLE> const& sle);
|
|
|
|
void
|
|
update(ReadView const& base,
|
|
std::shared_ptr<SLE> const& sle);
|
|
|
|
void
|
|
replace(ReadView const& base,
|
|
std::shared_ptr<SLE> const& sle);
|
|
|
|
void
|
|
destroyXRP (std::uint64_t feeDrops);
|
|
|
|
private:
|
|
using Mods = hash_map<key_type,
|
|
std::shared_ptr<SLE>>;
|
|
|
|
static
|
|
bool
|
|
threadItem (TxMeta& meta,
|
|
std::shared_ptr<SLE> const& to);
|
|
|
|
std::shared_ptr<SLE>
|
|
getForMod (ReadView const& base,
|
|
key_type const& key, Mods& mods,
|
|
beast::Journal j);
|
|
|
|
bool
|
|
threadTx (ReadView const& base, TxMeta& meta,
|
|
AccountID const& to, Mods& mods,
|
|
beast::Journal j);
|
|
|
|
bool
|
|
threadOwners (ReadView const& base,
|
|
TxMeta& meta, std::shared_ptr<
|
|
SLE const> const& sle, Mods& mods,
|
|
beast::Journal j);
|
|
};
|
|
|
|
} // detail
|
|
} // ripple
|
|
|
|
#endif
|