Skip to content

Commit

Permalink
Clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
spoto committed May 25, 2024
1 parent 8603bee commit 43caf3e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,6 @@ protected final void initStore(Optional<ConsensusConfig<?,?>> consensus) throws
throw new NodeException(e);
}
catch (StoreException e) {
e.printStackTrace();
throw new NodeException("Cannot fill the cache of the store: was the node already initialized?", e);
}
}
Expand Down Expand Up @@ -509,6 +508,8 @@ protected void moveToFinalStoreOf(T transaction) throws NodeException {
try {
S oldStore = store;
store = transaction.getFinalStore();
store.moveRootBranchToThis(oldStore);

if (!storesToGC.offer(oldStore))
LOGGER.warning("could not enqueue old store for garbage collection: the queue is full!");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,8 @@ public byte[] getStateId() throws StoreException {
int hash = hashCode();
return new byte[] { (byte) ((hash >> 24) % 0xff), (byte) ((hash >> 16) % 0xff), (byte) ((hash >> 8) % 0xff), (byte) (hash % 0xff) };
}

public void moveRootBranchToThis(S oldStore) throws StoreException {
// subclasses may redefine
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,7 @@ public void free() throws StoreException {
}
}

/**
* Yields the number of commits already performed over this store.
*
* @return the number of commits
*/
@Override
public long getHeight() throws StoreException {
try {
return CheckSupplier.check(TrieException.class, StoreException.class, () ->
Expand All @@ -368,8 +364,8 @@ public long getHeight() throws StoreException {
}
}

public void moveRootBranchToThis() throws StoreException {
var rootAsBI = ByteIterable.fromBytes(mergeRootsOfTries());
public void moveRootBranchToThis(S oldStore) throws StoreException {
var rootAsBI = ByteIterable.fromBytes(getStateId());

try {
env.executeInTransaction(txn -> storeOfInfo.put(txn, ROOT, rootAsBI));
Expand Down

0 comments on commit 43caf3e

Please sign in to comment.