Skip to content

Commit

Permalink
Don't try to render node hashes on failed reconnect
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Ananev <artem.ananev@swirldslabs.com>
  • Loading branch information
artemananiev committed Oct 31, 2023
1 parent 2183eb0 commit 4a1f84f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ private void abort() {
logger.warn(
RECONNECT.getMarker(),
"Deleting partially constructed tree:\n{}",
new MerkleTreeVisualizer(newRoot).setDepth(5).render());
new MerkleTreeVisualizer(newRoot).setDepth(5).setUseHashes(false).setUseMnemonics(false).render());
try {
if (newRoot != null) {
newRoot.release();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,18 +196,8 @@ public void render(final StringBuilder sb) {
indexString = Integer.toString(route.getStep(-1));
}

final Hash hash = node == null ? CryptographyHolder.get().getNullHash() : node.getHash();
final String className = node == null ? "null" : node.getClass().getSimpleName();

final String hashString;
if (hash == null) {
hashString = "null";
} else if (hashLength == -1) {
hashString = hash.toString();
} else {
hashString = hash.toString().substring(0, hashLength);
}

final String formattedIndexString = useColors ? BRIGHT_CYAN.apply(indexString) : indexString;
final String formattedClassName = useColors ? BRIGHT_YELLOW.apply(className) : className;

Expand All @@ -229,15 +219,27 @@ public void render(final StringBuilder sb) {
table.addToRow(formattedRouteString);
}

if (useMnemonics) {
final String mnemonic = hash == null ? "" : hash.toMnemonic();
final String formattedMnemonic = useColors ? WHITE.apply(mnemonic) : mnemonic;
table.addToRow(formattedMnemonic);
}
if (useHashes || useMnemonics) {
final Hash hash = node == null ? CryptographyHolder.get().getNullHash() : node.getHash();
final String hashString;
if (hash == null) {
hashString = "null";
} else if (hashLength == -1) {
hashString = hash.toString();
} else {
hashString = hash.toString().substring(0, hashLength);
}

if (useMnemonics) {
final String mnemonic = hash == null ? "" : hash.toMnemonic();
final String formattedMnemonic = useColors ? WHITE.apply(mnemonic) : mnemonic;
table.addToRow(formattedMnemonic);
}

if (useHashes) {
final String formattedHashString = useColors ? GRAY.apply(hashString) : hashString;
table.addToRow(formattedHashString);
if (useHashes) {
final String formattedHashString = useColors ? GRAY.apply(hashString) : hashString;
table.addToRow(formattedHashString);
}
}
});

Expand Down

0 comments on commit 4a1f84f

Please sign in to comment.