func extractHeader(block []byte, checkHeight uint64, skipDigest bool, pool storage.Handle) (*Header, blockdigest.Digest, []byte, error) {
	if len(block) < totalBlockSize {
		return nil, blockdigest.Digest{}, nil, fault.InvalidBlockHeaderSize
	}
	packedHeader := PackedHeader{}
	copy(packedHeader[:], block[:totalBlockSize])
	header, err := packedHeader.Unpack()
	if nil != err {
		return nil, blockdigest.Digest{}, nil, err
	}
	if checkHeight > genesis.BlockNumber {
		err := validNextHeightFromExpected(checkHeight, header.Number)
		if nil != err {
			log.Errorf("check height %d, incoming block height %d, error: %s", checkHeight, header.Number, err)
			return nil, blockdigest.Digest{}, nil, err
		}
	}
	if skipDigest {
		return header, blockdigest.Digest{}, block[totalBlockSize:], nil
	}
	thisBlockNumberKey := make([]byte, 8)
	binary.BigEndian.PutUint64(thisBlockNumberKey, header.Number)
	digest := DigestFromHashPool(pool, thisBlockNumberKey)
	if !digest.IsEmpty() {
		return header, digest, block[totalBlockSize:], nil
	}
	digest = blockdigest.NewDigest(packedHeader[:])
	return header, digest, block[totalBlockSize:], nil
}
extractHeader - extract a header from the front of a []byte
if checkHeight non-zero then verify correct block number first
to reduce hashing load for obviously incorrect blocks
package blockrecord
import (
	"encoding/binary"
	"time"
	"github.com/bitmark-inc/bitmarkd/blockdigest"
	"github.com/bitmark-inc/bitmarkd/difficulty"
	"github.com/bitmark-inc/bitmarkd/fault"
	"github.com/bitmark-inc/bitmarkd/genesis"
	"github.com/bitmark-inc/bitmarkd/merkle"
	"github.com/bitmark-inc/bitmarkd/storage"
	"github.com/bitmark-inc/logger"
)
type PackedHeader [totalBlockSize]byte
type PackedBlock []byte
const (
	Version                    = 5
	MinimumVersion             = 1
	MinimumBlockNumber         = 2  
	MinimumDifficultyBaseBlock = 3
)
const (
	MinimumTransactions = 2
	MaximumTransactions = 10000
)
const (
	VersionSize          = 2                    
	TransactionCountSize = 2                    
	NumberSize           = 8                    
	PreviousBlockSize    = blockdigest.Length   
	MerkleRootSize       = merkle.DigestLength  
	TimestampSize        = 8                    
	DifficultySize       = 8                    
	NonceSize            = 8                    
)
const (
	versionOffset          = 0
	transactionCountOffset = versionOffset + VersionSize
	numberOffset           = transactionCountOffset + TransactionCountSize
	previousBlockOffset    = numberOffset + NumberSize
	merkleRootOffset       = previousBlockOffset + PreviousBlockSize
	timestampOffset        = merkleRootOffset + MerkleRootSize
	difficultyOffset       = timestampOffset + TimestampSize
	nonceOffset            = difficultyOffset + DifficultySize
	totalBlockSize = nonceOffset + NonceSize  
)
type Header struct {
	Version          uint16                 `json:"version"`
	TransactionCount uint16                 `json:"transactionCount"`
	Number           uint64                 `json:"number,string"`
	PreviousBlock    blockdigest.Digest     `json:"previousBlock"`
	MerkleRoot       merkle.Digest          `json:"merkleRoot"`
	Timestamp        uint64                 `json:"timestamp,string"`
	Difficulty       *difficulty.Difficulty `json:"difficulty"`
	Nonce            NonceType              `json:"nonce"`
}
type Record interface {
	ExtractHeader([]byte, uint64, bool) (*Header, blockdigest.Digest, []byte, error)
}
type record struct {
	poolBockHeaderHash storage.Handle
}
func (r record) ExtractHeader(block []byte, checkHeight uint64, skipDigest bool) (*Header, blockdigest.Digest, []byte, error) {
	return extractHeader(block, checkHeight, skipDigest, r.poolBockHeaderHash)
}
var recordData record
var log *logger.L
func Initialise(handle storage.Handle) {
	recordData.poolBockHeaderHash = handle
	log = logger.New("blockrecord")
	log.Info("starting")
}
func Finalise() {
	log.Info("shutting down")
	log.Flush()
}
func Get() Record {
	return &recordData
}