func (l LayerID) Difference(other LayerID) uint32 {
	if other.Value > l.Value {
		panic(fmt.Sprintf("other (%d) must be before or equal to this layer (%d)", other.Value, l.Value))
	}
	return l.Value - other.Value
}
Difference returns the difference between current and other layer.
package types
import (
	"bytes"
	"fmt"
	"sort"
	"strconv"
	"strings"
	"sync/atomic"
	"github.com/spacemeshos/ed25519"
	"github.com/spacemeshos/go-spacemesh/common/util"
	"github.com/spacemeshos/go-spacemesh/log"
	"github.com/spacemeshos/go-spacemesh/signing"
)
const (
	LayerIDSize = 4
	BlockIDSize = Hash32Length
)
type BlockID Hash20
func (id BlockID) String() string {
	return id.AsHash32().ShortString()
}
func (id BlockID) Field() log.Field {
	return log.String("block_id", id.AsHash32().ShortString())
}
func (id BlockID) Compare(other BlockID) bool {
	return bytes.Compare(id.Bytes(), other.Bytes()) < 0
}
func (id BlockID) AsHash32() Hash32 {
	return Hash20(id).ToHash32()
}
var (
	layersPerEpoch uint32
	effectiveGenesis uint32
	EmptyLayerHash = Hash32{}
)
func SetLayersPerEpoch(layers uint32) {
	atomic.StoreUint32(&layersPerEpoch, layers)
	atomic.StoreUint32(&effectiveGenesis, layers*2-1)
}
func getLayersPerEpoch() uint32 {
	return atomic.LoadUint32(&layersPerEpoch)
}
func GetEffectiveGenesis() LayerID {
	return NewLayerID(atomic.LoadUint32(&effectiveGenesis))
}
func NewLayerID(value uint32) LayerID {
	return LayerID{Value: value}
}
type LayerID struct {
	Value uint32
}
func (l LayerID) GetEpoch() EpochID {
	return EpochID(l.Value / getLayersPerEpoch())
}
func (l LayerID) Add(layers uint32) LayerID {
	nl := l.Value + layers
	if nl < l.Value {
		panic("layer_id wraparound")
	}
	l.Value = nl
	return l
}
func (l LayerID) Sub(layers uint32) LayerID {
	if layers > l.Value {
		panic("layer_id wraparound")
	}
	l.Value -= layers
	return l
}
func (l LayerID) OrdinalInEpoch() uint32 {
	return l.Value % getLayersPerEpoch()
}
func (l LayerID) FirstInEpoch() bool {
	return l.OrdinalInEpoch() == 0
}
func (l LayerID) Mul(layers uint32) LayerID {
	if l.Value == 0 {
		return l
	}
	nl := l.Value * layers
	if nl/l.Value != layers {
		panic("layer_id wraparound")
	}
	l.Value = nl
	return l
}
func (l LayerID) Uint32() uint32 {
	return l.Value
}
func (l LayerID) Before(other LayerID) bool {
	return l.Value < other.Value
}
func (l LayerID) After(other LayerID) bool {
	return l.Value > other.Value
}