Skip to content

Commit

Permalink
Variable name change for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyeh committed Apr 21, 2024
1 parent 3ae1f5e commit da2db0c
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,15 @@
public class GraffitiManager {
private static final Logger LOG = LogManager.getLogger();
static final String GRAFFITI_DIR = "graffiti";

private final Path graffitiPath;
private final Path directory;

public GraffitiManager(final DataDirLayout dataDirLayout) {
this(dataDirLayout.getValidatorDataDirectory().resolve(GRAFFITI_DIR));
}

public GraffitiManager(final Path graffitiPath) {
this.graffitiPath = graffitiPath;
if (!graffitiPath.toFile().exists() && !graffitiPath.toFile().mkdirs()) {
public GraffitiManager(final Path directory) {
this.directory = directory;
if (!directory.toFile().exists() && !directory.toFile().mkdirs()) {
throw new IllegalStateException("Unable to create directory for graffiti management.");
}
}
Expand All @@ -53,7 +52,7 @@ public Optional<String> setGraffiti(final BLSPublicKey publicKey, final String g
}

try {
final Path file = graffitiPath.resolve(resolveFileName(publicKey));
final Path file = directory.resolve(resolveFileName(publicKey));
Files.writeString(file, strippedGraffiti);
} catch (IOException e) {
final String errorMessage =
Expand All @@ -65,7 +64,7 @@ public Optional<String> setGraffiti(final BLSPublicKey publicKey, final String g
}

public Optional<String> deleteGraffiti(final BLSPublicKey publicKey) {
final Path file = graffitiPath.resolve(resolveFileName(publicKey));
final Path file = directory.resolve(resolveFileName(publicKey));

try {
Files.delete(file);
Expand All @@ -82,7 +81,7 @@ public Optional<String> deleteGraffiti(final BLSPublicKey publicKey) {
}

public Optional<Bytes32> getGraffiti(final BLSPublicKey publicKey) {
final Path filePath = graffitiPath.resolve(resolveFileName(publicKey));
final Path filePath = directory.resolve(resolveFileName(publicKey));
if (!filePath.toFile().exists()) {
return Optional.empty();
}
Expand Down

0 comments on commit da2db0c

Please sign in to comment.