mirror of
https://github.com/XRPLF/rippled.git
synced 2026-07-25 16:10:57 +00:00
52 lines
1.3 KiB
C++
52 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include <xrpl/basics/SHAMapHash.h>
|
|
#include <xrpl/basics/base_uint.h>
|
|
#include <xrpl/basics/safe_cast.h>
|
|
|
|
#include <stdexcept>
|
|
#include <string>
|
|
#include <type_traits>
|
|
|
|
namespace xrpl {
|
|
|
|
enum class SHAMapType {
|
|
TRANSACTION = 1, // A tree of transactions
|
|
STATE = 2, // A tree of state nodes
|
|
FREE = 3, // A tree not part of a ledger
|
|
};
|
|
|
|
inline std::string
|
|
to_string(SHAMapType t)
|
|
{
|
|
switch (t)
|
|
{
|
|
case SHAMapType::TRANSACTION:
|
|
return "Transaction Tree";
|
|
case SHAMapType::STATE:
|
|
return "State Tree";
|
|
case SHAMapType::FREE:
|
|
return "Free Tree";
|
|
default:
|
|
return std::to_string(safeCast<std::underlying_type_t<SHAMapType>>(t));
|
|
}
|
|
}
|
|
|
|
class SHAMapMissingNode : public std::runtime_error
|
|
{
|
|
public:
|
|
SHAMapMissingNode(SHAMapType t, SHAMapHash const& hash, std::string const& location)
|
|
: std::runtime_error(
|
|
"Missing Node: " + to_string(t) + ": hash " + to_string(hash) + " in: " + location)
|
|
{
|
|
}
|
|
|
|
SHAMapMissingNode(SHAMapType t, uint256 const& id, std::string const& location)
|
|
: std::runtime_error(
|
|
"Missing Node: " + to_string(t) + ": id " + to_string(id) + " in: " + location)
|
|
{
|
|
}
|
|
};
|
|
|
|
} // namespace xrpl
|