Skip to content

Commit

Permalink
core, light: reject empty header batch for importing
Browse files Browse the repository at this point in the history
  • Loading branch information
rjl493456442 committed Mar 22, 2022
1 parent 23e24da commit 320e881
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/blockchain.go
Expand Up @@ -2296,6 +2296,9 @@ Error: %v
// of the header retrieval mechanisms already need to verify nonces, as well as
// because nonces can be verified sparsely, not needing to check each.
func (bc *BlockChain) InsertHeaderChain(chain []*types.Header, checkFreq int) (int, error) {
if len(chain) == 0 {
return 0, nil
}
start := time.Now()
if i, err := bc.hc.ValidateHeaderChain(chain, checkFreq); err != nil {
return i, err
Expand Down
3 changes: 3 additions & 0 deletions light/lightchain.go
Expand Up @@ -419,6 +419,9 @@ func (lc *LightChain) SetChainHead(header *types.Header) error {
// In the case of a light chain, InsertHeaderChain also creates and posts light
// chain events when necessary.
func (lc *LightChain) InsertHeaderChain(chain []*types.Header, checkFreq int) (int, error) {
if len(chain) == 0 {
return 0, nil
}
if atomic.LoadInt32(&lc.disableCheckFreq) == 1 {
checkFreq = 0
}
Expand Down

0 comments on commit 320e881

Please sign in to comment.