distribution

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2019 License: Apache-2.0 Imports: 10 Imported by: 2

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

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 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(revenueID []byte) (weave.Address, error)

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) 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, db weave.KVStore) error

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 (*NewRevenueMsg) GetRecipients

func (m *NewRevenueMsg) GetRecipients() []*Recipient

func (*NewRevenueMsg) Marshal

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

func (*NewRevenueMsg) MarshalTo

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

func (*Recipient) GetAddress

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

func (*Recipient) GetWeight

func (m *Recipient) GetWeight() int32

func (*Recipient) Marshal

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

func (*Recipient) MarshalTo

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

func (*Recipient) ProtoMessage

func (*Recipient) ProtoMessage()

func (*Recipient) Reset

func (m *Recipient) Reset()

func (*Recipient) Size

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

func (*Recipient) String

func (m *Recipient) String() string

func (*Recipient) Unmarshal

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

func (*Recipient) XXX_DiscardUnknown

func (m *Recipient) XXX_DiscardUnknown()

func (*Recipient) XXX_Marshal

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

func (*Recipient) XXX_Merge

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

func (*Recipient) XXX_Size

func (m *Recipient) XXX_Size() int

func (*Recipient) XXX_Unmarshal

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

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

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

func (*Revenue) GetAdmin

func (*Revenue) GetRecipients

func (m *Revenue) GetRecipients() []*Recipient

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

type RevenueBucket

type RevenueBucket struct {
	orm.Bucket
	// contains filtered or unexported fields
}

func NewRevenueBucket

func NewRevenueBucket() *RevenueBucket

NewRevenueBucket returns a bucket for managing revenues state.

func (*RevenueBucket) Create

func (b *RevenueBucket) Create(db weave.KVStore, rev *Revenue) (orm.Object, error)

Create adds given revenue instance to the store and returns the ID of the newly inserted entity.

func (*RevenueBucket) GetRevenue

func (b *RevenueBucket) GetRevenue(db weave.KVStore, revenueID []byte) (*Revenue, error)

GetRevenue returns a revenue instance with given ID.

func (*RevenueBucket) Save

func (b *RevenueBucket) Save(db weave.KVStore, obj orm.Object) error

Save persists the state of a given revenue entity.

Jump to

Keyboard shortcuts

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