-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Amendment table clean up (Improve amendment processing and activation logic) #3428
Closed
Closed
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
29b74b2
Use base 10 for majority vote calculation
gregtatcam 7d90194
Remove seconds option from amendment majority time configuration
gregtatcam 492272c
Fix clang
gregtatcam 7482d74
Fix min majority time config
gregtatcam 5e989ec
Move majority threshold calc into AmendmentSet
gregtatcam 63370d1
Include <chrono> in Config.h
gregtatcam e0f516f
Fix amendment threshold calculation
gregtatcam 9f6aefc
Fix Amendment calculation with one trusted validator
gregtatcam f3c752c
Fix amendment majority time Config unit test
gregtatcam 2c429dd
Refactor:
gregtatcam 69ea2d4
Clang fix
gregtatcam d7cb90c
Clang fix
gregtatcam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -485,24 +485,29 @@ Config::loadFromString(std::string const& fileContents) | |
{ | ||
using namespace std::chrono; | ||
boost::regex const re( | ||
"^\\s*(\\d+)\\s*(seconds|minutes|hours|days|weeks)\\s*(\\s+.*)?$"); | ||
"^\\s*(\\d+)\\s*(minutes|hours|days|weeks)\\s*(\\s+.*)?$"); | ||
boost::smatch match; | ||
if (!boost::regex_match(strTemp, match, re)) | ||
Throw<std::runtime_error>( | ||
"Invalid " SECTION_AMENDMENT_MAJORITY_TIME | ||
", must be: [0-9]+ [seconds|minutes|hours|days|weeks]"); | ||
", must be: [0-9]+ [minutes|hours|days|weeks]"); | ||
|
||
std::uint32_t duration = | ||
beast::lexicalCastThrow<std::uint32_t>(match[1].str()); | ||
if (boost::iequals(match[2], "seconds")) | ||
AMENDMENT_MAJORITY_TIME = seconds(duration); | ||
else if (boost::iequals(match[2], "minutes")) | ||
|
||
if (boost::iequals(match[2], "minutes")) | ||
AMENDMENT_MAJORITY_TIME = minutes(duration); | ||
else if (boost::iequals(match[2], "hours")) | ||
AMENDMENT_MAJORITY_TIME = hours(duration); | ||
else if (boost::iequals(match[2], "days")) | ||
AMENDMENT_MAJORITY_TIME = days(duration); | ||
else if (boost::iequals(match[2], "weeks")) | ||
AMENDMENT_MAJORITY_TIME = weeks(duration); | ||
|
||
if (AMENDMENT_MAJORITY_TIME < defaultAmendmentMajorityTime) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this check is wrong. It will prevent anything less than 2 weeks. I'd simply hard-code There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right!!! |
||
Throw<std::runtime_error>( | ||
"Invalid " SECTION_AMENDMENT_MAJORITY_TIME | ||
", the minimum amount of time an amendment must hold a majority is 15 minutes"); | ||
} | ||
|
||
// Do not load trusted validator configuration for standalone mode | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not allow
seconds
: there's no real plausible scenario for such a short interval. In fact, I think I'd reject any interval smaller than 15 minutes.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done