Documentation ¶
Index ¶
- Variables
- type Config
- type Engine
- func (e *Engine) BeginBlock(blockHeight uint64, blockHash string, txs []abci.Tx)
- func (e *Engine) BlockData() (uint64, string)
- func (e *Engine) CheckBlockTx(tx abci.Tx) (ValidationResult, *uint)
- func (e *Engine) CheckTx(tx abci.Tx) error
- func (e *Engine) DisableVerification()
- func (e *Engine) EndPrepareProposal(txs []ValidationEntry)
- func (e *Engine) GetSpamStatistics(partyID string) *protoapi.PoWStatistic
- func (e *Engine) GetState(k string) ([]byte, []types.StateProvider, error)
- func (e *Engine) IsReady() bool
- func (e *Engine) Keys() []string
- func (e *Engine) LoadState(ctx context.Context, p *types.Payload) ([]types.StateProvider, error)
- func (e *Engine) Namespace() types.SnapshotNamespace
- func (e *Engine) OnCommit()
- func (e *Engine) ProcessProposal(txs []abci.Tx) bool
- func (e *Engine) SpamPoWDifficulty() uint32
- func (e *Engine) SpamPoWHashFunction() string
- func (e *Engine) SpamPoWIncreasingDifficulty() bool
- func (e *Engine) SpamPoWNumberOfPastBlocks() uint32
- func (e *Engine) SpamPoWNumberOfTxPerBlock() uint32
- func (e *Engine) Stopped() bool
- func (e *Engine) UpdateSpamPoWDifficulty(_ context.Context, spamPoWDifficulty *num.Uint) error
- func (e *Engine) UpdateSpamPoWHashFunction(_ context.Context, spamPoWHashFunction string) error
- func (e *Engine) UpdateSpamPoWIncreasingDifficulty(_ context.Context, spamPoWIncreasingDifficulty *num.Uint) error
- func (e *Engine) UpdateSpamPoWNumberOfPastBlocks(_ context.Context, spamPoWNumberOfPastBlocks *num.Uint) error
- func (e *Engine) UpdateSpamPoWNumberOfTxPerBlock(_ context.Context, spamPoWNumberOfTxPerBlock *num.Uint) error
- type NoopEngine
- func (e *NoopEngine) BeginBlock(blockHeight uint64, blockHash string, txs []abci.Tx)
- func (e *NoopEngine) BlockData() (uint64, string)
- func (e *NoopEngine) CheckBlockTx(tx abci.Tx) (ValidationResult, *uint)
- func (e *NoopEngine) CheckTx(tx abci.Tx) error
- func (e *NoopEngine) Commit()
- func (e *NoopEngine) EndOfBlock()
- func (e *NoopEngine) EndPrepareProposal([]ValidationEntry)
- func (e *NoopEngine) GetSpamStatistics(_ string) *protoapi.PoWStatistic
- func (e *NoopEngine) IsReady() bool
- func (e *NoopEngine) OnFinalize()
- func (e *NoopEngine) ProcessProposal([]abci.Tx) bool
- func (e *NoopEngine) SpamPoWDifficulty() uint32
- func (e *NoopEngine) SpamPoWHashFunction() string
- func (e *NoopEngine) SpamPoWIncreasingDifficulty() bool
- func (e *NoopEngine) SpamPoWNumberOfPastBlocks() uint32
- func (e *NoopEngine) SpamPoWNumberOfTxPerBlock() uint32
- type ValidationEntry
- type ValidationResult
Constants ¶
This section is empty.
Variables ¶
var ErrNonceAlreadyUsedByParty = errors.New("nonce already used by party")
Functions ¶
This section is empty.
Types ¶
type Config ¶
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 (*Engine) BeginBlock ¶
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) 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 ¶
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) 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 (*Engine) SpamPoWDifficulty ¶
func (*Engine) SpamPoWHashFunction ¶
func (*Engine) SpamPoWIncreasingDifficulty ¶
func (*Engine) SpamPoWNumberOfPastBlocks ¶
func (*Engine) SpamPoWNumberOfTxPerBlock ¶
func (*Engine) UpdateSpamPoWDifficulty ¶
UpdateSpamPoWDifficulty updates the network parameter for difficulty.
func (*Engine) UpdateSpamPoWHashFunction ¶
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) 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 )