Back to

Package rewarding

Latest Go to latest

The highest tagged major version is .

Published: Apr 21, 2019 | License: Apache-2.0 | Module:



const (
	// ProtocolID is the protocol ID
	// TODO: it works only for one instance per protocol definition now
	ProtocolID = "rewarding"

func DepositGas

func DepositGas(ctx context.Context, sm protocol.StateManager, amount *big.Int, registry *protocol.Registry) error

DepositGas deposits gas into the rewarding fund

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 NewProtocol

func NewProtocol(cm protocol.ChainManager, rp *rolldpos.Protocol) *Protocol

NewProtocol instantiates a rewarding protocol instance.

func (*Protocol) AvailableBalance

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

AvailableBalance returns the available balance of the rewarding fund

func (*Protocol) BlockReward

func (p *Protocol) BlockReward(
	_ context.Context,
	sm protocol.StateManager,
) (*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,
) error

Claim claims the token from the rewarding fund

func (*Protocol) Deposit

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

Deposit deposits token into the rewarding fund

func (*Protocol) EpochReward

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

EpochReward returns the epoch reward amount

func (*Protocol) FoundationBonus

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

FoundationBonus returns the foundation bonus amount

func (*Protocol) FoundationBonusLastEpoch

func (p *Protocol) FoundationBonusLastEpoch(_ context.Context, sm protocol.StateManager) (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

func (p *Protocol) Handle(
	ctx context.Context,
	act action.Action,
	sm protocol.StateManager,
) (*action.Receipt, error)

Handle handles the actions on the rewarding protocol

func (*Protocol) Initialize

func (p *Protocol) Initialize(
	ctx context.Context,
	sm protocol.StateManager,
	initBalance *big.Int,
	blockReward *big.Int,
	epochReward *big.Int,
	numDelegatesForEpochReward uint64,
	exemptAddrs []address.Address,
	foundationBonus *big.Int,
	numDelegatesForFoundationBonus uint64,
	foundationBonusLastEpoch uint64,
	productivityThreshold uint64,
) error

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

func (*Protocol) NumDelegatesForEpochReward

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

NumDelegatesForEpochReward returns the number of candidates sharing an epoch reward

func (*Protocol) NumDelegatesForFoundationBonus

func (p *Protocol) NumDelegatesForFoundationBonus(_ context.Context, sm protocol.StateManager) (uint64, error)

NumDelegatesForFoundationBonus returns the number of delegates that will get foundation bonus

func (*Protocol) ProductivityThreshold

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

ProductivityThreshold returns the productivity threshold

func (*Protocol) ReadState

func (p *Protocol) ReadState(
	ctx context.Context,
	sm protocol.StateManager,
	method []byte,
	args ...[]byte,
) ([]byte, error)

ReadState read the state on blockchain via protocol

func (*Protocol) TotalBalance

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

TotalBalance returns the total balance of the rewarding fund

func (*Protocol) UnclaimedBalance

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

UnclaimedBalance returns unclaimed balance of a given address

func (*Protocol) Validate

func (p *Protocol) Validate(
	ctx context.Context,
	act action.Action,
) error

Validate validates the actions on the rewarding protocol

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier