consensus

package
v0.0.0-...-a0a9112 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2023 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Overview

Package consensus implements the PoWork consensus

Index

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 tnmtypes.Network, privateKey *secp256k1.PrivateKey, height uint64, extraData []byte) *tnmtypes.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      *tnmpool.TxPool
	State     *tnmstate.State
	LocalNode *tnmp2p.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 *tnmpool.TxPool, state *tnmstate.State, localNode *tnmp2p.LocalNode, config PoWorkConfig) *PoWork

InitPoWConsensus creates and initializes the PoW consensus.

func (*PoWork) GetBareBlockTemplateWithTxs

func (pow *PoWork) GetBareBlockTemplateWithTxs() (bareBlock *tnmtypes.FullBlock, txs []*tnmtypes.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) tnmtypes.Block

GetBlockTemplate is a generator of new block. But the generated block has no nonce.

func (*PoWork) GetChain

func (pow *PoWork) GetChain() tnmtypes.Chain

GetChain returns the chain of the PoW consensus.

func (*PoWork) GoLoop

func (pow *PoWork) GoLoop()

GoLoop ignites all loops.

func (*PoWork) ImportBlock

func (pow *PoWork) ImportBlock(b tnmtypes.Block) error

func (*PoWork) MinedNewBlock

func (pow *PoWork) MinedNewBlock(block *tnmtypes.FullBlock) error

MinedNewBlock means the local (from rpc) mined new block and need to add it into the chain. called by submitBlock and submitWork

type PoWorkConfig

type PoWorkConfig struct {
	Network                     tnmtypes.Network
	StrictMode                  bool
	SnapshotMode                bool
	DisableConnectingBootstraps bool
}

type RemoteRecord

type RemoteRecord struct {
	// contains filtered or unexported fields
}

func NewRemoteRecord

func NewRemoteRecord(id peer.ID, origin, latest uint64, checkpointHash, checkpointActualDiff []byte) *RemoteRecord

Jump to

Keyboard shortcuts

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