consensus

package
v0.0.0-...-1c4572a Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2018 License: BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var QueryData = types.NewQueryData("Query_")

Functions

func Reg

func Reg(name string, create ConsensusCreate)

Types

type BaseClient

type BaseClient struct {
	Cfg *types.Consensus
	// contains filtered or unexported fields
}

func NewBaseClient

func NewBaseClient(cfg *types.Consensus) *BaseClient

func (*BaseClient) AddTxsToBlock

func (bc *BaseClient) AddTxsToBlock(block *types.Block, txs []*types.Transaction) []*types.Transaction

func (*BaseClient) CheckBlock

func (bc *BaseClient) CheckBlock(block *types.BlockDetail) error

func (*BaseClient) CheckTxDup

func (bc *BaseClient) CheckTxDup(txs []*types.Transaction) (transactions []*types.Transaction)

为了不引起交易检查时候产生的无序

func (*BaseClient) Close

func (bc *BaseClient) Close()

func (*BaseClient) ConsensusTicketMiner

func (bc *BaseClient) ConsensusTicketMiner(iscaughtup *types.IsCaughtUp)

func (*BaseClient) EventLoop

func (bc *BaseClient) EventLoop()

准备新区块

func (*BaseClient) ExecConsensus

func (bc *BaseClient) ExecConsensus(data *types.ChainExecutor) (types.Message, error)

func (*BaseClient) GetAPI

func (bc *BaseClient) GetAPI() client.QueueProtocolAPI

func (*BaseClient) GetCurrentBlock

func (bc *BaseClient) GetCurrentBlock() (b *types.Block)

func (*BaseClient) GetCurrentHeight

func (bc *BaseClient) GetCurrentHeight() int64

func (*BaseClient) GetGenesisBlockTime

func (client *BaseClient) GetGenesisBlockTime() int64

func (*BaseClient) GetQueueClient

func (bc *BaseClient) GetQueueClient() queue.Client

func (*BaseClient) InitBlock

func (bc *BaseClient) InitBlock()

change init block

func (*BaseClient) InitClient

func (bc *BaseClient) InitClient(c queue.Client, minerstartCB func())

func (*BaseClient) InitMiner

func (bc *BaseClient) InitMiner()

func (*BaseClient) IsCaughtUp

func (bc *BaseClient) IsCaughtUp() bool

func (*BaseClient) IsMining

func (bc *BaseClient) IsMining() bool

func (*BaseClient) Lock

func (bc *BaseClient) Lock()

func (*BaseClient) RandInt64

func (bc *BaseClient) RandInt64() int64

func (*BaseClient) RequestBlock

func (bc *BaseClient) RequestBlock(start int64) (*types.Block, error)

func (*BaseClient) RequestLastBlock

func (bc *BaseClient) RequestLastBlock() (*types.Block, error)

获取最新的block从blockchain模块

func (*BaseClient) RequestTx

func (bc *BaseClient) RequestTx(listSize int, txHashList [][]byte) []*types.Transaction

Mempool中取交易列表

func (*BaseClient) SetChild

func (bc *BaseClient) SetChild(c Miner)

func (*BaseClient) SetCurrentBlock

func (bc *BaseClient) SetCurrentBlock(b *types.Block)

func (*BaseClient) SetQueueClient

func (bc *BaseClient) SetQueueClient(c queue.Client)

func (*BaseClient) Unlock

func (bc *BaseClient) Unlock()

func (*BaseClient) UpdateCurrentBlock

func (bc *BaseClient) UpdateCurrentBlock(b *types.Block)

func (*BaseClient) WriteBlock

func (bc *BaseClient) WriteBlock(prev []byte, block *types.Block) error

向blockchain写区块

type ConsensusCreate

type ConsensusCreate func(cfg *types.Consensus, sub []byte) queue.Module

func Load

func Load(name string) (create ConsensusCreate, err error)

type Miner

type Miner interface {
	CreateGenesisTx() []*types.Transaction
	GetGenesisBlockTime() int64
	CreateBlock()
	CheckBlock(parent *types.Block, current *types.BlockDetail) error
	ProcEvent(msg queue.Message) bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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