blockproducer

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2019 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Overview

Package blockproducer implements Bchain block creation and producing block.

Index

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 (self *CpuAgent) GetHashRate() int64

func (*CpuAgent) SetReturnCh

func (self *CpuAgent) SetReturnCh(ch chan<- *Result)

func (*CpuAgent) Start

func (self *CpuAgent) Start()

func (*CpuAgent) Stop

func (self *CpuAgent) Stop()

func (*CpuAgent) Work

func (self *CpuAgent) Work() chan<- *Work

type Result

type Result struct {
	Work  *Work
	Block *block.Block
}

type Work

type Work struct {
	Block *block.Block // the new block
	// contains filtered or unexported fields
}

Work is the workers current environment and holds all of the current state information

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL