Documentation ¶
Overview ¶
Package distribution implements a revenue stream that is periodically distributing collected coins between defined recipients.
Revenue instance defines recipients of an income. Coins are send to a revenue account. Upon request or configuration change collected coins are distributed between recipients. Share of the income is declared by using recipient weights. Each recipient is ensured to be paid before the configuration is changed. This means it is not possible to for example remove a recipient before distributing collected funds. Only an admin can alter a revenue configuration. It is a good idea to use a multisig contract as an admin address value.
This functionality can be used to pay validators for their work. It is a transparent and trustful way to split income.
Index ¶
- Variables
- func RegisterQuery(qr weave.QueryRouter)
- func RegisterRoutes(r weave.Registry, auth x.Authenticator, ctrl CashController)
- func RevenueAccount(revenueID []byte) weave.Address
- type CashController
- type DistributeMsg
- func (*DistributeMsg) Descriptor() ([]byte, []int)
- func (m *DistributeMsg) GetRevenueID() []byte
- func (m *DistributeMsg) Marshal() (dAtA []byte, err error)
- func (m *DistributeMsg) MarshalTo(dAtA []byte) (int, error)
- func (DistributeMsg) Path() string
- func (*DistributeMsg) ProtoMessage()
- func (m *DistributeMsg) Reset()
- func (m *DistributeMsg) Size() (n int)
- func (m *DistributeMsg) String() string
- func (m *DistributeMsg) Unmarshal(dAtA []byte) error
- func (msg *DistributeMsg) Validate() error
- func (m *DistributeMsg) XXX_DiscardUnknown()
- func (m *DistributeMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *DistributeMsg) XXX_Merge(src proto.Message)
- func (m *DistributeMsg) XXX_Size() int
- func (m *DistributeMsg) XXX_Unmarshal(b []byte) error
- type Initializer
- type NewRevenueMsg
- func (*NewRevenueMsg) Descriptor() ([]byte, []int)
- func (m *NewRevenueMsg) GetAdmin() github_com_iov_one_weave.Address
- func (m *NewRevenueMsg) GetRecipients() []*Recipient
- func (m *NewRevenueMsg) Marshal() (dAtA []byte, err error)
- func (m *NewRevenueMsg) MarshalTo(dAtA []byte) (int, error)
- func (NewRevenueMsg) Path() string
- func (*NewRevenueMsg) ProtoMessage()
- func (m *NewRevenueMsg) Reset()
- func (m *NewRevenueMsg) Size() (n int)
- func (m *NewRevenueMsg) String() string
- func (m *NewRevenueMsg) Unmarshal(dAtA []byte) error
- func (msg *NewRevenueMsg) Validate() error
- func (m *NewRevenueMsg) XXX_DiscardUnknown()
- func (m *NewRevenueMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *NewRevenueMsg) XXX_Merge(src proto.Message)
- func (m *NewRevenueMsg) XXX_Size() int
- func (m *NewRevenueMsg) XXX_Unmarshal(b []byte) error
- type Recipient
- func (*Recipient) Descriptor() ([]byte, []int)
- func (m *Recipient) GetAddress() github_com_iov_one_weave.Address
- func (m *Recipient) GetWeight() int32
- func (m *Recipient) Marshal() (dAtA []byte, err error)
- func (m *Recipient) MarshalTo(dAtA []byte) (int, error)
- func (*Recipient) ProtoMessage()
- func (m *Recipient) Reset()
- func (m *Recipient) Size() (n int)
- func (m *Recipient) String() string
- func (m *Recipient) Unmarshal(dAtA []byte) error
- func (m *Recipient) XXX_DiscardUnknown()
- func (m *Recipient) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Recipient) XXX_Merge(src proto.Message)
- func (m *Recipient) XXX_Size() int
- func (m *Recipient) XXX_Unmarshal(b []byte) error
- type ResetRevenueMsg
- func (*ResetRevenueMsg) Descriptor() ([]byte, []int)
- func (m *ResetRevenueMsg) GetRecipients() []*Recipient
- func (m *ResetRevenueMsg) GetRevenueID() []byte
- func (m *ResetRevenueMsg) Marshal() (dAtA []byte, err error)
- func (m *ResetRevenueMsg) MarshalTo(dAtA []byte) (int, error)
- func (ResetRevenueMsg) Path() string
- func (*ResetRevenueMsg) ProtoMessage()
- func (m *ResetRevenueMsg) Reset()
- func (m *ResetRevenueMsg) Size() (n int)
- func (m *ResetRevenueMsg) String() string
- func (m *ResetRevenueMsg) Unmarshal(dAtA []byte) error
- func (msg *ResetRevenueMsg) Validate() error
- func (m *ResetRevenueMsg) XXX_DiscardUnknown()
- func (m *ResetRevenueMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *ResetRevenueMsg) XXX_Merge(src proto.Message)
- func (m *ResetRevenueMsg) XXX_Size() int
- func (m *ResetRevenueMsg) XXX_Unmarshal(b []byte) error
- type Revenue
- func (rev *Revenue) Copy() orm.CloneableData
- func (*Revenue) Descriptor() ([]byte, []int)
- func (m *Revenue) GetAdmin() github_com_iov_one_weave.Address
- func (m *Revenue) GetRecipients() []*Recipient
- func (m *Revenue) Marshal() (dAtA []byte, err error)
- func (m *Revenue) MarshalTo(dAtA []byte) (int, error)
- func (*Revenue) ProtoMessage()
- func (m *Revenue) Reset()
- func (m *Revenue) Size() (n int)
- func (m *Revenue) String() string
- func (m *Revenue) Unmarshal(dAtA []byte) error
- func (rev *Revenue) Validate() error
- func (m *Revenue) XXX_DiscardUnknown()
- func (m *Revenue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Revenue) XXX_Merge(src proto.Message)
- func (m *Revenue) XXX_Size() int
- func (m *Revenue) XXX_Unmarshal(b []byte) error
- type RevenueBucket
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidLengthCodec = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowCodec = fmt.Errorf("proto: integer overflow") )
Functions ¶
func RegisterQuery ¶
func RegisterQuery(qr weave.QueryRouter)
RegisterQuery registers feedlist buckets for querying.
func RegisterRoutes ¶
func RegisterRoutes(r weave.Registry, auth x.Authenticator, ctrl CashController)
RegisterRoutes registers handlers for feedlist message processing.
func RevenueAccount ¶
RevenueAccount returns an account address that is holding funds of a revenue with given ID.
Types ¶
type CashController ¶
type CashController interface { Balance(weave.KVStore, weave.Address) (coin.Coins, error) MoveCoins(weave.KVStore, weave.Address, weave.Address, coin.Coin) error }
CashController allows to manage coins stored by the accounts without the need to directly access the bucket. Required functionality is implemented by the x/cash extension.
type DistributeMsg ¶
type DistributeMsg struct { // Revenue ID reference an ID of a revenue instance that the collected fees // should be distributed between recipients. RevenueID []byte `protobuf:"bytes,1,opt,name=revenue_id,json=revenueId,proto3" json:"revenue_id,omitempty"` }
DistributeMsg is a request to distribute all funds collected within a single revenue instance. Revenue is distributed between recipients. Request must be signed using admin key.
func (*DistributeMsg) Descriptor ¶
func (*DistributeMsg) Descriptor() ([]byte, []int)
func (*DistributeMsg) GetRevenueID ¶
func (m *DistributeMsg) GetRevenueID() []byte
func (*DistributeMsg) Marshal ¶
func (m *DistributeMsg) Marshal() (dAtA []byte, err error)
func (DistributeMsg) Path ¶
func (DistributeMsg) Path() string
func (*DistributeMsg) ProtoMessage ¶
func (*DistributeMsg) ProtoMessage()
func (*DistributeMsg) Reset ¶
func (m *DistributeMsg) Reset()
func (*DistributeMsg) Size ¶
func (m *DistributeMsg) Size() (n int)
func (*DistributeMsg) String ¶
func (m *DistributeMsg) String() string
func (*DistributeMsg) Unmarshal ¶
func (m *DistributeMsg) Unmarshal(dAtA []byte) error
func (*DistributeMsg) Validate ¶
func (msg *DistributeMsg) Validate() error
func (*DistributeMsg) XXX_DiscardUnknown ¶
func (m *DistributeMsg) XXX_DiscardUnknown()
func (*DistributeMsg) XXX_Marshal ¶
func (m *DistributeMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*DistributeMsg) XXX_Merge ¶
func (m *DistributeMsg) XXX_Merge(src proto.Message)
func (*DistributeMsg) XXX_Size ¶
func (m *DistributeMsg) XXX_Size() int
func (*DistributeMsg) XXX_Unmarshal ¶
func (m *DistributeMsg) XXX_Unmarshal(b []byte) error
type Initializer ¶
type Initializer struct{}
Initializer fulfils the Initializer interface to load data from the genesis file
func (*Initializer) FromGenesis ¶
FromGenesis will parse initial account info from genesis and save it to the database
type NewRevenueMsg ¶
type NewRevenueMsg struct { // Admin key belongs to the governance entities. It can be used to transfer // stored amount to an another account. // While not enforced it is best to use a multisig contract here. Admin github_com_iov_one_weave.Address `protobuf:"bytes,1,opt,name=admin,proto3,casttype=github.com/iov-one/weave.Address" json:"admin,omitempty"` // Recipients holds any number of addresses that the collected revenue is // distributed to. Must be at least one. Recipients []*Recipient `protobuf:"bytes,2,rep,name=recipients,proto3" json:"recipients,omitempty"` }
NewRevenueMsg is issuing the creation of a new revenue stream instance.
func (*NewRevenueMsg) Descriptor ¶
func (*NewRevenueMsg) Descriptor() ([]byte, []int)
func (*NewRevenueMsg) GetAdmin ¶
func (m *NewRevenueMsg) GetAdmin() github_com_iov_one_weave.Address
func (*NewRevenueMsg) GetRecipients ¶
func (m *NewRevenueMsg) GetRecipients() []*Recipient
func (*NewRevenueMsg) Marshal ¶
func (m *NewRevenueMsg) Marshal() (dAtA []byte, err error)
func (NewRevenueMsg) Path ¶
func (NewRevenueMsg) Path() string
func (*NewRevenueMsg) ProtoMessage ¶
func (*NewRevenueMsg) ProtoMessage()
func (*NewRevenueMsg) Reset ¶
func (m *NewRevenueMsg) Reset()
func (*NewRevenueMsg) Size ¶
func (m *NewRevenueMsg) Size() (n int)
func (*NewRevenueMsg) String ¶
func (m *NewRevenueMsg) String() string
func (*NewRevenueMsg) Unmarshal ¶
func (m *NewRevenueMsg) Unmarshal(dAtA []byte) error
func (*NewRevenueMsg) Validate ¶
func (msg *NewRevenueMsg) Validate() error
func (*NewRevenueMsg) XXX_DiscardUnknown ¶
func (m *NewRevenueMsg) XXX_DiscardUnknown()
func (*NewRevenueMsg) XXX_Marshal ¶
func (m *NewRevenueMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*NewRevenueMsg) XXX_Merge ¶
func (m *NewRevenueMsg) XXX_Merge(src proto.Message)
func (*NewRevenueMsg) XXX_Size ¶
func (m *NewRevenueMsg) XXX_Size() int
func (*NewRevenueMsg) XXX_Unmarshal ¶
func (m *NewRevenueMsg) XXX_Unmarshal(b []byte) error
type Recipient ¶
type Recipient struct { // An address that the funds should be transferred to. // This should not be the validator addresses, as the keys used to sign // blocks should never be in a wallet. This can be the wallets of the admins // of the validators. Address github_com_iov_one_weave.Address `protobuf:"bytes,1,opt,name=address,proto3,casttype=github.com/iov-one/weave.Address" json:"address,omitempty"` // Weight defines what part of the total revenue goes to this recipient. // Each recipient receives part of the total revenue amount proportional to // the weight. For example, if there are two recipients with weights 1 and 2 // accordingly, distribution will be 1/3 to the first address and 2/3 to the // second one. Weight int32 `protobuf:"varint,2,opt,name=weight,proto3" json:"weight,omitempty"` }
func (*Recipient) Descriptor ¶
func (*Recipient) GetAddress ¶
func (m *Recipient) GetAddress() github_com_iov_one_weave.Address
func (*Recipient) ProtoMessage ¶
func (*Recipient) ProtoMessage()
func (*Recipient) XXX_DiscardUnknown ¶
func (m *Recipient) XXX_DiscardUnknown()
func (*Recipient) XXX_Marshal ¶
func (*Recipient) XXX_Unmarshal ¶
type ResetRevenueMsg ¶
type ResetRevenueMsg struct { // Revenue ID reference an ID of a revenue instance that is updated. RevenueID []byte `protobuf:"bytes,1,opt,name=revenue_id,json=revenueId,proto3" json:"revenue_id,omitempty"` // Recipients holds any number of addresses that the collected revenue is // distributed to. Must be at least one. Recipients []*Recipient `protobuf:"bytes,2,rep,name=recipients,proto3" json:"recipients,omitempty"` }
ResetRevenueMsg change the configuration of a revenue instance. To assure recipients that they will receive money, every revenue update is forcing funds distribution. Before applying any change all funds stored by the revenue account are distributed using old configuration. Only when the collected revenue amount is equal to zero the change is applied.
func (*ResetRevenueMsg) Descriptor ¶
func (*ResetRevenueMsg) Descriptor() ([]byte, []int)
func (*ResetRevenueMsg) GetRecipients ¶
func (m *ResetRevenueMsg) GetRecipients() []*Recipient
func (*ResetRevenueMsg) GetRevenueID ¶
func (m *ResetRevenueMsg) GetRevenueID() []byte
func (*ResetRevenueMsg) Marshal ¶
func (m *ResetRevenueMsg) Marshal() (dAtA []byte, err error)
func (ResetRevenueMsg) Path ¶
func (ResetRevenueMsg) Path() string
func (*ResetRevenueMsg) ProtoMessage ¶
func (*ResetRevenueMsg) ProtoMessage()
func (*ResetRevenueMsg) Reset ¶
func (m *ResetRevenueMsg) Reset()
func (*ResetRevenueMsg) Size ¶
func (m *ResetRevenueMsg) Size() (n int)
func (*ResetRevenueMsg) String ¶
func (m *ResetRevenueMsg) String() string
func (*ResetRevenueMsg) Unmarshal ¶
func (m *ResetRevenueMsg) Unmarshal(dAtA []byte) error
func (*ResetRevenueMsg) Validate ¶
func (msg *ResetRevenueMsg) Validate() error
func (*ResetRevenueMsg) XXX_DiscardUnknown ¶
func (m *ResetRevenueMsg) XXX_DiscardUnknown()
func (*ResetRevenueMsg) XXX_Marshal ¶
func (m *ResetRevenueMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*ResetRevenueMsg) XXX_Merge ¶
func (m *ResetRevenueMsg) XXX_Merge(src proto.Message)
func (*ResetRevenueMsg) XXX_Size ¶
func (m *ResetRevenueMsg) XXX_Size() int
func (*ResetRevenueMsg) XXX_Unmarshal ¶
func (m *ResetRevenueMsg) XXX_Unmarshal(b []byte) error
type Revenue ¶
type Revenue struct { // Admin key belongs to the governance entities. It can be used to transfer // stored amount to an another account. // While not enforced it is best to use a multisig contract here. Admin github_com_iov_one_weave.Address `protobuf:"bytes,1,opt,name=admin,proto3,casttype=github.com/iov-one/weave.Address" json:"admin,omitempty"` // Recipients holds any number of addresses that the collected revenue is // distributed to. Must be at least one. Recipients []*Recipient `protobuf:"bytes,2,rep,name=recipients,proto3" json:"recipients,omitempty"` }
Revenue represents an account with funds collected from the fees. This is a temporary account used for storing fees that are later distributed between the owners.
func (*Revenue) Copy ¶
func (rev *Revenue) Copy() orm.CloneableData
func (*Revenue) Descriptor ¶
func (*Revenue) GetAdmin ¶
func (m *Revenue) GetAdmin() github_com_iov_one_weave.Address
func (*Revenue) GetRecipients ¶
func (*Revenue) ProtoMessage ¶
func (*Revenue) ProtoMessage()
func (*Revenue) XXX_DiscardUnknown ¶
func (m *Revenue) XXX_DiscardUnknown()
func (*Revenue) XXX_Marshal ¶
func (*Revenue) XXX_Unmarshal ¶
type RevenueBucket ¶
func NewRevenueBucket ¶
func NewRevenueBucket() *RevenueBucket
NewRevenueBucket returns a bucket for managing revenues state.
func (*RevenueBucket) Create ¶
Create adds given revenue instance to the store and returns the ID of the newly inserted entity.
func (*RevenueBucket) GetRevenue ¶
GetRevenue returns a revenue instance with given ID.