Skip to content

Commit

Permalink
Removed useless file generation
Browse files Browse the repository at this point in the history
  • Loading branch information
spoto committed May 20, 2024
1 parent 0f741d6 commit e37cc17
Showing 1 changed file with 8 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

import io.hotmoka.annotations.Immutable;
import io.hotmoka.crypto.api.Hasher;
import io.hotmoka.node.NodeMarshallingContexts;
import io.hotmoka.node.api.UnknownReferenceException;
import io.hotmoka.node.api.nodes.ConsensusConfig;
import io.hotmoka.node.api.requests.TransactionRequest;
Expand Down Expand Up @@ -136,11 +135,11 @@ private DiskStore(DiskStore toClone, StoreCache cache,

int progressive = 0;
for (var entry: addedRequests.entrySet())
setRequest(progressive++, entry.getKey(), entry.getValue());
dumpRequest(progressive++, entry.getKey(), entry.getValue());

progressive = 0;
for (var entry: addedResponses.entrySet())
setResponse(progressive++, entry.getKey(), entry.getValue());
dumpResponse(progressive++, entry.getKey(), entry.getValue());

for (var entry: addedHistories.entrySet())
histories.put(entry.getKey(), entry.getValue());
Expand Down Expand Up @@ -196,39 +195,27 @@ protected DiskStore setCache(StoreCache cache) {
return new DiskStore(this, cache);
}

private void setRequest(int progressive, TransactionReference reference, TransactionRequest<?> request) throws StoreException {
private void dumpRequest(int progressive, TransactionReference reference, TransactionRequest<?> request) throws StoreException {
requests.put(reference, request);

try {
Path requestPath = getPathFor(progressive, reference, "request");
Path requestPath = getPathFor(progressive, reference, "request.txt");
Path parent = requestPath.getParent();
ensureDeleted(parent);
Files.createDirectories(parent);

Files.writeString(parent.resolve("request.txt"), request.toString(), StandardCharsets.UTF_8);

try (var context = NodeMarshallingContexts.of(Files.newOutputStream(requestPath))) {
request.into(context);
}
Files.writeString(requestPath, request.toString(), StandardCharsets.UTF_8);
}
catch (IOException e) {
throw new StoreException(e);
}
}

private void setResponse(int progressive, TransactionReference reference, TransactionResponse response) throws StoreException {
private void dumpResponse(int progressive, TransactionReference reference, TransactionResponse response) throws StoreException {
responses.put(reference, response);

try {
Path responsePath = getPathFor(progressive, reference, "response");
Path parent = responsePath.getParent();
Files.createDirectories(parent);

Files.writeString(parent.resolve("response.txt"), response.toString(), StandardCharsets.UTF_8);

try (var context = NodeMarshallingContexts.of(Files.newOutputStream(responsePath))) {
response.into(context);
}
Path responsePath = getPathFor(progressive, reference, "response.txt");
Files.writeString(responsePath, response.toString(), StandardCharsets.UTF_8);
}
catch (IOException e) {
throw new StoreException(e);
Expand Down

0 comments on commit e37cc17

Please sign in to comment.