mirror of
https://github.com/XRPLF/clio.git
synced 2026-04-29 15:37:53 +00:00
93 lines
2.9 KiB
C++
93 lines
2.9 KiB
C++
//------------------------------------------------------------------------------
|
|
/*
|
|
This file is part of clio: https://github.com/XRPLF/clio
|
|
Copyright (c) 2023, the clio developers.
|
|
|
|
Permission to use, copy, modify, and 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.
|
|
*/
|
|
//==============================================================================
|
|
|
|
#pragma once
|
|
|
|
#include <fmt/core.h>
|
|
#include <ripple/basics/Slice.h>
|
|
#include <ripple/basics/StringUtilities.h>
|
|
#include <ripple/basics/strHex.h>
|
|
#include <ripple/protocol/LedgerFormats.h>
|
|
#include <ripple/protocol/LedgerHeader.h>
|
|
#include <ripple/protocol/jss.h>
|
|
|
|
#include <string>
|
|
#include <unordered_set>
|
|
#include <vector>
|
|
|
|
namespace util {
|
|
|
|
/**
|
|
* @brief Returns a string set of all supported ledger entry types
|
|
*
|
|
* @return The set of ledger entry types
|
|
*/
|
|
std::unordered_set<std::string> const&
|
|
getLedgerEntryTypeStrs();
|
|
|
|
/**
|
|
* @brief Return the ledger type from a string representation
|
|
*
|
|
* @param entryName The string representation of the ledger entry type
|
|
* @return The ledger entry type
|
|
*/
|
|
ripple::LedgerEntryType
|
|
getLedgerEntryTypeFromStr(std::string const& entryName);
|
|
|
|
/**
|
|
* @brief Return the list of ledger entry types which will block the account deletion
|
|
*
|
|
* @return The list of ledger entry types
|
|
*/
|
|
std::vector<ripple::LedgerEntryType> const&
|
|
getDeletionBlockerLedgerTypes();
|
|
|
|
/**
|
|
* @brief Deserializes a ripple::LedgerHeader from ripple::Slice of data.
|
|
*
|
|
* @param data The slice to deserialize
|
|
* @return The deserialized ripple::LedgerHeader
|
|
*/
|
|
inline ripple::LedgerHeader
|
|
deserializeHeader(ripple::Slice data)
|
|
{
|
|
return ripple::deserializeHeader(data, /* hasHash = */ true);
|
|
}
|
|
|
|
/**
|
|
* @brief A helper function that converts a ripple::LedgerHeader to a string representation.
|
|
*
|
|
* @param info The ledger header
|
|
* @return The string representation of the supplied ledger header
|
|
*/
|
|
inline std::string
|
|
toString(ripple::LedgerHeader const& info)
|
|
{
|
|
return fmt::format(
|
|
"LedgerHeader {{Sequence: {}, Hash: {}, TxHash: {}, AccountHash: {}, ParentHash: {}}}",
|
|
info.seq,
|
|
ripple::strHex(info.hash),
|
|
strHex(info.txHash),
|
|
ripple::strHex(info.accountHash),
|
|
strHex(info.parentHash)
|
|
);
|
|
}
|
|
|
|
} // namespace util
|