Documentation ¶
Index ¶
- Constants
- type ClaimFromRewardingFund
- func (c *ClaimFromRewardingFund) Amount() *big.Int
- func (c *ClaimFromRewardingFund) ByteStream() []byte
- func (c *ClaimFromRewardingFund) Cost() (*big.Int, error)
- func (c *ClaimFromRewardingFund) Data() []byte
- func (c *ClaimFromRewardingFund) IntrinsicGas() (uint64, error)
- func (c *ClaimFromRewardingFund) LoadProto(claim *iproto.ClaimFromRewardingFund) error
- func (c *ClaimFromRewardingFund) Proto() *iproto.ClaimFromRewardingFund
- type ClaimFromRewardingFundBuilder
- type DonateToRewardingFund
- func (d *DonateToRewardingFund) Amount() *big.Int
- func (d *DonateToRewardingFund) ByteStream() []byte
- func (d *DonateToRewardingFund) Cost() (*big.Int, error)
- func (d *DonateToRewardingFund) Data() []byte
- func (d *DonateToRewardingFund) IntrinsicGas() (uint64, error)
- func (d *DonateToRewardingFund) LoadProto(donate *iproto.DepositToRewardingFund) error
- func (d *DonateToRewardingFund) Proto() *iproto.DepositToRewardingFund
- type DonateToRewardingFundBuilder
- type GrantReward
- type GrantRewardBuilder
- type Protocol
- func (p *Protocol) Admin(_ context.Context, sm protocol.StateManager) (address.Address, error)
- func (p *Protocol) AvailableBalance(ctx context.Context, sm protocol.StateManager) (*big.Int, error)
- func (p *Protocol) BlockReward(_ context.Context, sm protocol.StateManager) (*big.Int, error)
- func (p *Protocol) Claim(ctx context.Context, sm protocol.StateManager, amount *big.Int) error
- func (p *Protocol) Donate(ctx context.Context, sm protocol.StateManager, amount *big.Int) error
- func (p *Protocol) EpochReward(_ context.Context, sm protocol.StateManager) (*big.Int, error)
- func (p *Protocol) GrantBlockReward(ctx context.Context, sm protocol.StateManager) error
- func (p *Protocol) GrantEpochReward(ctx context.Context, sm protocol.StateManager) error
- func (p *Protocol) Handle(ctx context.Context, act action.Action, sm protocol.StateManager) (*action.Receipt, error)
- func (p *Protocol) Initialize(ctx context.Context, sm protocol.StateManager, blockReward *big.Int, ...) error
- func (p *Protocol) SetAdmin(ctx context.Context, sm protocol.StateManager, addr address.Address) error
- func (p *Protocol) SetBlockReward(ctx context.Context, sm protocol.StateManager, amount *big.Int) error
- func (p *Protocol) SetEpochReward(ctx context.Context, sm protocol.StateManager, amount *big.Int) error
- func (p *Protocol) TotalBalance(ctx context.Context, sm protocol.StateManager) (*big.Int, error)
- func (p *Protocol) UnclaimedBalance(ctx context.Context, sm protocol.StateManager, addr address.Address) (*big.Int, error)
- func (p *Protocol) Validate(ctx context.Context, act action.Action) error
- type SetReward
- func (s *SetReward) Amount() *big.Int
- func (s *SetReward) ByteStream() []byte
- func (s *SetReward) Cost() (*big.Int, error)
- func (s *SetReward) Data() []byte
- func (s *SetReward) IntrinsicGas() (uint64, error)
- func (s *SetReward) LoadProto(sProto *iproto.SetReward) error
- func (s *SetReward) Proto() *iproto.SetReward
- func (s *SetReward) RewardType() int
- type SetRewardBuilder
Constants ¶
const ( // BlockReward indicates that the action is to grant block reward BlockReward = iota // EpochReward indicates that the action is to grant epoch reward EpochReward )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClaimFromRewardingFund ¶
type ClaimFromRewardingFund struct { action.AbstractAction // contains filtered or unexported fields }
ClaimFromRewardingFund is the action to claim reward from the rewarding fund
func (*ClaimFromRewardingFund) Amount ¶
func (c *ClaimFromRewardingFund) Amount() *big.Int
Amount returns the amount to claim
func (*ClaimFromRewardingFund) ByteStream ¶
func (c *ClaimFromRewardingFund) ByteStream() []byte
ByteStream returns a raw byte stream of a claim action
func (*ClaimFromRewardingFund) Cost ¶
func (c *ClaimFromRewardingFund) Cost() (*big.Int, error)
Cost returns the total cost of a claim action
func (*ClaimFromRewardingFund) Data ¶
func (c *ClaimFromRewardingFund) Data() []byte
Data returns the additional data
func (*ClaimFromRewardingFund) IntrinsicGas ¶
func (c *ClaimFromRewardingFund) IntrinsicGas() (uint64, error)
IntrinsicGas returns the intrinsic gas of a claim action
func (*ClaimFromRewardingFund) LoadProto ¶
func (c *ClaimFromRewardingFund) LoadProto(claim *iproto.ClaimFromRewardingFund) error
LoadProto converts a claim action protobuf to a claim action struct
func (*ClaimFromRewardingFund) Proto ¶
func (c *ClaimFromRewardingFund) Proto() *iproto.ClaimFromRewardingFund
Proto converts a claim action struct to a claim action protobuf
type ClaimFromRewardingFundBuilder ¶
type ClaimFromRewardingFundBuilder struct { action.Builder // contains filtered or unexported fields }
ClaimFromRewardingFundBuilder is the struct to build ClaimFromRewardingFund
func (*ClaimFromRewardingFundBuilder) Build ¶
func (b *ClaimFromRewardingFundBuilder) Build() ClaimFromRewardingFund
Build builds a new claim from rewarding fund action
func (*ClaimFromRewardingFundBuilder) SetAmount ¶
func (b *ClaimFromRewardingFundBuilder) SetAmount(amount *big.Int) *ClaimFromRewardingFundBuilder
SetAmount sets the amount to claim
func (*ClaimFromRewardingFundBuilder) SetData ¶
func (b *ClaimFromRewardingFundBuilder) SetData(data []byte) *ClaimFromRewardingFundBuilder
SetData sets the additional data
type DonateToRewardingFund ¶
type DonateToRewardingFund struct { action.AbstractAction // contains filtered or unexported fields }
DonateToRewardingFund is the action to donate to the rewarding fund
func (*DonateToRewardingFund) Amount ¶
func (d *DonateToRewardingFund) Amount() *big.Int
Amount returns the amount to donate
func (*DonateToRewardingFund) ByteStream ¶
func (d *DonateToRewardingFund) ByteStream() []byte
ByteStream returns a raw byte stream of a donate action
func (*DonateToRewardingFund) Cost ¶
func (d *DonateToRewardingFund) Cost() (*big.Int, error)
Cost returns the total cost of a donate action
func (*DonateToRewardingFund) Data ¶
func (d *DonateToRewardingFund) Data() []byte
Data returns the additional data
func (*DonateToRewardingFund) IntrinsicGas ¶
func (d *DonateToRewardingFund) IntrinsicGas() (uint64, error)
IntrinsicGas returns the intrinsic gas of a donate action
func (*DonateToRewardingFund) LoadProto ¶
func (d *DonateToRewardingFund) LoadProto(donate *iproto.DepositToRewardingFund) error
LoadProto converts a donate action protobuf to a donate action struct
func (*DonateToRewardingFund) Proto ¶
func (d *DonateToRewardingFund) Proto() *iproto.DepositToRewardingFund
Proto converts a donate action struct to a donate action protobuf
type DonateToRewardingFundBuilder ¶
type DonateToRewardingFundBuilder struct { action.Builder // contains filtered or unexported fields }
DonateToRewardingFundBuilder is the struct to build DonateToRewardingFund
func (*DonateToRewardingFundBuilder) Build ¶
func (b *DonateToRewardingFundBuilder) Build() DonateToRewardingFund
Build builds a new donate to rewarding fund action
func (*DonateToRewardingFundBuilder) SetAmount ¶
func (b *DonateToRewardingFundBuilder) SetAmount(amount *big.Int) *DonateToRewardingFundBuilder
SetAmount sets the amount to donate
func (*DonateToRewardingFundBuilder) SetData ¶
func (b *DonateToRewardingFundBuilder) SetData(data []byte) *DonateToRewardingFundBuilder
SetData sets the additional data
type GrantReward ¶
type GrantReward struct { action.AbstractAction // contains filtered or unexported fields }
GrantReward is the action to grant either block or epoch reward
func (*GrantReward) ByteStream ¶
func (g *GrantReward) ByteStream() []byte
ByteStream returns a raw byte stream of a grant reward action
func (*GrantReward) Cost ¶
func (*GrantReward) Cost() (*big.Int, error)
Cost returns the total cost of a grant reward action
func (*GrantReward) IntrinsicGas ¶
func (*GrantReward) IntrinsicGas() (uint64, error)
IntrinsicGas returns the intrinsic gas of a grant reward action, which is 0
func (*GrantReward) LoadProto ¶
func (g *GrantReward) LoadProto(gProto *iproto.GrantReward) error
LoadProto converts a grant reward action protobuf to a grant reward action struct
func (*GrantReward) Proto ¶
func (g *GrantReward) Proto() *iproto.GrantReward
Proto converts a grant reward action struct to a grant reward action protobuf
func (*GrantReward) RewardType ¶
func (g *GrantReward) RewardType() int
RewardType returns the grant reward type
type GrantRewardBuilder ¶
GrantRewardBuilder is the struct to build GrantReward
func (*GrantRewardBuilder) Build ¶
func (b *GrantRewardBuilder) Build() GrantReward
Build builds a new grant reward action
func (*GrantRewardBuilder) SetRewardType ¶
func (b *GrantRewardBuilder) SetRewardType(t int) *GrantRewardBuilder
SetRewardType sets the grant reward type
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 ¶
NewProtocol instantiates a rewarding protocol instance. The address of the protocol is defined by the creator's address and the nonce of creating it
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 ¶
BlockReward returns the block reward amount
func (*Protocol) EpochReward ¶
EpochReward returns the epoch reward amount
func (*Protocol) GrantBlockReward ¶
GrantBlockReward grants the block reward (token) to the block producer
func (*Protocol) GrantEpochReward ¶
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, blockReward *big.Int, epochReward *big.Int, ) error
Initialize initializes the rewarding protocol by setting the original admin, block and epoch reward
func (*Protocol) SetAdmin ¶
func (p *Protocol) SetAdmin( ctx context.Context, sm protocol.StateManager, addr address.Address, ) error
SetAdmin sets a new admin address. Only the current admin could make this change
func (*Protocol) SetBlockReward ¶
func (p *Protocol) SetBlockReward( ctx context.Context, sm protocol.StateManager, amount *big.Int, ) error
SetBlockReward sets the block reward amount for the block rewarding. Only the current admin could make this change
func (*Protocol) SetEpochReward ¶
func (p *Protocol) SetEpochReward( ctx context.Context, sm protocol.StateManager, amount *big.Int, ) error
SetEpochReward sets the epoch reward amount shared by all beneficiaries in an epoch. Only the current admin could make this change
func (*Protocol) TotalBalance ¶
TotalBalance returns the total balance of the rewarding fund
type SetReward ¶
type SetReward struct { action.AbstractAction // contains filtered or unexported fields }
SetReward is the action to update the reward amount
func (*SetReward) ByteStream ¶
ByteStream returns a raw byte stream of a set reward action
func (*SetReward) IntrinsicGas ¶
IntrinsicGas returns the intrinsic gas of a set reward action
func (*SetReward) LoadProto ¶
LoadProto converts a set block rewarding reward action protobuf to a set reward action struct
func (*SetReward) Proto ¶
func (s *SetReward) Proto() *iproto.SetReward
Proto converts a set reward action struct to a set reward action protobuf
func (*SetReward) RewardType ¶
RewardType returns the grant reward type
type SetRewardBuilder ¶
SetRewardBuilder is the struct to build SetReward
func (*SetRewardBuilder) Build ¶
func (b *SetRewardBuilder) Build() SetReward
Build builds a new set reward action
func (*SetRewardBuilder) SetAmount ¶
func (b *SetRewardBuilder) SetAmount(amount *big.Int) *SetRewardBuilder
SetAmount sets the amount to reward
func (*SetRewardBuilder) SetData ¶
func (b *SetRewardBuilder) SetData(data []byte) *SetRewardBuilder
SetData sets the additional data
func (*SetRewardBuilder) SetRewardType ¶
func (b *SetRewardBuilder) SetRewardType(t int) *SetRewardBuilder
SetRewardType sets the grant reward type