blockchain: export CheckBlockHeaderSanity as a library function

This commit is contained in:
eugene 2022-11-28 12:57:33 -05:00
parent 00d0edd5c4
commit ee6c0e1962
No known key found for this signature in database
GPG Key ID: 118759E83439A9B1

View File

@ -421,13 +421,15 @@ func CountP2SHSigOps(tx *btcutil.Tx, isCoinBaseTx bool, utxoView *UtxoViewpoint)
return totalSigOps, nil
}
// checkBlockHeaderSanity performs some preliminary checks on a block header to
// CheckBlockHeaderSanity performs some preliminary checks on a block header to
// ensure it is sane before continuing with processing. These checks are
// context free.
//
// The flags do not modify the behavior of this function directly, however they
// are needed to pass along to checkProofOfWork.
func checkBlockHeaderSanity(header *wire.BlockHeader, powLimit *big.Int, timeSource MedianTimeSource, flags BehaviorFlags) error {
func CheckBlockHeaderSanity(header *wire.BlockHeader, powLimit *big.Int,
timeSource MedianTimeSource, flags BehaviorFlags) error {
// Ensure the proof of work bits in the block header is in min/max range
// and the block hash is less than the target value described by the
// bits.
@ -467,7 +469,7 @@ func checkBlockHeaderSanity(header *wire.BlockHeader, powLimit *big.Int, timeSou
func checkBlockSanity(block *btcutil.Block, powLimit *big.Int, timeSource MedianTimeSource, flags BehaviorFlags) error {
msgBlock := block.MsgBlock()
header := &msgBlock.Header
err := checkBlockHeaderSanity(header, powLimit, timeSource, flags)
err := CheckBlockHeaderSanity(header, powLimit, timeSource, flags)
if err != nil {
return err
}