Documentation ¶
Index ¶
- Variables
- type Config
- type Engine
- func (e *Engine) BeginBlock(blockHeight uint64, blockHash string)
- func (e *Engine) BlockData() (uint64, string)
- func (e *Engine) CheckTx(tx abci.Tx) error
- func (e *Engine) Commit()
- func (e *Engine) DeliverTx(tx abci.Tx) error
- func (e *Engine) DisableVerification()
- func (e *Engine) EndOfBlock()
- 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) OnEpochDurationChanged(_ context.Context, duration time.Duration) error
- 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 EpochEngine
- type NoopEngine
- func (e *NoopEngine) BeginBlock(blockHeight uint64, blockHash string)
- func (e *NoopEngine) BlockData() (uint64, string)
- func (e *NoopEngine) CheckTx(tx abci.Tx) error
- func (e *NoopEngine) Commit()
- func (e *NoopEngine) DeliverTx(tx abci.Tx) error
- func (e *NoopEngine) EndOfBlock()
- func (e *NoopEngine) GetSpamStatistics(_ string) *protoapi.PoWStatistic
- func (e *NoopEngine) IsReady() 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 TimeService
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 New ¶
func New(log *logging.Logger, config Config, timeService TimeService) *Engine
New instantiates the proof of work engine.
func (*Engine) BeginBlock ¶
OnBeginBlock updates the block height and block hash and clears any out of scope parameters set and states.
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) DeliverTx ¶
DeliverTx is called by deliverTx in the abci and verifies the proof of work, takes a not of the transaction id and counts the number of transactions of the party in the block.
func (*Engine) DisableVerification ¶ added in v0.73.0
func (e *Engine) DisableVerification()
func (*Engine) EndOfBlock ¶
func (e *Engine) EndOfBlock()
EndOfBlock clears up block data structures at the end of the 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) OnEpochDurationChanged ¶ added in v0.64.0
OnEpochDurationChanged updates the ban duration as a fraction of the epoch duration.
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 EpochEngine ¶
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)
func (*NoopEngine) BlockData ¶
func (e *NoopEngine) BlockData() (uint64, string)
func (*NoopEngine) Commit ¶ added in v0.58.0
func (e *NoopEngine) Commit()
func (*NoopEngine) EndOfBlock ¶
func (e *NoopEngine) EndOfBlock()
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) 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