pow

package
v0.74.3 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNonceAlreadyUsedByParty = errors.New("nonce already used by party")

Functions

This section is empty.

Types

type Config

type Config struct {
	Level encoding.LogLevel `long:"log-level"`
}

Config represent the configuration of the proof of work engine.

func NewDefaultConfig

func NewDefaultConfig() Config

NewDefaultConfig creates an instance of the package specific configuration, given a pointer to a logger instance to be used for logging within the package.

type Engine

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

func New

func New(log *logging.Logger, config Config) *Engine

New instantiates the proof of work engine.

func (*Engine) BeginBlock

func (e *Engine) BeginBlock(blockHeight uint64, blockHash string, txs []abci.Tx)

OnBeginBlock updates the block height and block hash and clears any out of scope parameters set and states. It also records all of the block's transactions.

func (*Engine) BlockData

func (e *Engine) BlockData() (uint64, string)

func (*Engine) CheckBlockTx added in v0.74.0

func (e *Engine) CheckBlockTx(tx abci.Tx) (ValidationResult, *uint)

CheckBlockTx verifies if a transaction can be included a prepared/verified block.

func (*Engine) CheckTx

func (e *Engine) CheckTx(tx abci.Tx) error

CheckTx is called by checkTx in the abci and verifies the proof of work, it doesn't update any state.

func (*Engine) DisableVerification added in v0.73.0

func (e *Engine) DisableVerification()

func (*Engine) EndPrepareProposal added in v0.74.0

func (e *Engine) EndPrepareProposal(txs []ValidationEntry)

EndPrepareProposal is a callback called at the end of prepareBlock to revert to the state before prepare block.

func (*Engine) GetSpamStatistics added in v0.67.0

func (e *Engine) GetSpamStatistics(partyID string) *protoapi.PoWStatistic

func (*Engine) GetState

func (e *Engine) GetState(k string) ([]byte, []types.StateProvider, error)

func (*Engine) IsReady

func (e *Engine) IsReady() bool

func (*Engine) Keys

func (e *Engine) Keys() []string

func (*Engine) LoadState

func (e *Engine) LoadState(ctx context.Context, p *types.Payload) ([]types.StateProvider, error)

func (*Engine) Namespace

func (e *Engine) Namespace() types.SnapshotNamespace

func (*Engine) OnCommit added in v0.74.0

func (e *Engine) OnCommit()

OnCommit is called when the finalizeBlock is completed to clenup the mempool cache.

func (*Engine) ProcessProposal added in v0.74.0

func (e *Engine) ProcessProposal(txs []abci.Tx) bool

func (*Engine) SpamPoWDifficulty

func (e *Engine) SpamPoWDifficulty() uint32

func (*Engine) SpamPoWHashFunction

func (e *Engine) SpamPoWHashFunction() string

func (*Engine) SpamPoWIncreasingDifficulty

func (e *Engine) SpamPoWIncreasingDifficulty() bool

func (*Engine) SpamPoWNumberOfPastBlocks

func (e *Engine) SpamPoWNumberOfPastBlocks() uint32

func (*Engine) SpamPoWNumberOfTxPerBlock

func (e *Engine) SpamPoWNumberOfTxPerBlock() uint32

func (*Engine) Stopped

func (e *Engine) Stopped() bool

func (*Engine) UpdateSpamPoWDifficulty

func (e *Engine) UpdateSpamPoWDifficulty(_ context.Context, spamPoWDifficulty *num.Uint) error

UpdateSpamPoWDifficulty updates the network parameter for difficulty.

func (*Engine) UpdateSpamPoWHashFunction

func (e *Engine) UpdateSpamPoWHashFunction(_ context.Context, spamPoWHashFunction string) error

UpdateSpamPoWHashFunction updates the network parameter for hash function.

func (*Engine) UpdateSpamPoWIncreasingDifficulty

func (e *Engine) UpdateSpamPoWIncreasingDifficulty(_ context.Context, spamPoWIncreasingDifficulty *num.Uint) error

UpdateSpamPoWIncreasingDifficulty enables/disabled increased difficulty.

func (*Engine) UpdateSpamPoWNumberOfPastBlocks

func (e *Engine) UpdateSpamPoWNumberOfPastBlocks(_ context.Context, spamPoWNumberOfPastBlocks *num.Uint) error

UpdateSpamPoWNumberOfPastBlocks updates the network parameter of number of past blocks to look at. This requires extending or shrinking the size of the cache.

func (*Engine) UpdateSpamPoWNumberOfTxPerBlock

func (e *Engine) UpdateSpamPoWNumberOfTxPerBlock(_ context.Context, spamPoWNumberOfTxPerBlock *num.Uint) error

UpdateSpamPoWNumberOfTxPerBlock updates the number of transactions allowed for a party per block before increased difficulty kicks in if enabled.

type NoopEngine

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

func NewNoop

func NewNoop() *NoopEngine

func (*NoopEngine) BeginBlock

func (e *NoopEngine) BeginBlock(blockHeight uint64, blockHash string, txs []abci.Tx)

func (*NoopEngine) BlockData

func (e *NoopEngine) BlockData() (uint64, string)

func (*NoopEngine) CheckBlockTx added in v0.74.0

func (e *NoopEngine) CheckBlockTx(tx abci.Tx) (ValidationResult, *uint)

func (*NoopEngine) CheckTx

func (e *NoopEngine) CheckTx(tx abci.Tx) error

func (*NoopEngine) Commit added in v0.58.0

func (e *NoopEngine) Commit()

func (*NoopEngine) EndOfBlock

func (e *NoopEngine) EndOfBlock()

func (*NoopEngine) EndPrepareProposal added in v0.74.0

func (e *NoopEngine) EndPrepareProposal([]ValidationEntry)

func (*NoopEngine) GetSpamStatistics added in v0.67.0

func (e *NoopEngine) GetSpamStatistics(_ string) *protoapi.PoWStatistic

func (*NoopEngine) IsReady

func (e *NoopEngine) IsReady() bool

func (*NoopEngine) OnFinalize added in v0.74.0

func (e *NoopEngine) OnFinalize()

func (*NoopEngine) ProcessProposal added in v0.74.0

func (e *NoopEngine) ProcessProposal([]abci.Tx) bool

func (*NoopEngine) SpamPoWDifficulty

func (e *NoopEngine) SpamPoWDifficulty() uint32

func (*NoopEngine) SpamPoWHashFunction

func (e *NoopEngine) SpamPoWHashFunction() string

func (*NoopEngine) SpamPoWIncreasingDifficulty

func (e *NoopEngine) SpamPoWIncreasingDifficulty() bool

func (*NoopEngine) SpamPoWNumberOfPastBlocks

func (e *NoopEngine) SpamPoWNumberOfPastBlocks() uint32

func (*NoopEngine) SpamPoWNumberOfTxPerBlock

func (e *NoopEngine) SpamPoWNumberOfTxPerBlock() uint32

type ValidationEntry added in v0.74.0

type ValidationEntry struct {
	ValResult  ValidationResult
	Difficulty *uint
	Tx         abci.Tx
}

type ValidationResult added in v0.74.0

type ValidationResult int64
const (
	ValidationResultVerificationPowError ValidationResult = iota
	ValidationResultValidatorCommand
	ValidationResultTooManyTx
	ValidationResultSuccess
)

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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