From cb24ac0e54b91110a3ffeef559892cc96bd7e02f Mon Sep 17 00:00:00 2001 From: JukLee0ira Date: Fri, 17 Jan 2025 14:14:12 +0800 Subject: [PATCH] fix ReadChainConfig --- core/rawdb/accessors_metadata.go | 2 +- core/rawdb/schema.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/core/rawdb/accessors_metadata.go b/core/rawdb/accessors_metadata.go index c9ae50aeb85f1..3302f0d81fae1 100644 --- a/core/rawdb/accessors_metadata.go +++ b/core/rawdb/accessors_metadata.go @@ -43,7 +43,7 @@ func WriteDatabaseVersion(db ethdb.KeyValueWriter, vsn int) { // ReadChainConfig will fetch the network settings based on the given hash. func ReadChainConfig(db DatabaseReader, hash common.Hash) (*params.ChainConfig, error) { - jsonChainConfig, _ := db.Get(append(configPrefix, hash[:]...)) + jsonChainConfig, _ := db.Get(configKey(hash)) if len(jsonChainConfig) == 0 { return nil, errors.New("ChainConfig not found") // general config not found error } diff --git a/core/rawdb/schema.go b/core/rawdb/schema.go index 3fa28409bd310..2137956d10860 100644 --- a/core/rawdb/schema.go +++ b/core/rawdb/schema.go @@ -122,3 +122,8 @@ func txLookupKey(hash common.Hash) []byte { func preimageKey(hash common.Hash) []byte { return append(preimagePrefix, hash.Bytes()...) } + +// configKey = configPrefix + hash +func configKey(hash common.Hash) []byte { + return append(configPrefix, hash.Bytes()...) +}