func Height() uint64 {
	globalData.RLock()
	defer globalData.RUnlock()
	return globalData.height
}
Height - return current height
package blockheader
import (
	"sync"
	"github.com/bitmark-inc/bitmarkd/blockdigest"
	"github.com/bitmark-inc/bitmarkd/fault"
	"github.com/bitmark-inc/bitmarkd/genesis"
	"github.com/bitmark-inc/bitmarkd/mode"
	"github.com/bitmark-inc/logger"
)
type blockData struct {
	sync.RWMutex  
	log *logger.L
	height            uint64              
	previousBlock     blockdigest.Digest  
	previousVersion   uint16              
	previousTimestamp uint64              
	initialised bool
}
var globalData blockData
func Initialise() error {
	globalData.Lock()
	defer globalData.Unlock()
	if globalData.initialised {
		return fault.AlreadyInitialised
	}
	log := logger.New("blockheader")
	globalData.log = log
	log.Info("starting…")
	setGenesis()
	log.Infof("block height: %d", globalData.height)
	log.Infof("previous block: %v", globalData.previousBlock)
	log.Infof("previous version: %d", globalData.previousVersion)
	globalData.initialised = true
	return nil
}
func Finalise() error {
	if !globalData.initialised {
		return fault.NotInitialised
	}
	globalData.log.Info("shutting down…")
	globalData.log.Flush()
	globalData.initialised = false
	globalData.log.Info("finished")
	globalData.log.Flush()
	return nil
}
func SetGenesis() {
	globalData.Lock()
	setGenesis()
	globalData.Unlock()
}
func setGenesis() {
	globalData.height = genesis.BlockNumber
	globalData.previousBlock = genesis.LiveGenesisDigest
	globalData.previousVersion = 1
	globalData.previousTimestamp = 0
	if mode.IsTesting() {
		globalData.previousBlock = genesis.TestGenesisDigest
	}
}
func Set(height uint64, digest blockdigest.Digest, version uint16, timestamp uint64) {
	globalData.Lock()
	globalData.height = height
	globalData.previousBlock = digest
	globalData.previousVersion = version
	globalData.previousTimestamp = timestamp
	globalData.Unlock()
}
func Get() (uint64, blockdigest.Digest, uint16, uint64) {
	globalData.RLock()
	defer globalData.RUnlock()
	return globalData.height, globalData.previousBlock, globalData.previousVersion, globalData.previousTimestamp
}
func GetNew() (blockdigest.Digest, uint64) {
	globalData.RLock()
	defer globalData.RUnlock()
	nextBlockNumber := globalData.height + 1
	return globalData.previousBlock, nextBlockNumber
}