Skip to content

Commit

Permalink
feat(log): log state root
Browse files Browse the repository at this point in the history
  • Loading branch information
halibobo1205 committed Jul 17, 2024
1 parent 3458060 commit 0376107
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions chainbase/src/main/java/org/tron/core/service/RootHashService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -25,7 +31,9 @@ public static Pair<Optional<Long>, Sha256Hash> getRootHash(Map<byte[], byte[]> 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<byte[], byte[]> entry) {
Expand Down

0 comments on commit 0376107

Please sign in to comment.