-
Notifications
You must be signed in to change notification settings - Fork 267
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
Replacing shouldSave federation by a tracker class #2911
base: master
Are you sure you want to change the base?
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.OpenSSF Scorecard
Scanned Manifest Files |
An alternative is to create a new Tracker each time FederationStorageProvider fetches a new (old or pending) federation. If the federation should be saved, FederationStorageProvider may call a special constructor that sets the flag "modified" (previously shouldBeSaved). |
rskj-core/src/main/java/co/rsk/peg/federation/FederationTracker.java
Outdated
Show resolved
Hide resolved
rskj-core/src/main/java/co/rsk/peg/federation/FederationTracker.java
Outdated
Show resolved
Hide resolved
rskj-core/src/main/java/co/rsk/peg/federation/FederationTracker.java
Outdated
Show resolved
Hide resolved
rskj-core/src/main/java/co/rsk/peg/federation/FederationStorageProviderImpl.java
Outdated
Show resolved
Hide resolved
rskj-core/src/main/java/co/rsk/peg/federation/FederationTracker.java
Outdated
Show resolved
Hide resolved
rskj-core/src/main/java/co/rsk/peg/federation/FederationTracker.java
Outdated
Show resolved
Hide resolved
rskj-core/src/main/java/co/rsk/peg/federation/FederationStorageProviderImpl.java
Outdated
Show resolved
Hide resolved
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.
LGTM.
0bfc14b
to
75847c5
Compare
@@ -146,13 +139,13 @@ public void setNewFederation(Federation federation) { | |||
|
|||
@Override | |||
public Federation getOldFederation(FederationConstants federationConstants, ActivationConfig.ForBlock activations) { | |||
if (oldFederation != null || shouldSaveOldFederation) { | |||
return oldFederation; | |||
if (oldFederationTracker.isPresent() || oldFederationTracker.isModified()) { |
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.
Isn't the second condition here useless? What would be the case where oldFederationTracker
is empty but isModified
? It would return null, is it what we expect?
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.
It is, not clear the background but it is the expected behavior. If the method 'setFederation' is called passing null as a federation, it should keep the flag "isModified" as it was
rskj-core/src/main/java/co/rsk/peg/federation/FederationStorageProviderImpl.java
Outdated
Show resolved
Hide resolved
rskj-core/src/main/java/co/rsk/peg/federation/FederationTrackerImpl.java
Outdated
Show resolved
Hide resolved
rskj-core/src/main/java/co/rsk/peg/federation/FederationTracker.java
Outdated
Show resolved
Hide resolved
… the tracker, also merged setNew and replace into the same method using a parameter to clarify if it requires being saved or not
rskj-core/src/main/java/co/rsk/peg/federation/FederationTracker.java
Outdated
Show resolved
Hide resolved
57822e0
to
af2e9c9
Compare
Quality Gate passedIssues Measures |
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.
LGTM.
Created a new class FederationTracker that tracks whether the federation must be saved (if it was modified)