rewarding

package
v2.1.0-rc19 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DepositGas

func DepositGas(ctx context.Context, sm protocol.StateManager, amount *big.Int, opts ...protocol.DepositOption) ([]*action.TransactionLog, error)

DepositGas deposits gas into the rewarding fund

func ProtocolAddr

func ProtocolAddr() address.Address

ProtocolAddr returns the address generated from protocol id

func UnmarshalRewardLog

func UnmarshalRewardLog(data []byte) (*rewardingpb.RewardLogs, error)

UnmarshalRewardLog unmarshals reward log from byte slice it keep the compatibility with old reward log

Types

type Protocol

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

Protocol defines the protocol of the rewarding fund and the rewarding process. It allows the admin to config the reward amount, users to donate tokens to the fund, block producers to grant them block and epoch reward and, beneficiaries to claim the balance into their personal account.

func FindProtocol

func FindProtocol(registry *protocol.Registry) *Protocol

FindProtocol finds the registered protocol from registry

func NewProtocol

func NewProtocol(cfg genesis.Rewarding) *Protocol

NewProtocol instantiates a rewarding protocol instance.

func (*Protocol) AvailableBalance

func (p *Protocol) AvailableBalance(
	ctx context.Context,
	sm protocol.StateReader,
) (*big.Int, uint64, error)

AvailableBalance returns the available balance of the rewarding fund

func (*Protocol) BlockReward

func (p *Protocol) BlockReward(
	ctx context.Context,
	sm protocol.StateReader,
) (*big.Int, error)

BlockReward returns the block reward amount

func (*Protocol) Claim

func (p *Protocol) Claim(
	ctx context.Context,
	sm protocol.StateManager,
	amount *big.Int,
	claimFrom address.Address,
) (*action.TransactionLog, error)

Claim claims the token from the rewarding fund

func (*Protocol) CreateGenesisStates

func (p *Protocol) CreateGenesisStates(
	ctx context.Context,
	sm protocol.StateManager,
) error

CreateGenesisStates initializes the rewarding protocol by setting the original admin, block and epoch reward

func (*Protocol) CreatePostSystemActions

func (p *Protocol) CreatePostSystemActions(ctx context.Context, _ protocol.StateReader) ([]action.Envelope, error)

CreatePostSystemActions creates a list of system actions to be appended to block actions

func (*Protocol) CreatePreStates

func (p *Protocol) CreatePreStates(ctx context.Context, sm protocol.StateManager) error

CreatePreStates updates state manager

func (*Protocol) Deposit

func (p *Protocol) Deposit(
	ctx context.Context,
	sm protocol.StateManager,
	amount *big.Int,
	transactionLogType iotextypes.TransactionLogType,
) ([]*action.TransactionLog, error)

Deposit deposits token into the rewarding fund

func (*Protocol) EpochReward

func (p *Protocol) EpochReward(
	ctx context.Context,
	sm protocol.StateReader,
) (*big.Int, error)

EpochReward returns the epoch reward amount

func (*Protocol) ForceRegister

func (p *Protocol) ForceRegister(r *protocol.Registry) error

ForceRegister registers the protocol with a unique ID and force replacing the previous protocol if it exists

func (*Protocol) FoundationBonus

func (p *Protocol) FoundationBonus(ctx context.Context, sm protocol.StateReader) (*big.Int, error)

FoundationBonus returns the foundation bonus amount

func (*Protocol) FoundationBonusLastEpoch

func (p *Protocol) FoundationBonusLastEpoch(ctx context.Context, sm protocol.StateReader) (uint64, error)

FoundationBonusLastEpoch returns the last epoch when the foundation bonus will still be granted

func (*Protocol) GrantBlockReward

func (p *Protocol) GrantBlockReward(
	ctx context.Context,
	sm protocol.StateManager,
) (*action.Log, error)

GrantBlockReward grants the block reward (token) to the block producer

func (*Protocol) GrantEpochReward

func (p *Protocol) GrantEpochReward(
	ctx context.Context,
	sm protocol.StateManager,
) ([]*action.Log, error)

GrantEpochReward grants the epoch reward (token) to all beneficiaries of a epoch

func (*Protocol) Handle

Handle handles the actions on the rewarding protocol

func (*Protocol) Name

func (p *Protocol) Name() string

Name returns the name of protocol

func (*Protocol) NumDelegatesForEpochReward

func (p *Protocol) NumDelegatesForEpochReward(
	ctx context.Context,
	sm protocol.StateManager,
) (uint64, error)

NumDelegatesForEpochReward returns the number of candidates sharing an epoch reward

func (*Protocol) NumDelegatesForFoundationBonus

func (p *Protocol) NumDelegatesForFoundationBonus(ctx context.Context, sm protocol.StateReader) (uint64, error)

NumDelegatesForFoundationBonus returns the number of delegates that will get foundation bonus

func (*Protocol) ProductivityThreshold

func (p *Protocol) ProductivityThreshold(ctx context.Context, sm protocol.StateManager) (uint64, error)

ProductivityThreshold returns the productivity threshold

func (*Protocol) ReadState

func (p *Protocol) ReadState(
	ctx context.Context,
	sr protocol.StateReader,
	method []byte,
	args ...[]byte,
) ([]byte, uint64, error)

ReadState read the state on blockchain via protocol

func (*Protocol) Register

func (p *Protocol) Register(r *protocol.Registry) error

Register registers the protocol with a unique ID

func (*Protocol) SetReward

func (p *Protocol) SetReward(
	ctx context.Context,
	sm protocol.StateManager,
	amount *big.Int,
	blockLevel bool,
) error

SetReward updates block or epoch reward amount

func (*Protocol) TotalBalance

func (p *Protocol) TotalBalance(
	ctx context.Context,
	sm protocol.StateReader,
) (*big.Int, uint64, error)

TotalBalance returns the total balance of the rewarding fund

func (*Protocol) UnclaimedBalance

func (p *Protocol) UnclaimedBalance(
	ctx context.Context,
	sm protocol.StateReader,
	addr address.Address,
) (*big.Int, uint64, error)

UnclaimedBalance returns unclaimed balance of a given address

func (*Protocol) Validate

func (p *Protocol) Validate(ctx context.Context, elp action.Envelope, sr protocol.StateReader) error

Validate validates a reward action

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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