Skip to content

Commit

Permalink
feat: move the logic to determine if there is a federation present to…
Browse files Browse the repository at this point in the history
… the tracker, also merged setNew and replace into the same method using a parameter to clarify if it requires being saved or not
  • Loading branch information
julianlen committed Jan 3, 2025
1 parent 0fe0432 commit 3efcf62
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public void setNewFederation(Federation federation) {

@Override
public Federation getOldFederation(FederationConstants federationConstants, ActivationConfig.ForBlock activations) {
if (oldFederationTracker.isPresent() || oldFederationTracker.isModified()) {
if (oldFederationTracker.hasBeenSet()) {
return oldFederationTracker.get();
}

Expand All @@ -159,18 +159,18 @@ public Federation getOldFederation(FederationConstants federationConstants, Acti
}
);

oldFederationTracker.replace(oldFederation);
oldFederationTracker.set(oldFederation, false);
return oldFederationTracker.get();
}

@Override
public void setOldFederation(Federation federation) {
oldFederationTracker.setNew(federation);
oldFederationTracker.set(federation, true);
}

@Override
public PendingFederation getPendingFederation() {
if (pendingFederationTracker.isPresent() || pendingFederationTracker.isModified()) {
if (pendingFederationTracker.hasBeenSet()) {
return pendingFederationTracker.get();
}

Expand All @@ -190,13 +190,13 @@ public PendingFederation getPendingFederation() {
}
);

pendingFederationTracker.replace(pendingFederation);
pendingFederationTracker.set(pendingFederation, false);
return pendingFederationTracker.get();
}

@Override
public void setPendingFederation(PendingFederation federation) {
pendingFederationTracker.setNew(federation);
pendingFederationTracker.set(federation, true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ public boolean isPresent() {
return this.federation != null;
}

public void setNew(T aFederation) {
this.federation = aFederation;
this.modified = true;
public boolean hasBeenSet() {
return this.isPresent() || this.isModified();
}

public void replace(T aFederation) {
public void set(T aFederation, boolean shouldSave) {
this.federation = aFederation;
this.modified = shouldSave;
}
}

0 comments on commit 3efcf62

Please sign in to comment.