Documentation ¶
Overview ¶
Package consensus implements the PoWork consensus
Index ¶
- Variables
- func CreateGenerateTx(network ngtypes.Network, privateKey *secp256k1.PrivateKey, height uint64, ...) *ngtypes.FullTx
- type PoWork
- func (pow *PoWork) GetBareBlockTemplateWithTxs() (bareBlock *ngtypes.FullBlock, txs []*ngtypes.FullTx)
- func (pow *PoWork) GetBlockTemplate(privateKey *secp256k1.PrivateKey) ngtypes.Block
- func (pow *PoWork) GetChain() ngtypes.Chain
- func (pow *PoWork) GoLoop()
- func (pow *PoWork) ImportBlock(b ngtypes.Block) error
- func (pow *PoWork) MinedNewBlock(block *ngtypes.FullBlock) error
- type PoWorkConfig
- type RemoteRecord
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrMsgRejected = errors.New("message get rejected") ErrInvalidMsgType = errors.New("invalid message type") )
View Source
var ErrChainOnSyncing = errors.New("chain is syncing")
Functions ¶
func CreateGenerateTx ¶
func CreateGenerateTx(network ngtypes.Network, privateKey *secp256k1.PrivateKey, height uint64, extraData []byte) *ngtypes.FullTx
CreateGenerateTx will create a generate Tx for new Block. generate Tx is disallowed to edit external so use more local var.
Types ¶
type PoWork ¶
type PoWork struct { PoWorkConfig SyncMod *syncModule Chain *blockchain.Chain Pool *ngpool.TxPool State *ngstate.State LocalNode *ngp2p.LocalNode // contains filtered or unexported fields }
PoWork is a proof on work consensus manager.
func InitPoWConsensus ¶
func InitPoWConsensus(db *bbolt.DB, chain *blockchain.Chain, pool *ngpool.TxPool, state *ngstate.State, localNode *ngp2p.LocalNode, config PoWorkConfig) *PoWork
InitPoWConsensus creates and initializes the PoW consensus.
func (*PoWork) GetBareBlockTemplateWithTxs ¶
func (pow *PoWork) GetBareBlockTemplateWithTxs() (bareBlock *ngtypes.FullBlock, txs []*ngtypes.FullTx)
GetBlockTemplate is a generator of new block. But the generated block has no nonce.
func (*PoWork) GetBlockTemplate ¶
func (pow *PoWork) GetBlockTemplate(privateKey *secp256k1.PrivateKey) ngtypes.Block
GetBlockTemplate is a generator of new block. But the generated block has no nonce.
type PoWorkConfig ¶
type RemoteRecord ¶
type RemoteRecord struct {
// contains filtered or unexported fields
}
func NewRemoteRecord ¶
func NewRemoteRecord(id peer.ID, origin, latest uint64, checkpointHash, checkpointActualDiff []byte) *RemoteRecord
Click to show internal directories.
Click to hide internal directories.