Documentation ¶
Overview ¶
Package distribution implements a revenue stream that is periodically distributing collected coins between defined destinations.
Revenue instance defines destinations of an income. Coins are send to a revenue account. Upon request or configuration change collected coins are distributed between destinations. Share of the income is declared by using destination weights. Each destination is ensured to be paid before the configuration is changed. This means it is not possible to for example remove a destination 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 NewRevenueBucket() orm.ModelBucket
- func RegisterQuery(qr weave.QueryRouter)
- func RegisterRoutes(r weave.Registry, auth x.Authenticator, ctrl CashController)
- func RevenueAccount(key []byte) weave.Address
- type CashController
- type CreateMsg
- func (*CreateMsg) Descriptor() ([]byte, []int)
- func (m *CreateMsg) GetAdmin() github_com_iov_one_weave.Address
- func (m *CreateMsg) GetDestinations() []*Destination
- func (m *CreateMsg) GetMetadata() *weave.Metadata
- func (m *CreateMsg) Marshal() (dAtA []byte, err error)
- func (m *CreateMsg) MarshalTo(dAtA []byte) (int, error)
- func (CreateMsg) Path() string
- func (*CreateMsg) ProtoMessage()
- func (m *CreateMsg) Reset()
- func (m *CreateMsg) Size() (n int)
- func (m *CreateMsg) String() string
- func (m *CreateMsg) Unmarshal(dAtA []byte) error
- func (msg *CreateMsg) Validate() error
- func (m *CreateMsg) XXX_DiscardUnknown()
- func (m *CreateMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *CreateMsg) XXX_Merge(src proto.Message)
- func (m *CreateMsg) XXX_Size() int
- func (m *CreateMsg) XXX_Unmarshal(b []byte) error
- type Destination
- func (*Destination) Descriptor() ([]byte, []int)
- func (m *Destination) GetAddress() github_com_iov_one_weave.Address
- func (m *Destination) GetWeight() int32
- func (m *Destination) Marshal() (dAtA []byte, err error)
- func (m *Destination) MarshalTo(dAtA []byte) (int, error)
- func (*Destination) ProtoMessage()
- func (m *Destination) Reset()
- func (m *Destination) Size() (n int)
- func (m *Destination) String() string
- func (m *Destination) Unmarshal(dAtA []byte) error
- func (m *Destination) XXX_DiscardUnknown()
- func (m *Destination) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Destination) XXX_Merge(src proto.Message)
- func (m *Destination) XXX_Size() int
- func (m *Destination) XXX_Unmarshal(b []byte) error
- type DistributeMsg
- func (*DistributeMsg) Descriptor() ([]byte, []int)
- func (m *DistributeMsg) GetMetadata() *weave.Metadata
- 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 ResetMsg
- func (*ResetMsg) Descriptor() ([]byte, []int)
- func (m *ResetMsg) GetDestinations() []*Destination
- func (m *ResetMsg) GetMetadata() *weave.Metadata
- func (m *ResetMsg) GetRevenueID() []byte
- func (m *ResetMsg) Marshal() (dAtA []byte, err error)
- func (m *ResetMsg) MarshalTo(dAtA []byte) (int, error)
- func (ResetMsg) Path() string
- func (*ResetMsg) ProtoMessage()
- func (m *ResetMsg) Reset()
- func (m *ResetMsg) Size() (n int)
- func (m *ResetMsg) String() string
- func (m *ResetMsg) Unmarshal(dAtA []byte) error
- func (msg *ResetMsg) Validate() error
- func (m *ResetMsg) XXX_DiscardUnknown()
- func (m *ResetMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *ResetMsg) XXX_Merge(src proto.Message)
- func (m *ResetMsg) XXX_Size() int
- func (m *ResetMsg) XXX_Unmarshal(b []byte) error
- type Revenue
- func (*Revenue) Descriptor() ([]byte, []int)
- func (m *Revenue) GetAddress() github_com_iov_one_weave.Address
- func (m *Revenue) GetAdmin() github_com_iov_one_weave.Address
- func (m *Revenue) GetDestinations() []*Destination
- func (m *Revenue) GetMetadata() *weave.Metadata
- 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
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidLengthCodec = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowCodec = fmt.Errorf("proto: integer overflow") )
Functions ¶
func NewRevenueBucket ¶
func NewRevenueBucket() orm.ModelBucket
NewRevenueBucket returns a bucket for managing revenues state.
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 ¶
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 CreateMsg ¶ added in v0.17.0
type CreateMsg struct { Metadata *weave.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"` // 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,2,opt,name=admin,proto3,casttype=github.com/iov-one/weave.Address" json:"admin,omitempty"` // Destinations holds any number of addresses that the collected revenue is // distributed to. Must be at least one. Destinations []*Destination `protobuf:"bytes,3,rep,name=destinations,proto3" json:"destinations,omitempty"` }
CreateMsg is issuing the creation of a new revenue stream instance.
func (*CreateMsg) Descriptor ¶ added in v0.17.0
func (*CreateMsg) GetAdmin ¶ added in v0.17.0
func (m *CreateMsg) GetAdmin() github_com_iov_one_weave.Address
func (*CreateMsg) GetDestinations ¶ added in v0.18.0
func (m *CreateMsg) GetDestinations() []*Destination
func (*CreateMsg) GetMetadata ¶ added in v0.17.0
func (*CreateMsg) ProtoMessage ¶ added in v0.17.0
func (*CreateMsg) ProtoMessage()
func (*CreateMsg) XXX_DiscardUnknown ¶ added in v0.17.0
func (m *CreateMsg) XXX_DiscardUnknown()
func (*CreateMsg) XXX_Marshal ¶ added in v0.17.0
func (*CreateMsg) XXX_Unmarshal ¶ added in v0.17.0
type Destination ¶ added in v0.18.0
type Destination 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 destination. // Each destination receives part of the total revenue amount proportional to // the weight. For example, if there are two destinations 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 (*Destination) Descriptor ¶ added in v0.18.0
func (*Destination) Descriptor() ([]byte, []int)
func (*Destination) GetAddress ¶ added in v0.18.0
func (m *Destination) GetAddress() github_com_iov_one_weave.Address
func (*Destination) GetWeight ¶ added in v0.18.0
func (m *Destination) GetWeight() int32
func (*Destination) Marshal ¶ added in v0.18.0
func (m *Destination) Marshal() (dAtA []byte, err error)
func (*Destination) MarshalTo ¶ added in v0.18.0
func (m *Destination) MarshalTo(dAtA []byte) (int, error)
func (*Destination) ProtoMessage ¶ added in v0.18.0
func (*Destination) ProtoMessage()
func (*Destination) Reset ¶ added in v0.18.0
func (m *Destination) Reset()
func (*Destination) Size ¶ added in v0.18.0
func (m *Destination) Size() (n int)
func (*Destination) String ¶ added in v0.18.0
func (m *Destination) String() string
func (*Destination) Unmarshal ¶ added in v0.18.0
func (m *Destination) Unmarshal(dAtA []byte) error
func (*Destination) XXX_DiscardUnknown ¶ added in v0.18.0
func (m *Destination) XXX_DiscardUnknown()
func (*Destination) XXX_Marshal ¶ added in v0.18.0
func (m *Destination) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*Destination) XXX_Merge ¶ added in v0.18.0
func (m *Destination) XXX_Merge(src proto.Message)
func (*Destination) XXX_Size ¶ added in v0.18.0
func (m *Destination) XXX_Size() int
func (*Destination) XXX_Unmarshal ¶ added in v0.18.0
func (m *Destination) XXX_Unmarshal(b []byte) error
type DistributeMsg ¶
type DistributeMsg struct { Metadata *weave.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"` // Revenue ID reference an ID of a revenue instance that the collected fees // should be distributed between destinations. RevenueID []byte `protobuf:"bytes,2,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 destinations. Request must be signed using admin key.
func (*DistributeMsg) Descriptor ¶
func (*DistributeMsg) Descriptor() ([]byte, []int)
func (*DistributeMsg) GetMetadata ¶ added in v0.15.0
func (m *DistributeMsg) GetMetadata() *weave.Metadata
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 ¶
func (*Initializer) FromGenesis(opts weave.Options, params weave.GenesisParams, kv weave.KVStore) error
FromGenesis will parse initial account info from genesis and save it to the database
type ResetMsg ¶ added in v0.17.0
type ResetMsg struct { Metadata *weave.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"` // Revenue ID reference an ID of a revenue instance that is updated. RevenueID []byte `protobuf:"bytes,2,opt,name=revenue_id,json=revenueId,proto3" json:"revenue_id,omitempty"` // Destinations holds any number of addresses that the collected revenue is // distributed to. Must be at least one. Destinations []*Destination `protobuf:"bytes,3,rep,name=destinations,proto3" json:"destinations,omitempty"` }
ResetMsg change the configuration of a revenue instance. To assure destinations 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 (*ResetMsg) Descriptor ¶ added in v0.17.0
func (*ResetMsg) GetDestinations ¶ added in v0.18.0
func (m *ResetMsg) GetDestinations() []*Destination
func (*ResetMsg) GetMetadata ¶ added in v0.17.0
func (*ResetMsg) GetRevenueID ¶ added in v0.17.0
func (*ResetMsg) ProtoMessage ¶ added in v0.17.0
func (*ResetMsg) ProtoMessage()
func (*ResetMsg) XXX_DiscardUnknown ¶ added in v0.17.0
func (m *ResetMsg) XXX_DiscardUnknown()
func (*ResetMsg) XXX_Marshal ¶ added in v0.17.0
func (*ResetMsg) XXX_Unmarshal ¶ added in v0.17.0
type Revenue ¶
type Revenue struct { Metadata *weave.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"` // 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,2,opt,name=admin,proto3,casttype=github.com/iov-one/weave.Address" json:"admin,omitempty"` // Destinations holds any number of addresses that the collected revenue is // distributed to. Must be at least one. Destinations []*Destination `protobuf:"bytes,3,rep,name=destinations,proto3" json:"destinations,omitempty"` // Address of this entity. Set during creation and does not change. Address github_com_iov_one_weave.Address `protobuf:"bytes,4,opt,name=address,proto3,casttype=github.com/iov-one/weave.Address" json:"address,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) Descriptor ¶
func (*Revenue) GetAddress ¶ added in v0.19.0
func (m *Revenue) GetAddress() github_com_iov_one_weave.Address
func (*Revenue) GetAdmin ¶
func (m *Revenue) GetAdmin() github_com_iov_one_weave.Address
func (*Revenue) GetDestinations ¶ added in v0.18.0
func (m *Revenue) GetDestinations() []*Destination
func (*Revenue) GetMetadata ¶ added in v0.15.0
func (*Revenue) ProtoMessage ¶
func (*Revenue) ProtoMessage()
func (*Revenue) XXX_DiscardUnknown ¶
func (m *Revenue) XXX_DiscardUnknown()