From 57822e08b22b091923b2b17491a173f4f4c7a072 Mon Sep 17 00:00:00 2001 From: Julian Len Date: Thu, 9 Jan 2025 18:24:51 -0300 Subject: [PATCH] feat: changed the tracker for a more generic class --- .../FederationStorageProviderImpl.java | 8 ++++---- .../co/rsk/peg/federation/FederationTracker.java | 16 ++++++++++------ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/rskj-core/src/main/java/co/rsk/peg/federation/FederationStorageProviderImpl.java b/rskj-core/src/main/java/co/rsk/peg/federation/FederationStorageProviderImpl.java index 86dad0d5bc..f131b78a57 100644 --- a/rskj-core/src/main/java/co/rsk/peg/federation/FederationStorageProviderImpl.java +++ b/rskj-core/src/main/java/co/rsk/peg/federation/FederationStorageProviderImpl.java @@ -159,13 +159,13 @@ public Federation getOldFederation(FederationConstants federationConstants, Acti } ); - oldFederationTracker.set(oldFederation, false); + oldFederationTracker.set(oldFederation); return oldFederationTracker.get(); } @Override public void setOldFederation(Federation federation) { - oldFederationTracker.set(federation, true); + oldFederationTracker.setNew(federation); } @Override @@ -190,13 +190,13 @@ public PendingFederation getPendingFederation() { } ); - pendingFederationTracker.set(pendingFederation, false); + pendingFederationTracker.set(pendingFederation); return pendingFederationTracker.get(); } @Override public void setPendingFederation(PendingFederation federation) { - pendingFederationTracker.set(federation, true); + pendingFederationTracker.setNew(federation); } @Override diff --git a/rskj-core/src/main/java/co/rsk/peg/federation/FederationTracker.java b/rskj-core/src/main/java/co/rsk/peg/federation/FederationTracker.java index d1ab1daa9e..cb1b945b86 100644 --- a/rskj-core/src/main/java/co/rsk/peg/federation/FederationTracker.java +++ b/rskj-core/src/main/java/co/rsk/peg/federation/FederationTracker.java @@ -1,7 +1,7 @@ package co.rsk.peg.federation; public class FederationTracker { - private T federation; + private T value; private boolean modified = false; public boolean isModified() { @@ -9,19 +9,23 @@ public boolean isModified() { } public T get() { - return this.federation; + return this.value; } public boolean isPresent() { - return this.federation != null; + return this.value != null; } public boolean hasBeenSet() { return this.isPresent() || this.isModified(); } - public void set(T aFederation, boolean shouldSave) { - this.federation = aFederation; - this.modified = shouldSave; + public void setNew(T aValue) { + this.value = aValue; + this.modified = true; + } + + public void set(T aValue) { + this.value = aValue; } }