Clean up and modernize code:

This commit removes obsolete comments, dead or no longer useful
code, and workarounds for several issues that were present in older
compilers that we no longer support.

Specifically:

- It improves the transaction metadata handling class, simplifying
  its use and making it less error-prone.
- It reduces the footprint of the Serializer class by consolidating
  code and leveraging templates.
- It cleanups the ST* class hierarchy, removing dead code, improving
  and consolidating code to reduce complexity and code duplication.
- It shores up the handling of currency codes and the conversation
  between 160-bit currency codes and their string representation.
- It migrates beast::secure_erase to the ripple namespace and uses
  a call to OpenSSL_cleanse instead of the custom implementation.
This commit is contained in:
Nik Bougalis
2020-03-27 14:26:46 -07:00
parent 6c72d5cf7e
commit dbee3f01b7
45 changed files with 244 additions and 703 deletions

View File

@@ -63,9 +63,7 @@ Cluster::update(
{
std::lock_guard lock(mutex_);
// We can't use auto here yet due to the libstdc++ issue
// described at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68190
std::set<ClusterNode, Comparator>::iterator iter = nodes_.find(identity);
auto iter = nodes_.find(identity);
if (iter != nodes_.end())
{

View File

@@ -237,7 +237,7 @@ OverlayImpl::onHandoff(
return handoff;
}
// TODO Validate HTTP request
// Validate HTTP request
{
auto const types = beast::rfc2616::split_commas(request["Connect-As"]);
@@ -1083,14 +1083,13 @@ OverlayImpl::processValidatorList(
{
// If the target is in the form "/vl/<validator_list_public_key>",
// return the most recent validator list for that key.
if (!req.target().starts_with("/vl/") || !setup_.vlEnabled)
constexpr std::string_view prefix("/vl/");
if (!req.target().starts_with(prefix.data()) || !setup_.vlEnabled)
return false;
auto key = req.target();
if (key.starts_with("/vl/"))
key.remove_prefix(strlen("/vl/"));
else
key.remove_prefix(strlen("/unl/"));
auto key = req.target().substr(prefix.size());
if (key.empty())
return false;

View File

@@ -32,7 +32,16 @@ namespace ripple {
@note The list must be sorted in strictly ascending order (and so
it may not contain any duplicates!)
*/
constexpr ProtocolVersion const supportedProtocolList[]{{1, 2}, {2, 0}, {2, 1}};
// clang-format off
constexpr ProtocolVersion const supportedProtocolList[]
{
{1, 2},
{2, 0},
{2, 1}
};
// clang-format on
// This ugly construct ensures that supportedProtocolList is sorted in strictly
// ascending order and doesn't contain any duplicates.