Skip to content
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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

julianlen
Copy link
Contributor

Created a new class FederationTracker that tracks whether the federation must be saved (if it was modified)

@julianlen julianlen requested a review from a team as a code owner January 2, 2025 16:24
Copy link

github-actions bot commented Jan 2, 2025

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Manifest Files

@julianlen
Copy link
Contributor Author

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).

jeremy-then
jeremy-then previously approved these changes Jan 2, 2025
Copy link
Contributor

@jeremy-then jeremy-then left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@@ -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()) {
Copy link
Contributor

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?

Copy link
Contributor Author

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

… the tracker, also merged setNew and replace into the same method using a parameter to clarify if it requires being saved or not
@julianlen julianlen force-pushed the bridge-federation-tracker branch from 57822e0 to af2e9c9 Compare January 10, 2025 15:27
Copy link
Contributor

@jeremy-then jeremy-then left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants