mirror of
https://github.com/Xahau/xahaud.git
synced 2026-09-26 23:29:04 +00:00
This commit makes several changes to the base_uint class, which was originally taken from Bitcoin and has already been heavily modified by Ripple engineers. It introduces conditional widening of the internal limb type, going from 32 to 64 bits if the requested number of bits is a multiple of 64. This change alone halves iteration counts for common operations and, combined with use of add-with-carry compiler intrinsics, helps leverage modern processor resources more effectively. Other changes include: - Extracting the arithmetic operations into free helper functions which operate on the limb array directly. - Replacing the SFINAE-based is_contiguous_container trait with a byte_copy_source concept. - Rewriting the hex parsing around a consteval lookup table and a simple left-to-right loop, replacing the old shift-based nibble accumulator. - Using memmove instead of memcpy when copying to avoid UB in the unlikely case where the source and destination buffers overlap. - Eliminating a workaround in operator<=> to handle MacOS quirks. - Removing redundant parseHex overloads and introducing from_hex as a factory function. - Introducing a tagless_compare() for cross-tag comparison. - Adding noexcept, [[nodiscard]], and constexpr throughout.
79 lines
2.8 KiB
C++
79 lines
2.8 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_PROTOCOL_SYSTEMPARAMETERS_H_INCLUDED
|
|
#define RIPPLE_PROTOCOL_SYSTEMPARAMETERS_H_INCLUDED
|
|
|
|
#include <xrpl/basics/chrono.h>
|
|
#include <xrpl/protocol/XRPAmount.h>
|
|
|
|
#include <cstdint>
|
|
#include <string_view>
|
|
|
|
namespace ripple {
|
|
|
|
// Various protocol and system specific constant globals.
|
|
|
|
/* The name of the system. */
|
|
inline constexpr std::string_view systemName = "xahau";
|
|
|
|
/* The currency code for the native currency. */
|
|
inline constexpr std::string_view systemCurrencyCode = "XAH";
|
|
|
|
/** Number of drops in the genesis account. */
|
|
inline constexpr XRPAmount INITIAL_XRP{100'000'000'000 * DROPS_PER_XRP};
|
|
|
|
/** Returns true if the amount does not exceed the initial XRP in existence. */
|
|
inline bool
|
|
isLegalAmount(XRPAmount const& amount) noexcept
|
|
{
|
|
return amount <= INITIAL_XRP;
|
|
}
|
|
|
|
/** Returns true if the absolute value of the amount does not exceed the initial
|
|
* XRP in existence. */
|
|
inline bool
|
|
isLegalAmountSigned(XRPAmount const& amount) noexcept
|
|
{
|
|
return amount >= -INITIAL_XRP && amount <= INITIAL_XRP;
|
|
}
|
|
|
|
/** The XRP ledger network's earliest allowed sequence */
|
|
inline constexpr std::uint32_t XRP_LEDGER_EARLIEST_SEQ{1U};
|
|
|
|
/** The minimum amount of support an amendment should have.
|
|
|
|
@note This value is used by legacy code and will become obsolete
|
|
once the fixAmendmentMajorityCalc amendment activates.
|
|
*/
|
|
inline constexpr std::ratio<204, 256> preFixAmendmentMajorityCalcThreshold;
|
|
|
|
inline constexpr std::ratio<80, 100> postFixAmendmentMajorityCalcThreshold;
|
|
|
|
/** The minimum amount of time an amendment must hold a majority */
|
|
constexpr std::chrono::seconds const defaultAmendmentMajorityTime =
|
|
std::chrono::days{5};
|
|
|
|
} // namespace ripple
|
|
|
|
/** Default peer port (IANA registered) */
|
|
inline std::uint16_t constexpr DEFAULT_PEER_PORT{21337};
|
|
|
|
#endif
|