distribution

package
v0.21.4 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2019 License: Apache-2.0 Imports: 11 Imported by: 2

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

Constants

This section is empty.

Variables

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

func RevenueAccount(key []byte) weave.Address

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) Descriptor() ([]byte, []int)

func (*CreateMsg) GetAdmin added in v0.17.0

func (*CreateMsg) GetDestinations added in v0.18.0

func (m *CreateMsg) GetDestinations() []*Destination

func (*CreateMsg) GetMetadata added in v0.17.0

func (m *CreateMsg) GetMetadata() *weave.Metadata

func (*CreateMsg) Marshal added in v0.17.0

func (m *CreateMsg) Marshal() (dAtA []byte, err error)

func (*CreateMsg) MarshalTo added in v0.17.0

func (m *CreateMsg) MarshalTo(dAtA []byte) (int, error)

func (CreateMsg) Path added in v0.17.0

func (CreateMsg) Path() string

func (*CreateMsg) ProtoMessage added in v0.17.0

func (*CreateMsg) ProtoMessage()

func (*CreateMsg) Reset added in v0.17.0

func (m *CreateMsg) Reset()

func (*CreateMsg) Size added in v0.17.0

func (m *CreateMsg) Size() (n int)

func (*CreateMsg) String added in v0.17.0

func (m *CreateMsg) String() string

func (*CreateMsg) Unmarshal added in v0.17.0

func (m *CreateMsg) Unmarshal(dAtA []byte) error

func (*CreateMsg) Validate added in v0.17.0

func (msg *CreateMsg) Validate() error

func (*CreateMsg) XXX_DiscardUnknown added in v0.17.0

func (m *CreateMsg) XXX_DiscardUnknown()

func (*CreateMsg) XXX_Marshal added in v0.17.0

func (m *CreateMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*CreateMsg) XXX_Merge added in v0.17.0

func (m *CreateMsg) XXX_Merge(src proto.Message)

func (*CreateMsg) XXX_Size added in v0.17.0

func (m *CreateMsg) XXX_Size() int

func (*CreateMsg) XXX_Unmarshal added in v0.17.0

func (m *CreateMsg) XXX_Unmarshal(b []byte) error

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 (*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) MarshalTo

func (m *DistributeMsg) MarshalTo(dAtA []byte) (int, 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) Descriptor() ([]byte, []int)

func (*ResetMsg) GetDestinations added in v0.18.0

func (m *ResetMsg) GetDestinations() []*Destination

func (*ResetMsg) GetMetadata added in v0.17.0

func (m *ResetMsg) GetMetadata() *weave.Metadata

func (*ResetMsg) GetRevenueID added in v0.17.0

func (m *ResetMsg) GetRevenueID() []byte

func (*ResetMsg) Marshal added in v0.17.0

func (m *ResetMsg) Marshal() (dAtA []byte, err error)

func (*ResetMsg) MarshalTo added in v0.17.0

func (m *ResetMsg) MarshalTo(dAtA []byte) (int, error)

func (ResetMsg) Path added in v0.17.0

func (ResetMsg) Path() string

func (*ResetMsg) ProtoMessage added in v0.17.0

func (*ResetMsg) ProtoMessage()

func (*ResetMsg) Reset added in v0.17.0

func (m *ResetMsg) Reset()

func (*ResetMsg) Size added in v0.17.0

func (m *ResetMsg) Size() (n int)

func (*ResetMsg) String added in v0.17.0

func (m *ResetMsg) String() string

func (*ResetMsg) Unmarshal added in v0.17.0

func (m *ResetMsg) Unmarshal(dAtA []byte) error

func (*ResetMsg) Validate added in v0.17.0

func (msg *ResetMsg) Validate() error

func (*ResetMsg) XXX_DiscardUnknown added in v0.17.0

func (m *ResetMsg) XXX_DiscardUnknown()

func (*ResetMsg) XXX_Marshal added in v0.17.0

func (m *ResetMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ResetMsg) XXX_Merge added in v0.17.0

func (m *ResetMsg) XXX_Merge(src proto.Message)

func (*ResetMsg) XXX_Size added in v0.17.0

func (m *ResetMsg) XXX_Size() int

func (*ResetMsg) XXX_Unmarshal added in v0.17.0

func (m *ResetMsg) XXX_Unmarshal(b []byte) error

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

func (rev *Revenue) Copy() orm.CloneableData

func (*Revenue) Descriptor

func (*Revenue) Descriptor() ([]byte, []int)

func (*Revenue) GetAddress added in v0.19.0

func (m *Revenue) GetAddress() github_com_iov_one_weave.Address

func (*Revenue) GetAdmin

func (*Revenue) GetDestinations added in v0.18.0

func (m *Revenue) GetDestinations() []*Destination

func (*Revenue) GetMetadata added in v0.15.0

func (m *Revenue) GetMetadata() *weave.Metadata

func (*Revenue) Marshal

func (m *Revenue) Marshal() (dAtA []byte, err error)

func (*Revenue) MarshalTo

func (m *Revenue) MarshalTo(dAtA []byte) (int, error)

func (*Revenue) ProtoMessage

func (*Revenue) ProtoMessage()

func (*Revenue) Reset

func (m *Revenue) Reset()

func (*Revenue) Size

func (m *Revenue) Size() (n int)

func (*Revenue) String

func (m *Revenue) String() string

func (*Revenue) Unmarshal

func (m *Revenue) Unmarshal(dAtA []byte) error

func (*Revenue) Validate

func (rev *Revenue) Validate() error

func (*Revenue) XXX_DiscardUnknown

func (m *Revenue) XXX_DiscardUnknown()

func (*Revenue) XXX_Marshal

func (m *Revenue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Revenue) XXX_Merge

func (m *Revenue) XXX_Merge(src proto.Message)

func (*Revenue) XXX_Size

func (m *Revenue) XXX_Size() int

func (*Revenue) XXX_Unmarshal

func (m *Revenue) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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