func deserializeAddrIndexEntry(serialized []byte, region *database.BlockRegion, fetchBlockHash fetchBlockHashFunc) error {
	if len(serialized) < txEntrySize {
		return errDeserialize("unexpected end of data")
	}
	hash, err := fetchBlockHash(serialized[0:4])
	if err != nil {
		return err
	}
	region.Hash = hash
	region.Offset = byteOrder.Uint32(serialized[4:8])
	region.Len = byteOrder.Uint32(serialized[8:12])
	return nil
}
deserializeAddrIndexEntry decodes the passed serialized byte slice into the
provided region struct according to the format described in detail above and
uses the passed block hash fetching function in order to conver the block ID
to the associated block hash.
package indexers
import (
	"errors"
	"fmt"
	"sync"
	"github.com/HcashOrg/hcashd/blockchain"
	"github.com/HcashOrg/hcashd/blockchain/stake"
	"github.com/HcashOrg/hcashd/chaincfg"
	"github.com/HcashOrg/hcashd/chaincfg/chainec"
	"github.com/HcashOrg/hcashd/chaincfg/chainhash"
	"github.com/HcashOrg/hcashd/database"
	"github.com/HcashOrg/hcashd/txscript"
	"github.com/HcashOrg/hcashd/wire"
	"github.com/HcashOrg/hcashutil"
	"github.com/HcashOrg/hcashd/crypto/bliss"
	"github.com/HcashOrg/hcashd/crypto/lms"
)
const (
	addrIndexName = "address index"
	level0MaxEntries = 8
	addrKeySize = 1 + 20
	levelKeySize = addrKeySize + 1
	levelOffset = levelKeySize - 1
	addrKeyTypePubKeyHash = 0
	addrKeyTypePubKeyHashEdwards = 1
	addrKeyTypePubKeyHashSchnorr = 2
	addrKeyTypeScriptHash = 3
	addrKeyTypePubKeyHashBliss = 4
	addrKeyTypePubKeyHashLms = 5
	txEntrySize = 4 + 4 + 4
)
var (
	addrIndexKey = []byte("txbyaddridx")
	errUnsupportedAddressType = errors.New("address type is not supported " +
		"by the address index")
)
type fetchBlockHashFunc func(serializedID []byte) (*chainhash.Hash, error)
func serializeAddrIndexEntry(blockID uint32, txLoc wire.TxLoc) []byte {
	serialized := make([]byte, 12)
	byteOrder.PutUint32(serialized, blockID)
	byteOrder.PutUint32(serialized[4:], uint32(txLoc.TxStart))
	byteOrder.PutUint32(serialized[8:], uint32(txLoc.TxLen))
	return serialized
}