github.com/sberex/go-sberex@v1.8.2-0.20181113200658-ed96ac38f7d7/consensus/misc/forks.go (about)

     1  // This file is part of the go-sberex library. The go-sberex library is 
     2  // free software: you can redistribute it and/or modify it under the terms 
     3  // of the GNU Lesser General Public License as published by the Free 
     4  // Software Foundation, either version 3 of the License, or (at your option)
     5  // any later version.
     6  //
     7  // The go-sberex library is distributed in the hope that it will be useful, 
     8  // but WITHOUT ANY WARRANTY; without even the implied warranty of
     9  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 
    10  // General Public License <http://www.gnu.org/licenses/> for more details.
    11  
    12  package misc
    13  
    14  import (
    15  	"fmt"
    16  
    17  	"github.com/Sberex/go-sberex/common"
    18  	"github.com/Sberex/go-sberex/core/types"
    19  	"github.com/Sberex/go-sberex/params"
    20  )
    21  
    22  // VerifyForkHashes verifies that blocks conforming to network hard-forks do have
    23  // the correct hashes, to avoid clients going off on different chains. This is an
    24  // optional feature.
    25  func VerifyForkHashes(config *params.ChainConfig, header *types.Header, uncle bool) error {
    26  	// We don't care about uncles
    27  	if uncle {
    28  		return nil
    29  	}
    30  	// If the homestead reprice hash is set, validate it
    31  	if config.EIP150Block != nil && config.EIP150Block.Cmp(header.Number) == 0 {
    32  		if config.EIP150Hash != (common.Hash{}) && config.EIP150Hash != header.Hash() {
    33  			return fmt.Errorf("homestead gas reprice fork: have 0x%x, want 0x%x", header.Hash(), config.EIP150Hash)
    34  		}
    35  	}
    36  	// All ok, return
    37  	return nil
    38  }