rewarding

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2019 License: Apache-2.0 Imports: 17 Imported by: 12

Documentation

Index

Constants

View Source
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

Build builds a new claim from rewarding fund action

func (*ClaimFromRewardingFundBuilder) SetAmount

SetAmount sets the amount to claim

func (*ClaimFromRewardingFundBuilder) SetData

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

Build builds a new donate to rewarding fund action

func (*DonateToRewardingFundBuilder) SetAmount

SetAmount sets the amount to donate

func (*DonateToRewardingFundBuilder) SetData

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

type GrantRewardBuilder struct {
	action.Builder
	// contains filtered or unexported fields
}

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

func NewProtocol(caller address.Address, nonce uint64) *Protocol

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) Admin

Admin returns the address of current admin

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) Donate

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

Donate donates 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) GrantBlockReward

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

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

func (*Protocol) GrantEpochReward

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

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

type SetReward

type SetReward struct {
	action.AbstractAction
	// contains filtered or unexported fields
}

SetReward is the action to update the reward amount

func (*SetReward) Amount

func (s *SetReward) Amount() *big.Int

Amount returns the amount to reward

func (*SetReward) ByteStream

func (s *SetReward) ByteStream() []byte

ByteStream returns a raw byte stream of a set reward action

func (*SetReward) Cost

func (s *SetReward) Cost() (*big.Int, error)

Cost returns the total cost of a set reward action

func (*SetReward) Data

func (s *SetReward) Data() []byte

Data returns the additional data

func (*SetReward) IntrinsicGas

func (s *SetReward) IntrinsicGas() (uint64, error)

IntrinsicGas returns the intrinsic gas of a set reward action

func (*SetReward) LoadProto

func (s *SetReward) LoadProto(sProto *iproto.SetReward) error

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

func (s *SetReward) RewardType() int

RewardType returns the grant reward type

type SetRewardBuilder

type SetRewardBuilder struct {
	action.Builder
	// contains filtered or unexported fields
}

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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