From 93ae61d6b582473791646c50429f227cd110c74d Mon Sep 17 00:00:00 2001 From: Lutty Date: Thu, 20 Jan 2022 21:23:33 +0800 Subject: [PATCH] opti --- core/blockchain_pruner.go | 4 ++++ ...blockchain_pruner_meric.go => blockchain_pruner_metric.go} | 0 node/node.go | 2 ++ 3 files changed, 6 insertions(+) rename core/{blockchain_pruner_meric.go => blockchain_pruner_metric.go} (100%) diff --git a/core/blockchain_pruner.go b/core/blockchain_pruner.go index 98a3fd6cd..0dbe6fb69 100644 --- a/core/blockchain_pruner.go +++ b/core/blockchain_pruner.go @@ -148,6 +148,10 @@ func (bp *blockchainPruner) pruneBeaconChainBlock(maxBlockNum uint64) (minKey [] } blockInfo := rawdb.ReadBlock(bp.db, hash, blockNum) + if blockInfo == nil { + return true + } + err := bp.deleteBlockInfo(blockInfo) if err != nil { utils.Logger().Error(). diff --git a/core/blockchain_pruner_meric.go b/core/blockchain_pruner_metric.go similarity index 100% rename from core/blockchain_pruner_meric.go rename to core/blockchain_pruner_metric.go diff --git a/node/node.go b/node/node.go index 2e026989c..d8cc5f39c 100644 --- a/node/node.go +++ b/node/node.go @@ -160,6 +160,8 @@ func (node *Node) Beaconchain() *core.BlockChain { isNotBeaconChainValidator := node.NodeConfig.Role() == nodeconfig.Validator && node.NodeConfig.ShardID != shard.BeaconChainShardID if isEnablePruneBeaconChain && isNotBeaconChainValidator { bc.EnablePruneBeaconChainFeature() + } else if isEnablePruneBeaconChain && !isNotBeaconChainValidator { + utils.Logger().Info().Msg("`IsEnablePruneBeaconChain` only available in validator node and shard 1-3") } return bc }