diff --git a/chainbase/src/main/java/org/tron/core/store/CheckPointV2Store.java b/chainbase/src/main/java/org/tron/core/store/CheckPointV2Store.java index 6876bfac751..ae1199bc5a3 100644 --- a/chainbase/src/main/java/org/tron/core/store/CheckPointV2Store.java +++ b/chainbase/src/main/java/org/tron/core/store/CheckPointV2Store.java @@ -12,7 +12,6 @@ import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; import org.tron.common.storage.WriteOptionsWrapper; -import org.tron.common.utils.ByteArray; import org.tron.common.utils.Pair; import org.tron.common.utils.Sha256Hash; import org.tron.core.db.TronDatabase; @@ -90,8 +89,7 @@ public void close() { public void updateByBatch(Map rows, WriteOptionsWrapper writeOptions) { Pair, Sha256Hash> ret = RootHashService.getRootHash(rows); super.updateByBatch(rows, writeOptions); - ret.getKey().ifPresent(height -> stateRootStore.put(ByteArray.fromLong(height), - ret.getValue().getBytes())); + ret.getKey().ifPresent(height -> stateRootStore.put(height, ret.getValue())); } } diff --git a/chainbase/src/main/java/org/tron/core/store/CheckTmpStore.java b/chainbase/src/main/java/org/tron/core/store/CheckTmpStore.java index 6abc40ddbc6..bceab7c4630 100644 --- a/chainbase/src/main/java/org/tron/core/store/CheckTmpStore.java +++ b/chainbase/src/main/java/org/tron/core/store/CheckTmpStore.java @@ -9,7 +9,6 @@ import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Component; import org.tron.common.storage.WriteOptionsWrapper; -import org.tron.common.utils.ByteArray; import org.tron.common.utils.Pair; import org.tron.common.utils.Sha256Hash; import org.tron.core.db.TronDatabase; @@ -61,7 +60,6 @@ public Spliterator spliterator() { public void updateByBatch(Map rows, WriteOptionsWrapper writeOptions) { Pair, Sha256Hash> ret = RootHashService.getRootHash(rows); super.updateByBatch(rows, writeOptions); - ret.getKey().ifPresent(height -> stateRootStore.put(ByteArray.fromLong(height), - ret.getValue().getBytes())); + ret.getKey().ifPresent(height -> stateRootStore.put(height, ret.getValue())); } } diff --git a/chainbase/src/main/java/org/tron/core/store/StateRootStore.java b/chainbase/src/main/java/org/tron/core/store/StateRootStore.java index 93441c133df..1096ff29f6c 100755 --- a/chainbase/src/main/java/org/tron/core/store/StateRootStore.java +++ b/chainbase/src/main/java/org/tron/core/store/StateRootStore.java @@ -5,6 +5,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import org.tron.common.utils.ByteArray; +import org.tron.common.utils.Sha256Hash; import org.tron.core.db.TronDatabase; import org.tron.core.db.common.iterator.DBIterator; @@ -31,6 +32,11 @@ public void put(byte[] key, byte[] item) { dbSource.putData(key, item); } + public void put(long key, Sha256Hash root) { + logger.info("block: {},root: {}", key, root); + this.put(ByteArray.fromLong(key), root.getBytes()); + } + @Override public void delete(byte[] key) { throw new UnsupportedOperationException();