-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add high_watermark data to metadata db table
- high_watermark_epoch and high_watermark_slot - CRUD operations in MetadataDao - find - update (assumes GVR metadata is already inserted) - delete
- Loading branch information
Showing
5 changed files
with
184 additions
and
1 deletion.
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
60 changes: 60 additions & 0 deletions
60
...rotection/src/main/java/tech/pegasys/web3signer/slashingprotection/dao/HighWatermark.java
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright 2023 ConsenSys AG. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
package tech.pegasys.web3signer.slashingprotection.dao; | ||
|
||
import java.util.Objects; | ||
|
||
import org.apache.tuweni.units.bigints.UInt64; | ||
|
||
public class HighWatermark { | ||
|
||
private UInt64 slot; | ||
private UInt64 epoch; | ||
|
||
// needed for JDBI | ||
public HighWatermark() {} | ||
|
||
public HighWatermark(final UInt64 slot, final UInt64 epoch) { | ||
this.slot = slot; | ||
this.epoch = epoch; | ||
} | ||
|
||
public UInt64 getSlot() { | ||
return slot; | ||
} | ||
|
||
public UInt64 getEpoch() { | ||
return epoch; | ||
} | ||
|
||
public void setSlot(final UInt64 slot) { | ||
this.slot = slot; | ||
} | ||
|
||
public void setEpoch(final UInt64 epoch) { | ||
this.epoch = epoch; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
HighWatermark that = (HighWatermark) o; | ||
return Objects.equals(slot, that.slot) && Objects.equals(epoch, that.epoch); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(slot, epoch); | ||
} | ||
} |
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
5 changes: 5 additions & 0 deletions
5
...rotection/src/main/resources/migrations/postgresql/V00012__add_highwatermark_metadata.sql
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
ALTER TABLE metadata | ||
ADD COLUMN high_watermark_epoch NUMERIC(20), | ||
ADD COLUMN high_watermark_slot NUMERIC(20); | ||
|
||
UPDATE database_version SET version = 12 WHERE id = 1; |
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