mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Enable Amendments from config file or static data (RIPD-746):
* The rippled.cfg file has a new section called "amendments" * Each line in this section contains two white-space separated items ** The first item is the ID of the amendment (a 256-bit hash) ** The second item is the friendly name * Replaces config section name macros with variables * Make addKnown arguments safer * Added lock to addKnown
This commit is contained in:
committed by
Nik Bougalis
parent
312aec79ca
commit
44450bf644
@@ -21,6 +21,7 @@
|
||||
#define RIPPLE_AMENDMENT_TABLE_H
|
||||
|
||||
#include <ripple/app/book/Types.h>
|
||||
#include <ripple/app/misc/Validations.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -46,6 +47,48 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/** 256-bit Id and human friendly name of an amendment.
|
||||
*/
|
||||
class AmendmentName final
|
||||
{
|
||||
private:
|
||||
uint256 mId;
|
||||
// Keep the hex string around for error reporting
|
||||
std::string mHexString;
|
||||
std::string mFriendlyName;
|
||||
bool mValid{false};
|
||||
|
||||
public:
|
||||
AmendmentName () = default;
|
||||
AmendmentName (AmendmentName const& rhs) = default;
|
||||
// AmendmentName (AmendmentName&& rhs) = default; // MSVS not supported
|
||||
AmendmentName (uint256 const& id, std::string friendlyName)
|
||||
: mId (id), mFriendlyName (std::move (friendlyName)), mValid (true)
|
||||
{
|
||||
}
|
||||
AmendmentName (std::string id, std::string friendlyName)
|
||||
: mHexString (std::move (id)), mFriendlyName (std::move (friendlyName))
|
||||
{
|
||||
mValid = mId.SetHex (mHexString);
|
||||
}
|
||||
bool valid () const
|
||||
{
|
||||
return mValid;
|
||||
}
|
||||
uint256 const& id () const
|
||||
{
|
||||
return mId;
|
||||
}
|
||||
std::string const& hexString () const
|
||||
{
|
||||
return mHexString;
|
||||
}
|
||||
std::string const& friendlyName () const
|
||||
{
|
||||
return mFriendlyName;
|
||||
}
|
||||
};
|
||||
|
||||
/** Current state of an amendment.
|
||||
Tells if a amendment is supported, enabled or vetoed. A vetoed amendment
|
||||
means the node will never announce its support.
|
||||
@@ -53,22 +96,19 @@ public:
|
||||
class AmendmentState
|
||||
{
|
||||
public:
|
||||
bool mVetoed; // We don't want this amendment enabled
|
||||
bool mEnabled;
|
||||
bool mSupported;
|
||||
bool mDefault; // Include in genesis ledger
|
||||
bool mVetoed{false}; // We don't want this amendment enabled
|
||||
bool mEnabled{false};
|
||||
bool mSupported{false};
|
||||
bool mDefault{false}; // Include in genesis ledger
|
||||
|
||||
core::Clock::time_point m_firstMajority; // First time we saw a majority (close time)
|
||||
core::Clock::time_point m_lastMajority; // Most recent time we saw a majority (close time)
|
||||
core::Clock::time_point
|
||||
m_firstMajority{0}; // First time we saw a majority (close time)
|
||||
core::Clock::time_point
|
||||
m_lastMajority{0}; // Most recent time we saw a majority (close time)
|
||||
|
||||
std::string mFriendlyName;
|
||||
|
||||
AmendmentState ()
|
||||
: mVetoed (false), mEnabled (false), mSupported (false), mDefault (false),
|
||||
m_firstMajority (0), m_lastMajority (0)
|
||||
{
|
||||
;
|
||||
}
|
||||
AmendmentState () = default;
|
||||
|
||||
void setVeto ()
|
||||
{
|
||||
@@ -104,6 +144,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class Section;
|
||||
|
||||
/** The amendment table stores the list of enabled and potential amendments.
|
||||
Individuals amendments are voted on by validators during the consensus
|
||||
process.
|
||||
@@ -123,10 +165,17 @@ public:
|
||||
|
||||
virtual ~AmendmentTable() { }
|
||||
|
||||
virtual void addInitial () = 0;
|
||||
/**
|
||||
@param section the config section of initial amendments
|
||||
*/
|
||||
virtual void addInitial (Section const& section) = 0;
|
||||
|
||||
/** Add an amendment to the AmendmentTable
|
||||
|
||||
@throw will throw if the name parameter is not valid
|
||||
*/
|
||||
virtual void addKnown (AmendmentName const& name) = 0;
|
||||
|
||||
virtual AmendmentState* addKnown (const char* amendmentID,
|
||||
const char* friendlyName, bool veto) = 0;
|
||||
virtual uint256 get (std::string const& name) = 0;
|
||||
|
||||
virtual bool veto (uint256 const& amendment) = 0;
|
||||
@@ -138,9 +187,17 @@ public:
|
||||
virtual bool isEnabled (uint256 const& amendment) = 0;
|
||||
virtual bool isSupported (uint256 const& amendment) = 0;
|
||||
|
||||
/** Enable only the specified amendments.
|
||||
Other amendments in the table will be set to disabled.
|
||||
*/
|
||||
virtual void setEnabled (const std::vector<uint256>& amendments) = 0;
|
||||
/** Support only the specified amendments.
|
||||
Other amendments in the table will be set to unsupported.
|
||||
*/
|
||||
virtual void setSupported (const std::vector<uint256>& amendments) = 0;
|
||||
|
||||
/** Update the walletDB with the majority times.
|
||||
*/
|
||||
virtual void reportValidations (const AmendmentSet&) = 0;
|
||||
|
||||
virtual Json::Value getJson (int) = 0;
|
||||
@@ -154,10 +211,12 @@ public:
|
||||
doVoting (Ledger::ref lastClosedLedger, SHAMap::ref initialPosition) = 0;
|
||||
};
|
||||
|
||||
std::unique_ptr<AmendmentTable>
|
||||
make_AmendmentTable (std::chrono::seconds majorityTime, int majorityFraction,
|
||||
beast::Journal journal);
|
||||
std::unique_ptr<AmendmentTable> make_AmendmentTable (
|
||||
std::chrono::seconds majorityTime,
|
||||
int majorityFraction,
|
||||
beast::Journal journal,
|
||||
bool useMockFacade = false);
|
||||
|
||||
} // ripple
|
||||
} // ripple
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user