Skip to content

Commit

Permalink
Clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
spoto committed May 28, 2024
1 parent b7c7c5f commit f8d1715
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import io.hotmoka.xodus.ByteIterable;
import io.hotmoka.xodus.ExodusException;
import io.hotmoka.xodus.env.Environment;
import io.hotmoka.xodus.env.Transaction;

/**
* Partial implementation of a local (ie., non-remote) node.
Expand Down Expand Up @@ -68,6 +69,13 @@ public abstract class AbstractCheckableLocalNodeImpl<C extends LocalNodeConfig<C
*/
private final static ByteIterable ROOT = ByteIterable.fromBytes("root".getBytes());

/**
* The key used inside {@link #storeOfNode} to keep the list of old stores
* that are candidate for garbage-collection, as soon as their height is sufficiently
* smaller than the height of the store of this node.
*/
private final static ByteIterable PAST_STORES = ByteIterable.fromBytes("past stores".getBytes());

private final static Logger LOGGER = Logger.getLogger(AbstractCheckableLocalNodeImpl.class.getName());

/**
Expand Down Expand Up @@ -122,7 +130,7 @@ protected void moveToFinalStoreOf(T transaction) throws NodeException {

try {
var rootAsBI = ByteIterable.fromBytes(getStore().getStateId());
env.executeInTransaction(txn -> storeOfNode.put(txn, ROOT, rootAsBI));
env.executeInTransaction(txn -> setRootBranch(oldStore, rootAsBI, txn));

if (!storesToGC.offer(oldStore))
LOGGER.warning("could not enqueue old store for garbage collection: the queue is full!");
Expand All @@ -147,6 +155,11 @@ protected void closeResources() throws NodeException, InterruptedException {
}
}

private void setRootBranch(S oldStore, ByteIterable rootAsBI, Transaction txn) {
storeOfNode.put(txn, ROOT, rootAsBI); // we set the root branch
//storeOfNode.put(txn, PAST_STORES, null); // we add the old store to the past stores list
}

/**
* The garbage-collection routine. It takes stores to garbage-collect and frees them.
*/
Expand Down

0 comments on commit f8d1715

Please sign in to comment.