mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Add [features] section to .cfg:
This non-production config section allows features to be enabled
by listing their text descriptions, one line each, in the config
section titled "features".
NOTE: Feature names with leading or trailing whitespace, or
containing an equals sign ('=') are not supported.
This commit is contained in:
committed by
Edward Hennis
parent
2ec40cb6f1
commit
d49f9ea109
@@ -2751,6 +2751,8 @@
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\protocol\ErrorCodes.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\protocol\Feature.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\protocol\HashPrefix.h">
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\protocol\impl\AccountID.cpp">
|
||||
@@ -2773,6 +2775,10 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\protocol\impl\Feature.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\protocol\impl\HashPrefix.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
||||
@@ -2945,6 +2951,8 @@
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\protocol\SOTemplate.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\protocol\st.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\protocol\STAccount.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\protocol\STAmount.h">
|
||||
|
||||
@@ -3471,6 +3471,9 @@
|
||||
<ClInclude Include="..\..\src\ripple\protocol\ErrorCodes.h">
|
||||
<Filter>ripple\protocol</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\protocol\Feature.h">
|
||||
<Filter>ripple\protocol</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\protocol\HashPrefix.h">
|
||||
<Filter>ripple\protocol</Filter>
|
||||
</ClInclude>
|
||||
@@ -3489,6 +3492,9 @@
|
||||
<ClCompile Include="..\..\src\ripple\protocol\impl\ErrorCodes.cpp">
|
||||
<Filter>ripple\protocol\impl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\protocol\impl\Feature.cpp">
|
||||
<Filter>ripple\protocol\impl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\protocol\impl\HashPrefix.cpp">
|
||||
<Filter>ripple\protocol\impl</Filter>
|
||||
</ClCompile>
|
||||
@@ -3651,6 +3657,9 @@
|
||||
<ClInclude Include="..\..\src\ripple\protocol\SOTemplate.h">
|
||||
<Filter>ripple\protocol</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\protocol\st.h">
|
||||
<Filter>ripple\protocol</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\protocol\STAccount.h">
|
||||
<Filter>ripple\protocol</Filter>
|
||||
</ClInclude>
|
||||
|
||||
@@ -29,23 +29,25 @@ namespace ripple {
|
||||
struct PreflightContext
|
||||
{
|
||||
public:
|
||||
explicit PreflightContext(STTx const& tx_,
|
||||
Rules const& rules_, ApplyFlags flags_,
|
||||
SigVerify verify_,
|
||||
beast::Journal j_ = {})
|
||||
: tx(tx_)
|
||||
, rules(rules_)
|
||||
, flags(flags_)
|
||||
, verify(verify_)
|
||||
, j(j_)
|
||||
{
|
||||
}
|
||||
|
||||
STTx const& tx;
|
||||
Rules const& rules;
|
||||
ApplyFlags flags;
|
||||
SigVerify verify;
|
||||
Config const& config;
|
||||
beast::Journal j;
|
||||
|
||||
PreflightContext(STTx const& tx_,
|
||||
Rules const& rules_, ApplyFlags flags_,
|
||||
SigVerify verify_, Config const& config_,
|
||||
beast::Journal j_)
|
||||
: tx(tx_)
|
||||
, rules(rules_)
|
||||
, flags(flags_)
|
||||
, verify(verify_)
|
||||
, config(config_)
|
||||
, j(j_)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class Transactor
|
||||
|
||||
@@ -86,8 +86,8 @@ preflight (Rules const& rules, STTx const& tx,
|
||||
{
|
||||
try
|
||||
{
|
||||
PreflightContext pfctx(
|
||||
tx, rules, flags, verify, j);
|
||||
PreflightContext pfctx(tx,
|
||||
rules, flags, verify, config, j);
|
||||
return invoke_preflight(pfctx);
|
||||
}
|
||||
catch (std::exception const& e)
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#define RIPPLE_CORE_CONFIG_H_INCLUDED
|
||||
|
||||
#include <ripple/basics/BasicConfig.h>
|
||||
#include <ripple/basics/base_uint.h>
|
||||
#include <ripple/protocol/SystemParameters.h>
|
||||
#include <ripple/protocol/RippleAddress.h>
|
||||
#include <ripple/json/json_value.h>
|
||||
@@ -36,6 +37,7 @@
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
namespace ripple {
|
||||
@@ -53,6 +55,8 @@ countSectionEntries (IniFileSections& secSource, std::string const& strSection);
|
||||
IniFileSections::mapped_type*
|
||||
getIniFileSection (IniFileSections& secSource, std::string const& strSection);
|
||||
|
||||
class Rules;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
enum SizedItemName
|
||||
@@ -257,6 +261,8 @@ public:
|
||||
boost::optional<boost::asio::ip::address_v4> rpc_ip;
|
||||
boost::optional<std::uint16_t> rpc_port;
|
||||
|
||||
std::unordered_set<uint256, beast::uhash<>> features;
|
||||
|
||||
public:
|
||||
Config ();
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <ripple/core/ConfigSections.h>
|
||||
#include <ripple/basics/Log.h>
|
||||
#include <ripple/json/json_reader.h>
|
||||
#include <ripple/protocol/Feature.h>
|
||||
#include <ripple/protocol/SystemParameters.h>
|
||||
#include <ripple/net/HTTPClient.h>
|
||||
#include <beast/http/URL.h>
|
||||
@@ -553,6 +554,12 @@ void Config::loadFromString (std::string const& fileContents)
|
||||
|
||||
if (getSingleSection (secConfig, SECTION_DEBUG_LOGFILE, strTemp))
|
||||
DEBUG_LOGFILE = strTemp;
|
||||
|
||||
{
|
||||
auto const part = section("features");
|
||||
for(auto const& s : part.values())
|
||||
features.insert(feature(s));
|
||||
}
|
||||
}
|
||||
|
||||
int Config::getSize (SizedItemName item) const
|
||||
|
||||
@@ -26,10 +26,12 @@
|
||||
#include <ripple/protocol/Protocol.h>
|
||||
#include <ripple/protocol/STLedgerEntry.h>
|
||||
#include <ripple/protocol/STTx.h>
|
||||
#include <beast/hash/uhash.h>
|
||||
#include <boost/optional.hpp>
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <unordered_set>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -137,7 +139,9 @@ public:
|
||||
|
||||
/** Returns `true` if a feature is enabled. */
|
||||
bool
|
||||
enabled (uint256 const& feature) const;
|
||||
enabled (uint256 const& id,
|
||||
std::unordered_set<uint256,
|
||||
beast::uhash<>> const& presets) const;
|
||||
|
||||
/** Returns `true` if these rules don't match the ledger. */
|
||||
bool
|
||||
|
||||
@@ -86,11 +86,15 @@ Rules::Rules (DigestAwareReadView const& ledger)
|
||||
}
|
||||
|
||||
bool
|
||||
Rules::enabled (uint256 const& feature) const
|
||||
Rules::enabled (uint256 const& id,
|
||||
std::unordered_set<uint256,
|
||||
beast::uhash<>> const& presets) const
|
||||
{
|
||||
if (presets.count(id) > 0)
|
||||
return true;
|
||||
if (! impl_)
|
||||
return false;
|
||||
return impl_->enabled(feature);
|
||||
return impl_->enabled(id);
|
||||
}
|
||||
|
||||
bool
|
||||
|
||||
39
src/ripple/protocol/Feature.h
Normal file
39
src/ripple/protocol/Feature.h
Normal file
@@ -0,0 +1,39 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
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_FEATURE_H_INCLUDED
|
||||
#define RIPPLE_PROTOCOL_FEATURE_H_INCLUDED
|
||||
|
||||
#include <ripple/basics/base_uint.h>
|
||||
#include <string>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
/** Convert feature description to feature id. */
|
||||
/** @{ */
|
||||
uint256
|
||||
feature (std::string const& name);
|
||||
|
||||
uint256
|
||||
feature (const char* name);
|
||||
/** @} */
|
||||
|
||||
} // ripple
|
||||
|
||||
#endif
|
||||
48
src/ripple/protocol/impl/Feature.cpp
Normal file
48
src/ripple/protocol/impl/Feature.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <BeastConfig.h>
|
||||
#include <ripple/protocol/digest.h>
|
||||
#include <ripple/protocol/Feature.h>
|
||||
#include <cstring>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
static
|
||||
uint256
|
||||
feature (char const* s, std::size_t n)
|
||||
{
|
||||
sha512_half_hasher h;
|
||||
h(s, n);
|
||||
return static_cast<uint256>(h);
|
||||
}
|
||||
|
||||
uint256
|
||||
feature (std::string const& name)
|
||||
{
|
||||
return feature(name.c_str(), name.size());
|
||||
}
|
||||
|
||||
uint256
|
||||
feature (const char* name)
|
||||
{
|
||||
return feature(name, std::strlen(name));
|
||||
}
|
||||
|
||||
} // ripple
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <ripple/protocol/impl/ByteOrder.cpp>
|
||||
#include <ripple/protocol/impl/digest.cpp>
|
||||
#include <ripple/protocol/impl/ErrorCodes.cpp>
|
||||
#include <ripple/protocol/impl/Feature.cpp>
|
||||
#include <ripple/protocol/impl/HashPrefix.cpp>
|
||||
#include <ripple/protocol/impl/Indexes.cpp>
|
||||
#include <ripple/protocol/impl/Keylet.cpp>
|
||||
|
||||
Reference in New Issue
Block a user