Documentation ¶
Overview ¶
Package blockproducer implements Bchain block creation and producing block.
Index ¶
- Variables
- type Agent
- type Backend
- type Blockproducer
- func (self *Blockproducer) GetProducerNewBlock(data *block.ConsensusData, timeLimit int64) *block.Block
- func (self *Blockproducer) HashRate() (tot int64)
- func (self *Blockproducer) Pending() (*block.Block, *state.StateDB)
- func (self *Blockproducer) PendingBlock() *block.Block
- func (self *Blockproducer) Producing() bool
- func (self *Blockproducer) Register(agent Agent)
- func (self *Blockproducer) SetCoinbase(addr types.Address)
- func (self *Blockproducer) SetExtra(extra []byte) error
- func (self *Blockproducer) SetPriKey(pri *ecdsa.PrivateKey)
- func (self *Blockproducer) Start(coinbase types.Address)
- func (self *Blockproducer) Stop()
- func (self *Blockproducer) Unregister(agent Agent)
- type CpuAgent
- type Result
- type Work
Constants ¶
This section is empty.
Variables ¶
View Source
var (
LogTag = "blockproducer"
)
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent interface { Work() chan<- *Work SetReturnCh(chan<- *Result) Stop() Start() GetHashRate() int64 }
Agent can register themself with the worker
type Backend ¶
type Backend interface { AccountManager() *accounts.Manager BlockChain() *blockchain.BlockChain TxPool() *txprocessor.TxPool ChainDb() database.IDatabase }
Backend wraps all methods required for producing block.
type Blockproducer ¶
type Blockproducer struct {
// contains filtered or unexported fields
}
Blockproducer creates blocks and searches for proof-of-work values.
func New ¶
func New(bchain Backend, config *params.ChainConfig, mux *event.TypeMux, engine consensus.Engine, maxBlkSize uint64) *Blockproducer
func (*Blockproducer) GetProducerNewBlock ¶
func (self *Blockproducer) GetProducerNewBlock(data *block.ConsensusData, timeLimit int64) *block.Block
func (*Blockproducer) HashRate ¶
func (self *Blockproducer) HashRate() (tot int64)
func (*Blockproducer) Pending ¶
func (self *Blockproducer) Pending() (*block.Block, *state.StateDB)
Pending returns the currently pending block and associated state.
func (*Blockproducer) PendingBlock ¶
func (self *Blockproducer) PendingBlock() *block.Block
PendingBlock returns the currently pending block.
Note, to access both the pending block and the pending state simultaneously, please use Pending(), as the pending state can change between multiple method calls
func (*Blockproducer) Producing ¶
func (self *Blockproducer) Producing() bool
func (*Blockproducer) Register ¶
func (self *Blockproducer) Register(agent Agent)
func (*Blockproducer) SetCoinbase ¶
func (self *Blockproducer) SetCoinbase(addr types.Address)
func (*Blockproducer) SetExtra ¶
func (self *Blockproducer) SetExtra(extra []byte) error
func (*Blockproducer) SetPriKey ¶
func (self *Blockproducer) SetPriKey(pri *ecdsa.PrivateKey)
func (*Blockproducer) Start ¶
func (self *Blockproducer) Start(coinbase types.Address)
func (*Blockproducer) Stop ¶
func (self *Blockproducer) Stop()
func (*Blockproducer) Unregister ¶
func (self *Blockproducer) Unregister(agent Agent)
type CpuAgent ¶
type CpuAgent struct {
// contains filtered or unexported fields
}
func NewCpuAgent ¶
func NewCpuAgent(chain consensus.ChainReader, engine consensus.Engine) *CpuAgent
func (*CpuAgent) GetHashRate ¶
func (*CpuAgent) SetReturnCh ¶
Click to show internal directories.
Click to hide internal directories.