pow

package
v0.71.5 Latest Latest
Warning

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

Go to latest
Published: May 26, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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, timeService TimeService) *Engine

New instantiates the proof of work engine.

func (*Engine) BeginBlock

func (e *Engine) BeginBlock(blockHeight uint64, blockHash string)

OnBeginBlock updates the block height and block hash and clears any out of scope parameters set and states.

func (*Engine) BlockData

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

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) Commit added in v0.58.0

func (e *Engine) Commit()

func (*Engine) DeliverTx

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

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) 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) OnEpochDurationChanged added in v0.64.0

func (e *Engine) OnEpochDurationChanged(_ context.Context, duration time.Duration) error

OnEpochDurationChanged updates the ban duration as a fraction of the epoch duration.

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 EpochEngine

type EpochEngine interface {
	NotifyOnEpoch(f func(context.Context, types.Epoch), r func(context.Context, types.Epoch))
}

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) CheckTx

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

func (*NoopEngine) Commit added in v0.58.0

func (e *NoopEngine) Commit()

func (*NoopEngine) DeliverTx

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

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

type TimeService added in v0.64.0

type TimeService interface {
	GetTimeNow() time.Time
}

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