func (g *Generator) Params() *chaincfg.Params {
	return g.params
}
Params returns the chain params associated with the generator instance.
package chaingen
import (
	"bytes"
	"encoding/binary"
	"fmt"
	"math"
	"math/big"
	"runtime"
	"sort"
	"time"
	"github.com/HcashOrg/hcashd/blockchain"
	"github.com/HcashOrg/hcashd/chaincfg"
	"github.com/HcashOrg/hcashd/chaincfg/chainhash"
	"github.com/HcashOrg/hcashd/txscript"
	"github.com/HcashOrg/hcashd/wire"
	"github.com/HcashOrg/hcashutil"
)
var (
	hash256prngSeedConst = []byte{0x24, 0x3f, 0x6a, 0x88, 0x85, 0xa3, 0x08,
		0xd3}
	opTrueScript = []byte{txscript.OP_TRUE}
	opTrueRedeemScript = []byte{txscript.OP_DATA_1, txscript.OP_TRUE}
	coinbaseSigScript = []byte{txscript.OP_0, txscript.OP_0}
)
const (
	voteBitYes = 0x01
)
type SpendableOut struct {
	prevOut     wire.OutPoint
	blockHeight uint32
	blockIndex  uint32
	amount      hcashutil.Amount
}
func (s *SpendableOut) PrevOut() wire.OutPoint {
	return s.prevOut
}
func (s *SpendableOut) BlockHeight() uint32 {
	return s.blockHeight
}
func (s *SpendableOut) BlockIndex() uint32 {
	return s.blockIndex
}
func (s *SpendableOut) Amount() hcashutil.Amount {
	return s.amount
}
func MakeSpendableOutForTx(tx *wire.MsgTx, blockHeight, txIndex, txOutIndex uint32) SpendableOut {
	return SpendableOut{
		prevOut: wire.OutPoint{
			Hash:  *tx.CachedTxHash(),
			Index: txOutIndex,
			Tree:  wire.TxTreeRegular,
		},
		blockHeight: blockHeight,
		blockIndex:  txIndex,
		amount:      hcashutil.Amount(tx.TxOut[txOutIndex].Value),
	}
}
func MakeSpendableOut(block *wire.MsgBlock, txIndex, txOutIndex uint32) SpendableOut {
	tx := block.Transactions[txIndex]
	return MakeSpendableOutForTx(tx, block.Header.Height, txIndex, txOutIndex)
}
type stakeTicket struct {
	tx          *wire.MsgTx
	blockHeight uint32
	blockIndex  uint32
}
type stakeTicketSorter []*stakeTicket
func (t stakeTicketSorter) Len() int { return len(t) }
func (t stakeTicketSorter) Swap(i, j int) { t[i], t[j] = t[j], t[i] }
func (t stakeTicketSorter) Less(i, j int) bool {
	iHash := t[i].tx.CachedTxHash()[:]
	jHash := t[j].tx.CachedTxHash()[:]
	return bytes.Compare(iHash, jHash) < 0
}
type Generator struct {
	params           *chaincfg.Params
	tip              *wire.MsgBlock
	tipName          string
	blocks           map[chainhash.Hash]*wire.MsgBlock
	blocksByName     map[string]*wire.MsgBlock
	p2shOpTrueAddr   hcashutil.Address
	p2shOpTrueScript []byte
	spendableOuts     [][]SpendableOut
	prevCollectedHash chainhash.Hash
	originalParents map[chainhash.Hash]chainhash.Hash
	immatureTickets []*stakeTicket
	liveTickets     []*stakeTicket
	wonTickets      map[chainhash.Hash][]*stakeTicket
	expiredTickets  []*stakeTicket
}
func MakeGenerator(params *chaincfg.Params) (Generator, error) {
	p2shOpTrueAddr, err := hcashutil.NewAddressScriptHash(opTrueScript, params)
	if err != nil {
		return Generator{}, err
	}
	p2shOpTrueScript, err := txscript.PayToAddrScript(p2shOpTrueAddr)
	if err != nil {
		return Generator{}, err
	}
	genesis := params.GenesisBlock
	genesisHash := genesis.BlockHash()
	return Generator{
		params:           params,
		tip:              genesis,
		tipName:          "genesis",
		blocks:           map[chainhash.Hash]*wire.MsgBlock{genesisHash: genesis},
		blocksByName:     map[string]*wire.MsgBlock{"genesis": genesis},
		p2shOpTrueAddr:   p2shOpTrueAddr,
		p2shOpTrueScript: p2shOpTrueScript,
		originalParents:  make(map[chainhash.Hash]chainhash.Hash),
		wonTickets:       make(map[chainhash.Hash][]*stakeTicket),
	}, nil
}