mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Refactor Ledger and LedgerEntrySet:
Member functions and free functions on Ledger and LedgerEntrySet are rewritten in terms of new abstract interfaces `BasicView` and `View`, representing the set of non-decomposable primitives necessary to read and write state map items in a ledger, and to overlay a discardable view onto a Ledger that can calculate metadata during transaction processing. const-correctness is enforced through the parameter and return types. The MetaView now supports multi-level stacking: A MetaView can be stacked on top of either a Ledger or another MetaView, up to any number of levels. The getSLEi member function is removed. The CachedView wrapper replaces it, wrapping a View such that any function called with a CachedView will go through the SLECache. * Add BasicView, View, CachedView * Rename LedgerEntrySet to MetaView * Factor out free functions * Consolidate free functions in ViewAPI * Remove unused class members and free functions
This commit is contained in:
@@ -42,7 +42,6 @@ getLedgerHashIndex (std::uint32_t desiredLedgerIndex)
|
||||
std::uint16_t(spaceSkipList),
|
||||
std::uint32_t(desiredLedgerIndex >> 16));
|
||||
}
|
||||
|
||||
// get the index of the node that holds the enabled amendments
|
||||
uint256
|
||||
getLedgerAmendmentIndex ()
|
||||
@@ -211,11 +210,9 @@ Keylet account_t::operator()(
|
||||
getAccountRootIndex(ra.getAccountID()) };
|
||||
}
|
||||
|
||||
Keylet owndir_t::operator()(
|
||||
AccountID const& id) const
|
||||
Keylet child (uint256 const& key)
|
||||
{
|
||||
return { ltDIR_NODE,
|
||||
getOwnerDirIndex(id) };
|
||||
return { ltCHILD, key };
|
||||
}
|
||||
|
||||
Keylet skip_t::operator()() const
|
||||
@@ -236,7 +233,7 @@ Keylet amendments_t::operator()() const
|
||||
getLedgerAmendmentIndex() };
|
||||
}
|
||||
|
||||
Keylet fee_t::operator()() const
|
||||
Keylet fees_t::operator()() const
|
||||
{
|
||||
return { ltFEE_SETTINGS,
|
||||
getLedgerFeeIndex() };
|
||||
@@ -248,6 +245,20 @@ Keylet book_t::operator()(Book const& b) const
|
||||
getBookBase(b) };
|
||||
}
|
||||
|
||||
Keylet line_t::operator()(AccountID const& id0,
|
||||
AccountID const& id1, Currency const& currency) const
|
||||
{
|
||||
return { ltRIPPLE_STATE,
|
||||
getRippleStateIndex(id0, id1, currency) };
|
||||
}
|
||||
|
||||
Keylet line_t::operator()(AccountID const& id,
|
||||
Issue const& issue) const
|
||||
{
|
||||
return { ltRIPPLE_STATE,
|
||||
getRippleStateIndex(id, issue) };
|
||||
}
|
||||
|
||||
Keylet offer_t::operator()(AccountID const& id,
|
||||
std::uint32_t seq) const
|
||||
{
|
||||
@@ -255,14 +266,6 @@ Keylet offer_t::operator()(AccountID const& id,
|
||||
getOfferIndex(id, seq) };
|
||||
}
|
||||
|
||||
Keylet item_t::operator()(Keylet const& k,
|
||||
std::uint64_t index,
|
||||
LedgerEntryType type) const
|
||||
{
|
||||
return { type,
|
||||
getDirNodeIndex(k.key, index) };
|
||||
}
|
||||
|
||||
Keylet quality_t::operator()(Keylet const& k,
|
||||
std::uint64_t q) const
|
||||
{
|
||||
@@ -285,26 +288,39 @@ Keylet ticket_t::operator()(AccountID const& id,
|
||||
getTicketIndex(id, seq) };
|
||||
}
|
||||
|
||||
Keylet trust_t::operator()(AccountID const& id0,
|
||||
AccountID const& id1, Currency const& currency) const
|
||||
{
|
||||
return { ltRIPPLE_STATE,
|
||||
getRippleStateIndex(id0, id1, currency) };
|
||||
}
|
||||
|
||||
Keylet trust_t::operator()(AccountID const& id,
|
||||
Issue const& issue) const
|
||||
{
|
||||
return { ltRIPPLE_STATE,
|
||||
getRippleStateIndex(id, issue) };
|
||||
}
|
||||
|
||||
Keylet signers_t::operator()(AccountID const& id) const
|
||||
{
|
||||
return { ltSIGNER_LIST,
|
||||
getSignerListIndex(id) };
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
Keylet unchecked (uint256 const& key)
|
||||
{
|
||||
return { ltANY, key };
|
||||
}
|
||||
|
||||
Keylet ownerDir(AccountID const& id)
|
||||
{
|
||||
return { ltDIR_NODE,
|
||||
getOwnerDirIndex(id) };
|
||||
}
|
||||
|
||||
Keylet page(uint256 const& key,
|
||||
std::uint64_t index)
|
||||
{
|
||||
return { ltDIR_NODE,
|
||||
getDirNodeIndex(key, index) };
|
||||
}
|
||||
|
||||
Keylet page(Keylet const& root,
|
||||
std::uint64_t index)
|
||||
{
|
||||
assert(root.type == ltDIR_NODE);
|
||||
return page(root.key, index);
|
||||
}
|
||||
|
||||
} // keylet
|
||||
|
||||
} // ripple
|
||||
|
||||
Reference in New Issue
Block a user