Documentation ¶
Index ¶
- Constants
- func ConstructCoinbaseTx(rewardReceiver *key.PublicKey, proof []byte, score []byte) (*transactions.Coinbase, error)
- func GenerateGenesisBlock(generatorPubKey *key.PublicKey) (string, error)
- type Factory
- type Generator
- func (bg *Generator) Collect(e consensus.Event) error
- func (bg *Generator) ConstructBlockTxs(proof, score []byte) ([]transactions.Transaction, error)
- func (bg *Generator) Finalize()
- func (bg *Generator) Generate(sev score.Event) (*block.Block, error)
- func (bg *Generator) GenerateBlock(round uint64, seed, proof, score, prevBlockHash []byte) (*block.Block, error)
- func (bg *Generator) ID() uint32
- func (bg *Generator) Initialize(eventPlayer consensus.EventPlayer, signer consensus.Signer, ...) []consensus.TopicListener
- type Helper
Constants ¶
const MaxTxSetSize = 150000
TBD along with block size and processing.MaxFrameSize
Variables ¶
This section is empty.
Functions ¶
func ConstructCoinbaseTx ¶
func ConstructCoinbaseTx(rewardReceiver *key.PublicKey, proof []byte, score []byte) (*transactions.Coinbase, error)
ConstructCoinbaseTx forges the transaction to reward the block generator.
func GenerateGenesisBlock ¶
GenerateGenesisBlock is a developer utility for regenerating the genesis block as they would be different per network type. Once a genesis block is approved, its hex blob should be copied into config.TestNetGenesisBlob
Types ¶
type Factory ¶
type Factory struct { Bus eventbus.Broker RBus *rpcbus.RPCBus // contains filtered or unexported fields }
Factory creates a candidate.Generator.
func NewFactory ¶
func NewFactory(broker eventbus.Broker, rpcBus *rpcbus.RPCBus, walletPubKey *key.PublicKey) *Factory
NewFactory instantiates a Factory.
func (*Factory) Instantiate ¶
Instantiate a candidate Generator. Implements consensus.ComponentFactory.
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator is responsible for generating candidate blocks, and propagating them alongside received Scores. It is triggered by the ScoreEvent, sent by the score generator.
func NewComponent ¶
func NewComponent(publisher eventbus.Publisher, genPubKey *key.PublicKey, rpcBus *rpcbus.RPCBus) *Generator
NewComponent returns an uninitialized candidate generator.
func (*Generator) Collect ¶
Collect a ScoreEvent, which triggers generation of a candidate block. The Generator will propagate both the Score and Candidate messages at the end of this function call.
func (*Generator) ConstructBlockTxs ¶
func (bg *Generator) ConstructBlockTxs(proof, score []byte) ([]transactions.Transaction, error)
ConstructBlockTxs will fetch all valid transactions from the mempool, prepend a coinbase transaction, and return them all.
func (*Generator) Finalize ¶
func (bg *Generator) Finalize()
Finalize implements consensus.Component
func (*Generator) GenerateBlock ¶
func (bg *Generator) GenerateBlock(round uint64, seed, proof, score, prevBlockHash []byte) (*block.Block, error)
GenerateBlock generates a candidate block, by constructing the header and filling it with transactions from the mempool.
func (*Generator) Initialize ¶
func (bg *Generator) Initialize(eventPlayer consensus.EventPlayer, signer consensus.Signer, ru consensus.RoundUpdate) []consensus.TopicListener
Initialize the Generator, by populating the fields needed to generate candidate blocks, and returns a Listener for ScoreEvents. Implements consensus.Component.
type Helper ¶
type Helper struct { Bus *eventbus.EventBus RBus *rpcbus.RPCBus *Factory Generator *Generator *consensus.SimplePlayer ScoreChan, CandidateChan chan bytes.Buffer // contains filtered or unexported fields }
Helper for reducing generation test boilerplate
func NewHelper ¶
func NewHelper(t *testing.T, eb *eventbus.EventBus, rpcBus *rpcbus.RPCBus, txBatchCount uint16) *Helper
NewHelper creates a Helper
func (*Helper) Initialize ¶
func (h *Helper) Initialize(ru consensus.RoundUpdate)
Initialize the generator with the given round update.
func (*Helper) ProvideTransactions ¶
ProvideTransactions sends a set of transactions upon the request of the blockgenerator, standing in place of the mempool.
func (*Helper) TriggerBlockGeneration ¶
func (h *Helper) TriggerBlockGeneration()
TriggerBlockGeneration creates a random ScoreEvent and triggers block generation