Documentation ¶
Index ¶
- func DepositGas(ctx context.Context, sm protocol.StateManager, amount *big.Int) error
- type Productivity
- type Protocol
- func (p *Protocol) AvailableBalance(ctx context.Context, sm protocol.StateReader) (*big.Int, error)
- func (p *Protocol) BlockReward(_ context.Context, sm protocol.StateReader) (*big.Int, error)
- func (p *Protocol) Claim(ctx context.Context, sm protocol.StateManager, amount *big.Int) error
- func (p *Protocol) CreateGenesisStates(ctx context.Context, sm protocol.StateManager) error
- func (p *Protocol) CreatePostSystemActions(ctx context.Context, _ protocol.StateReader) ([]action.Envelope, error)
- func (p *Protocol) CreatePreStates(ctx context.Context, sm protocol.StateManager) error
- func (p *Protocol) Deposit(ctx context.Context, sm protocol.StateManager, amount *big.Int) error
- func (p *Protocol) EpochReward(_ context.Context, sm protocol.StateReader) (*big.Int, error)
- func (p *Protocol) ForceRegister(r *protocol.Registry) error
- func (p *Protocol) FoundationBonus(_ context.Context, sm protocol.StateReader) (*big.Int, error)
- func (p *Protocol) FoundationBonusLastEpoch(_ context.Context, sm protocol.StateReader) (uint64, error)
- func (p *Protocol) GrantBlockReward(ctx context.Context, sm protocol.StateManager) (*action.Log, error)
- func (p *Protocol) GrantEpochReward(ctx context.Context, sm protocol.StateManager) ([]*action.Log, error)
- func (p *Protocol) Handle(ctx context.Context, act action.Action, sm protocol.StateManager) (*action.Receipt, error)
- func (p *Protocol) Name() string
- func (p *Protocol) NumDelegatesForEpochReward(_ context.Context, sm protocol.StateManager) (uint64, error)
- func (p *Protocol) NumDelegatesForFoundationBonus(_ context.Context, sm protocol.StateReader) (uint64, error)
- func (p *Protocol) ProductivityThreshold(_ context.Context, sm protocol.StateManager) (uint64, error)
- func (p *Protocol) ReadState(ctx context.Context, sr protocol.StateReader, method []byte, args ...[]byte) ([]byte, error)
- func (p *Protocol) Register(r *protocol.Registry) error
- func (p *Protocol) SetReward(ctx context.Context, sm protocol.StateManager, amount *big.Int, ...) error
- func (p *Protocol) TotalBalance(ctx context.Context, sm protocol.StateReader) (*big.Int, error)
- func (p *Protocol) UnclaimedBalance(ctx context.Context, sm protocol.StateReader, addr address.Address) (*big.Int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DepositGas ¶ added in v0.5.0
DepositGas deposits gas into the rewarding fund
Types ¶
type Productivity ¶ added in v1.0.0
Productivity returns the number of produced blocks per producer
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 ¶ added in v0.11.0
FindProtocol finds the registered protocol from registry
func NewProtocol ¶
func NewProtocol( productivity Productivity, foundationBonusP2Start uint64, foundationBonusP2End uint64, ) *Protocol
NewProtocol instantiates a rewarding protocol instance.
func (*Protocol) AvailableBalance ¶
func (p *Protocol) AvailableBalance( ctx context.Context, sm protocol.StateReader, ) (*big.Int, error)
AvailableBalance returns the available balance of the rewarding fund
func (*Protocol) BlockReward ¶
BlockReward returns the block reward amount
func (*Protocol) CreateGenesisStates ¶ added in v0.11.0
CreateGenesisStates initializes the rewarding protocol by setting the original admin, block and epoch reward
func (*Protocol) CreatePostSystemActions ¶ added in v0.11.0
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 ¶ added in v0.11.0
CreatePreStates updates state manager
func (*Protocol) EpochReward ¶
EpochReward returns the epoch reward amount
func (*Protocol) ForceRegister ¶ added in v0.11.0
ForceRegister registers the protocol with a unique ID and force replacing the previous protocol if it exists
func (*Protocol) FoundationBonus ¶ added in v0.5.0
FoundationBonus returns the foundation bonus amount
func (*Protocol) FoundationBonusLastEpoch ¶ added in v0.5.0
func (p *Protocol) FoundationBonusLastEpoch(_ 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 ¶
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) NumDelegatesForEpochReward ¶ added in v0.5.0
func (p *Protocol) NumDelegatesForEpochReward( _ context.Context, sm protocol.StateManager, ) (uint64, error)
NumDelegatesForEpochReward returns the number of candidates sharing an epoch reward
func (*Protocol) NumDelegatesForFoundationBonus ¶ added in v0.5.0
func (p *Protocol) NumDelegatesForFoundationBonus(_ context.Context, sm protocol.StateReader) (uint64, error)
NumDelegatesForFoundationBonus returns the number of delegates that will get foundation bonus
func (*Protocol) ProductivityThreshold ¶ added in v0.5.0
func (p *Protocol) ProductivityThreshold(_ context.Context, sm protocol.StateManager) (uint64, error)
ProductivityThreshold returns the productivity threshold
func (*Protocol) ReadState ¶ added in v0.5.0
func (p *Protocol) ReadState( ctx context.Context, sr protocol.StateReader, method []byte, args ...[]byte, ) ([]byte, error)
ReadState read the state on blockchain via protocol
func (*Protocol) SetReward ¶ added in v0.7.1
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 ¶
TotalBalance returns the total balance of the rewarding fund