Skip to content

Commit

Permalink
spotless
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
  • Loading branch information
gfukushima committed Dec 15, 2023
1 parent 1e07f92 commit 9f149a5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static void printUsageForColumnFamily(
!totalSstFilesSize.isEmpty() && !totalSstFilesSize.isBlank()
? Long.parseLong(totalSstFilesSize)
: 0;
if (sizeLong == 0 && numberOfKeysLong == 0){
if (sizeLong == 0 && numberOfKeysLong == 0) {
emptyColumnFamily = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import static com.google.common.base.Preconditions.checkArgument;
import static org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration.Unstable.MINIMUM_BONSAI_TRIE_LOG_RETENTION_THRESHOLD;

import org.hyperledger.besu.controller.BesuController;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.chain.Blockchain;
Expand Down Expand Up @@ -57,7 +56,8 @@ static void prune(
final PrintWriter out,
final DataStorageConfiguration config,
final BonsaiWorldStateKeyValueStorage rootWorldStateStorage,
final MutableBlockchain blockchain) throws IOException {
final MutableBlockchain blockchain)
throws IOException {

TrieLogHelper.validatePruneConfiguration(config);
final long layersToRetain = config.getUnstable().getBonsaiTrieLogRetentionThreshold();
Expand Down Expand Up @@ -180,34 +180,34 @@ private static void saveTrieLogsInFile(final Map<byte[], byte[]> trieLogs) throw

File file = new File(trieLogFile);

try (BufferedWriter bf = new BufferedWriter(new FileWriter(file, StandardCharsets.UTF_8))) {
for (Map.Entry<byte[], byte[]> entry : trieLogs.entrySet()) {
bf.write(Bytes.of(entry.getKey()) + ":" + Base64.toBase64String(entry.getValue()));
bf.newLine();
}
bf.flush();
} catch (IOException e) {
LOG.error(e.getMessage());
throw e;
try (BufferedWriter bf = new BufferedWriter(new FileWriter(file, StandardCharsets.UTF_8))) {
for (Map.Entry<byte[], byte[]> entry : trieLogs.entrySet()) {
bf.write(Bytes.of(entry.getKey()) + ":" + Base64.toBase64String(entry.getValue()));
bf.newLine();
}
bf.flush();
} catch (IOException e) {
LOG.error(e.getMessage());
throw e;
}
}

private static IdentityHashMap<byte[], byte[]> readTrieLogsFromFile() throws IOException {

File file = new File(trieLogFile);
IdentityHashMap<byte[], byte[]> trieLogs = new IdentityHashMap<>();
try (BufferedReader br = new BufferedReader(new FileReader(file, StandardCharsets.UTF_8))) {
String line;
while ((line = br.readLine()) != null) {
List<String> parts = Splitter.on(':').splitToList(line);
byte[] key = Bytes.fromHexString(parts.get(0)).toArrayUnsafe();
byte[] value = Base64.decode(parts.get(1));
trieLogs.put(key, value);
}
} catch (IOException e) {
LOG.error(e.getMessage());
throw e;
try (BufferedReader br = new BufferedReader(new FileReader(file, StandardCharsets.UTF_8))) {
String line;
while ((line = br.readLine()) != null) {
List<String> parts = Splitter.on(':').splitToList(line);
byte[] key = Bytes.fromHexString(parts.get(0)).toArrayUnsafe();
byte[] value = Base64.decode(parts.get(1));
trieLogs.put(key, value);
}
} catch (IOException e) {
LOG.error(e.getMessage());
throw e;
}

return trieLogs;
}
Expand Down

0 comments on commit 9f149a5

Please sign in to comment.