Documentation ¶
Index ¶
- 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) DeliverTx(tx abci.Tx) error
- func (e *Engine) EndOfBlock()
- func (e *Engine) GetState(k string) ([]byte, []types.StateProvider, error)
- func (e *Engine) HasChanged(k string) bool
- 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) OnEpochEvent(ctx context.Context, epoch types.Epoch)
- func (e *Engine) OnEpochRestore(ctx context.Context, epoch types.Epoch)
- 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) DeliverTx(tx abci.Tx) error
- func (e *NoopEngine) EndOfBlock()
- 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
Constants ¶
This section is empty.
Variables ¶
This section is empty.
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, epochEngine EpochEngine) *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) EndOfBlock ¶
func (e *Engine) EndOfBlock()
EndOfBlock clears up block data structures at the end of the block.
func (*Engine) HasChanged ¶
func (*Engine) Namespace ¶
func (e *Engine) Namespace() types.SnapshotNamespace
func (*Engine) OnEpochEvent ¶
OnEpochEvent is called on epoch events. It only cares about new epoch events.
func (*Engine) OnEpochRestore ¶
OnEpochRestore is called when we restore the epoch from snapshot.
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) EndOfBlock ¶
func (e *NoopEngine) EndOfBlock()
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