func (si *StampIssuer) Label() string {
	return si.data.Label
}
Label returns the label of the issuer.
package postage
import (
	"encoding/binary"
	"math/big"
	"sync"
	"github.com/ethsana/sana/pkg/swarm"
	"github.com/vmihailenco/msgpack/v5"
)
type stampIssuerData struct {
	Label          string   `msgpack:"label"`           
	KeyID          string   `msgpack:"keyID"`           
	BatchID        []byte   `msgpack:"batchID"`         
	BatchAmount    *big.Int `msgpack:"batchAmount"`     
	BatchDepth     uint8    `msgpack:"batchDepth"`      
	BucketDepth    uint8    `msgpack:"bucketDepth"`     
	Buckets        []uint32 `msgpack:"buckets"`         
	MaxBucketCount uint32   `msgpack:"maxBucketCount"`  
	BlockNumber    uint64   `msgpack:"blockNumber"`     
	ImmutableFlag  bool     `msgpack:"immutableFlag"`   
}
type StampIssuer struct {
	bucketMu sync.Mutex
	data     stampIssuerData
}
func NewStampIssuer(label, keyID string, batchID []byte, batchAmount *big.Int, batchDepth, bucketDepth uint8, blockNumber uint64, immutableFlag bool) *StampIssuer {
	return &StampIssuer{
		data: stampIssuerData{
			Label:         label,
			KeyID:         keyID,
			BatchID:       batchID,
			BatchAmount:   batchAmount,
			BatchDepth:    batchDepth,
			BucketDepth:   bucketDepth,
			Buckets:       make([]uint32, 1<<bucketDepth),
			BlockNumber:   blockNumber,
			ImmutableFlag: immutableFlag,
		},
	}
}
func (si *StampIssuer) inc(addr swarm.Address) ([]byte, error) {
	si.bucketMu.Lock()
	defer si.bucketMu.Unlock()
	b := toBucket(si.BucketDepth(), addr)
	bucketCount := si.data.Buckets[b]
	if bucketCount == 1<<(si.Depth()-si.BucketDepth()) {
		return nil, ErrBucketFull
	}
	si.data.Buckets[b]++
	if si.data.Buckets[b] > si.data.MaxBucketCount {
		si.data.MaxBucketCount = si.data.Buckets[b]
	}
	return indexToBytes(b, bucketCount), nil
}
func toBucket(depth uint8, addr swarm.Address) uint32 {
	i := binary.BigEndian.Uint32(addr.Bytes()[:4])
	return i >> (32 - depth)
}
func indexToBytes(bucket, index uint32) []byte {
	buf := make([]byte, IndexSize)
	binary.BigEndian.PutUint32(buf, bucket)
	binary.BigEndian.PutUint32(buf[4:], index)
	return buf
}
func bytesToIndex(buf []byte) (bucket, index uint32) {
	index64 := binary.BigEndian.Uint64(buf)
	bucket = uint32(index64 >> 32)
	index = uint32(index64)
	return bucket, index
}