func (cs *ChainState) fetchLastWorkHeight() uint32 {
	return atomic.LoadUint32(&cs.lastWorkHeight)
}
fetchLastWorkHeight fetches the last work height.
package pool
import (
	"context"
	"errors"
	"sync"
	"sync/atomic"
	"time"
	"github.com/decred/dcrd/blockchain/standalone/v2"
	"github.com/decred/dcrd/chaincfg/chainhash"
	"github.com/decred/dcrd/dcrutil/v3"
	"github.com/decred/dcrd/wire"
	errs "github.com/decred/dcrpool/errors"
)
const (
	bufferSize = 128
)
type ChainStateConfig struct {
	db Database
	SoloPool bool
	ProcessPayments func(msg *paymentMsg)
	GeneratePayments func(uint32, *PaymentSource, dcrutil.Amount, int64) error
	GetBlock func(context.Context, *chainhash.Hash) (*wire.MsgBlock, error)
	GetBlockConfirmations func(context.Context, *chainhash.Hash) (int64, error)
	Cancel context.CancelFunc
	SignalCache func(event CacheUpdateEvent)
	HubWg *sync.WaitGroup
}
type blockNotification struct {
	Header []byte
	Done   chan bool
}
type ChainState struct {
	lastWorkHeight uint32  
	cfg            *ChainStateConfig
	connCh         chan *blockNotification
	discCh         chan *blockNotification
	currentWork    string
	currentWorkMtx sync.RWMutex
}
func NewChainState(sCfg *ChainStateConfig) *ChainState {
	return &ChainState{
		cfg:    sCfg,
		connCh: make(chan *blockNotification, bufferSize),
		discCh: make(chan *blockNotification, bufferSize),
	}
}