From 037610765e34b5c9a8e25c0a32c089bf5be98be9 Mon Sep 17 00:00:00 2001 From: halibobo1205 Date: Wed, 17 Jul 2024 17:35:59 +0800 Subject: [PATCH] feat(log): log state root --- .../org/tron/core/service/RootHashService.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/chainbase/src/main/java/org/tron/core/service/RootHashService.java b/chainbase/src/main/java/org/tron/core/service/RootHashService.java index 8cf2037e86c..e17c1151ae1 100644 --- a/chainbase/src/main/java/org/tron/core/service/RootHashService.java +++ b/chainbase/src/main/java/org/tron/core/service/RootHashService.java @@ -3,14 +3,20 @@ import com.google.common.collect.Streams; import com.google.common.primitives.Bytes; import com.google.common.primitives.Ints; - -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Optional; import java.util.concurrent.atomic.AtomicReference; +import lombok.extern.slf4j.Slf4j; import org.tron.common.utils.ByteArray; import org.tron.common.utils.MerkleRoot; import org.tron.common.utils.Pair; import org.tron.common.utils.Sha256Hash; +@Slf4j(topic = "DB") public class RootHashService { private static final byte[] HEADER_KEY = Bytes.concat(simpleEncode("properties"), @@ -25,7 +31,9 @@ public static Pair, Sha256Hash> getRootHash(Map r } ids.add(getHash(entry)); }); - return new Pair<>(height.get(), MerkleRoot.root(ids)); + Sha256Hash root = MerkleRoot.root(ids); + logger.info("blockNum: {}, stateRoot: {}", height.get(), root); + return new Pair<>(height.get(), root); } private static Sha256Hash getHash(Map.Entry entry) {