storageincentives

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2023 License: BSD-3-Clause Imports: 22 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DefaultBlocksPerRound = 152
	DefaultBlocksPerPhase = DefaultBlocksPerRound / 4
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

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

func New

func New(overlay swarm.Address, ethAddress common.Address, backend ChainBackend, logger log.Logger, monitor Monitor, contract redistribution.Contract, batchExpirer postagecontract.PostageBatchExpirer, redistributionStatuser staking.RedistributionStatuser, radius postage.Radius, sampler storage.Sampler, blockTime time.Duration, blocksPerRound, blocksPerPhase uint64, stateStore storage.StateStorer, erc20Service erc20.Service, tranService transaction.Service) (*Agent, error)

func (*Agent) Close

func (a *Agent) Close() error

func (*Agent) HasEnoughFundsToPlay added in v1.13.0

func (a *Agent) HasEnoughFundsToPlay(ctx context.Context) (*big.Int, bool, error)

func (*Agent) Metrics

func (a *Agent) Metrics() []prometheus.Collector

TODO: register metric

func (*Agent) Status added in v1.12.0

func (a *Agent) Status() (*Status, error)

Status returns the node status

type ChainBackend

type ChainBackend interface {
	BlockNumber(context.Context) (uint64, error)
	HeaderByNumber(context.Context, *big.Int) (*types.Header, error)
	BalanceAt(ctx context.Context, address common.Address, block *big.Int) (*big.Int, error)
	SuggestGasPrice(ctx context.Context) (*big.Int, error)
}

type Monitor

type Monitor interface {
	IsFullySynced() bool
}

type PhaseType

type PhaseType int

func (PhaseType) String

func (p PhaseType) String() string

type RedistributionState added in v1.12.0

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

func NewRedistributionState added in v1.12.0

func NewRedistributionState(logger log.Logger, ethAddress common.Address, stateStore storage.StateStorer, erc20Service erc20.Service, contract transaction.Service) (*RedistributionState, error)

func (*RedistributionState) AddFee added in v1.12.0

func (r *RedistributionState) AddFee(ctx context.Context, txHash common.Hash)

AddFee sets the internal node status

func (*RedistributionState) CalculateWinnerReward added in v1.12.0

func (r *RedistributionState) CalculateWinnerReward(ctx context.Context) error

CalculateWinnerReward calculates the reward for the winner

func (*RedistributionState) CommitKey added in v1.14.0

func (r *RedistributionState) CommitKey(round uint64) ([]byte, bool)

func (*RedistributionState) HasRevealed added in v1.14.0

func (r *RedistributionState) HasRevealed(round uint64) bool

func (*RedistributionState) IsFullySynced added in v1.12.0

func (r *RedistributionState) IsFullySynced(isSynced bool)

func (*RedistributionState) SampleData added in v1.14.0

func (r *RedistributionState) SampleData(round uint64) (SampleData, bool)

func (*RedistributionState) SetBalance added in v1.12.0

func (r *RedistributionState) SetBalance(ctx context.Context) error

func (*RedistributionState) SetCommitKey added in v1.14.0

func (r *RedistributionState) SetCommitKey(round uint64, commitKey []byte)

func (*RedistributionState) SetCurrentEvent added in v1.12.0

func (r *RedistributionState) SetCurrentEvent(phase PhaseType, round uint64, block uint64)

func (*RedistributionState) SetFrozen added in v1.12.0

func (r *RedistributionState) SetFrozen(isFrozen bool, round uint64)

func (*RedistributionState) SetHasRevealed added in v1.14.0

func (r *RedistributionState) SetHasRevealed(round uint64)

func (*RedistributionState) SetLastPlayedRound added in v1.12.0

func (r *RedistributionState) SetLastPlayedRound(round uint64)

func (*RedistributionState) SetLastWonRound added in v1.12.0

func (r *RedistributionState) SetLastWonRound(round uint64)

func (*RedistributionState) SetSampleData added in v1.14.0

func (r *RedistributionState) SetSampleData(round uint64, sd SampleData)

func (*RedistributionState) Status added in v1.12.0

func (r *RedistributionState) Status() (*Status, error)

Status returns the node status

type RoundData added in v1.14.0

type RoundData struct {
	CommitKey   []byte
	SampleData  *SampleData
	HasRevealed bool
}

type SampleData added in v1.14.0

type SampleData struct {
	ReserveSample storage.Sample
	StorageRadius uint8
}

type Status added in v1.12.0

type Status struct {
	Phase           PhaseType
	IsFrozen        bool
	IsFullySynced   bool
	Round           uint64
	LastWonRound    uint64
	LastPlayedRound uint64
	LastFrozenRound uint64
	Block           uint64
	Reward          *big.Int
	Fees            *big.Int
	RoundData       map[uint64]RoundData
}

Status provide internal status of the nodes in the redistribution game

func NewStatus added in v1.14.0

func NewStatus() *Status

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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