Documentation ¶
Overview ¶
Package miner implements Ethereum block creation and mining.
Index ¶
- Constants
- type Agent
- type Backend
- type CPUAgent
- type CommitteeElection
- type Miner
- func (miner *Miner) GetCurrentBlock() *types.SnailBlock
- func (miner *Miner) HashRate() (tot int64)
- func (miner *Miner) Mining() bool
- func (miner *Miner) Pending() (*types.Block, *state.StateDB)
- func (miner *Miner) PendingBlock() *types.Block
- func (miner *Miner) PendingSnail() (*types.SnailBlock, *state.StateDB)
- func (miner *Miner) PendingSnailBlock() *types.SnailBlock
- func (miner *Miner) Register(agent Agent)
- func (miner *Miner) SetElection(toElect bool, pubkey []byte)
- func (miner *Miner) SetEtherbase(addr common.Address)
- func (miner *Miner) SetExtra(extra []byte) error
- func (miner *Miner) SetFruitOnly(FruitOnly bool)
- func (miner *Miner) SetShouldStartMining(start bool)
- func (miner *Miner) Start(coinbase common.Address)
- func (miner *Miner) Stop()
- func (miner *Miner) Unregister(agent Agent)
- type RemoteAgent
- func (a *RemoteAgent) CompletionHexString(n int, src string) string
- func (a *RemoteAgent) GetDataset() ([DATASETHEADLENGH]string, error)
- func (a *RemoteAgent) GetDatasetBySeedHash(seedHash string) ([DATASETHEADLENGH]string, error)
- func (a *RemoteAgent) GetHashRate() (tot int64)
- func (a *RemoteAgent) GetWork() ([4]string, error)
- func (a *RemoteAgent) SetReturnCh(returnCh chan<- *Result)
- func (a *RemoteAgent) Start()
- func (a *RemoteAgent) Stop()
- func (a *RemoteAgent) SubmitHashrate(id common.Hash, rate uint64)
- func (a *RemoteAgent) SubmitWork(nonce types.BlockNonce, mixDigest, hash common.Hash) bool
- func (a *RemoteAgent) Work() chan<- *Work
- type Result
- type Work
Constants ¶
const DATASETHEADLENGH = 10240
const UPDATABLOCKLENGTH = 12000 //12000 3000
Variables ¶
This section is empty.
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 SnailBlockChain() *snailchain.SnailBlockChain BlockChain() *core.BlockChain TxPool() *core.TxPool SnailPool() *snailchain.SnailPool ChainDb() etruedb.Database }
Backend wraps all methods required for mining.
type CPUAgent ¶
type CPUAgent struct {
// contains filtered or unexported fields
}
CPUAgent is for agent to mine
func NewCPUAgent ¶
func NewCPUAgent(chain consensus.SnailChainReader, engine consensus.Engine) *CPUAgent
NewCPUAgent create a Agent for miner
func (*CPUAgent) GetHashRate ¶
GetHashRate return the cpu miner rate
func (*CPUAgent) SetReturnCh ¶
SetReturnCh is Agent return monitor result chan after the miner
func (*CPUAgent) Start ¶
func (agent *CPUAgent) Start()
Start is a interface the work can control the Agent to start miner
type CommitteeElection ¶
type CommitteeElection interface { //VerifySigns verify the fast chain committee signatures in batches VerifySigns(pvs []*types.PbftSign) ([]*types.CommitteeMember, []error) //Get a list of committee members GetCommittee(fastNumber *big.Int) []*types.CommitteeMember SubscribeElectionEvent(ch chan<- types.ElectionEvent) event.Subscription IsCommitteeMember(members []*types.CommitteeMember, publickey []byte) bool }
CommitteeElection interface is Election module implementation committee interface
type Miner ¶
type Miner struct {
// contains filtered or unexported fields
}
Miner creates blocks and searches for proof-of-work values.
func New ¶
func New(truechain Backend, config *params.ChainConfig, mux *event.TypeMux, engine consensus.Engine, election CommitteeElection, mineFruit bool, singleNode bool, remoteMining bool, mining bool) *Miner
New is create a miner object
func (*Miner) GetCurrentBlock ¶
func (miner *Miner) GetCurrentBlock() *types.SnailBlock
GetCurrentBlock return the fruit or block it is mining
func (*Miner) PendingBlock ¶
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 (*Miner) PendingSnail ¶
func (miner *Miner) PendingSnail() (*types.SnailBlock, *state.StateDB)
PendingSnail returns the currently pending Snailblock and associated state.
func (*Miner) PendingSnailBlock ¶
func (miner *Miner) PendingSnailBlock() *types.SnailBlock
PendingSnailBlock 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 (*Miner) SetElection ¶
SetElection Election is after mine the miner can be committee number
func (*Miner) SetEtherbase ¶
SetEtherbase for reward
func (*Miner) SetFruitOnly ¶
SetFruitOnly allow the mine only mined fruit
func (*Miner) SetShouldStartMining ¶
Stop stop miner
func (*Miner) Unregister ¶
Unregister is Unregister the Agent
type RemoteAgent ¶
type RemoteAgent struct {
// contains filtered or unexported fields
}
RemoteAgent for Remote mine
func NewRemoteAgent ¶
func NewRemoteAgent(chain consensus.ChainReader, snailchain consensus.SnailChainReader, engine consensus.Engine) *RemoteAgent
NewRemoteAgent create remote agent object
func (*RemoteAgent) CompletionHexString ¶
func (a *RemoteAgent) CompletionHexString(n int, src string) string
func (*RemoteAgent) GetDataset ¶
func (a *RemoteAgent) GetDataset() ([DATASETHEADLENGH]string, error)
GetWork return the current block hash without nonce
func (*RemoteAgent) GetDatasetBySeedHash ¶
func (a *RemoteAgent) GetDatasetBySeedHash(seedHash string) ([DATASETHEADLENGH]string, error)
GetWork return the current block hash without nonce
func (*RemoteAgent) GetHashRate ¶
func (a *RemoteAgent) GetHashRate() (tot int64)
GetHashRate returns the accumulated hashrate of all identifier combined
func (*RemoteAgent) GetWork ¶
func (a *RemoteAgent) GetWork() ([4]string, error)
GetWork return the current block hash without nonce
func (*RemoteAgent) SetReturnCh ¶
func (a *RemoteAgent) SetReturnCh(returnCh chan<- *Result)
SetReturnCh return a mine result for return chan
func (*RemoteAgent) SubmitHashrate ¶
func (a *RemoteAgent) SubmitHashrate(id common.Hash, rate uint64)
SubmitHashrate return the HashRate for remote agent
func (*RemoteAgent) SubmitWork ¶
func (a *RemoteAgent) SubmitWork(nonce types.BlockNonce, mixDigest, hash common.Hash) bool
SubmitWork tries to inject a pow solution into the remote agent, returning whether the solution was accepted or not (not can be both a bad pow as well as any other error, like no work pending).
type Result ¶
type Result struct { Work *Work Block *types.SnailBlock }
Result is for miner and get mined result
type Work ¶
type Work struct { Block *types.SnailBlock // the new block // contains filtered or unexported fields }
Work is the workers current environment and holds all of the current state information