msgfee

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: 9 Imported by: 0

Documentation

Overview

Package msgfee allows to define and charge an additional fee per transaction type.

With this extension it is possible to declare a fee for each transaction message type. For each message path a coin value can be declared. After successful processing of a transaction the result required fee value is increased by the declared coin value.

This extension does not know of supported (installed) message paths and therefore cannot validate for their existence. Make sure that when registering a new message fee the path is set correctly.

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

This section is empty.

Types

type AntiSpamQuery added in v0.14.0

type AntiSpamQuery struct {
	// contains filtered or unexported fields
}

AntiSpamQuery allows querying currently set anti-spam fee

func NewAntiSpamQuery added in v0.14.0

func NewAntiSpamQuery(minFee coin.Coin) *AntiSpamQuery

func (*AntiSpamQuery) Query added in v0.14.0

func (q *AntiSpamQuery) Query(db weave.ReadOnlyKVStore, mod string, data []byte) ([]weave.Model, error)

func (*AntiSpamQuery) RegisterQuery added in v0.14.0

func (q *AntiSpamQuery) RegisterQuery(qr weave.QueryRouter)

type AntispamFeeDecorator added in v0.14.0

type AntispamFeeDecorator struct {
	// contains filtered or unexported fields
}

AntispamFeeDecorator implements a decorator that for each processed transaction asks for a minimal fee. The fee is defined globally in the app. If fee is not set (zero value) or is less than the fee already asked for the transaction then this decorator is a noop.

func NewAntispamFeeDecorator added in v0.14.0

func NewAntispamFeeDecorator(fee coin.Coin) *AntispamFeeDecorator

NewAntispamFeeDecorator returns an AntispamFeeDecorator

func (*AntispamFeeDecorator) Check added in v0.14.0

func (*AntispamFeeDecorator) Deliver added in v0.14.0

type FeeDecorator

type FeeDecorator struct {
	// contains filtered or unexported fields
}

FeeDecorator implements a decorator that for each processed transaction attach an additional fee to the result. Each fee is declarated per transaction type. If fee is not set (zero value) then this decorator does not increase the required fee value. Additional fee is attached to only those transaction results that represent a success.

func NewFeeDecorator

func NewFeeDecorator() *FeeDecorator

NewFeeDecorator returns a decorator that is upading the cost of processing each message according to the fee configured per each message type.

func (*FeeDecorator) Check

func (d *FeeDecorator) Check(ctx weave.Context, store weave.KVStore, tx weave.Tx, next weave.Checker) (weave.CheckResult, error)

func (*FeeDecorator) Deliver

func (d *FeeDecorator) Deliver(ctx weave.Context, store weave.KVStore, tx weave.Tx, next weave.Deliverer) (weave.DeliverResult, 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 MsgFee

type MsgFee struct {
	MsgPath string    `protobuf:"bytes,1,opt,name=msg_path,json=msgPath,proto3" json:"msg_path,omitempty"`
	Fee     coin.Coin `protobuf:"bytes,2,opt,name=fee,proto3" json:"fee"`
}

MsgFee represents a fee for a single message that must be paid in order for the message to be processed.

func (*MsgFee) Copy

func (mf *MsgFee) Copy() orm.CloneableData

func (*MsgFee) Descriptor

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

func (*MsgFee) GetFee

func (m *MsgFee) GetFee() coin.Coin

func (*MsgFee) GetMsgPath

func (m *MsgFee) GetMsgPath() string

func (*MsgFee) Marshal

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

func (*MsgFee) MarshalTo

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

func (*MsgFee) ProtoMessage

func (*MsgFee) ProtoMessage()

func (*MsgFee) Reset

func (m *MsgFee) Reset()

func (*MsgFee) Size

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

func (*MsgFee) String

func (m *MsgFee) String() string

func (*MsgFee) Unmarshal

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

func (*MsgFee) Validate

func (mf *MsgFee) Validate() error

func (*MsgFee) XXX_DiscardUnknown

func (m *MsgFee) XXX_DiscardUnknown()

func (*MsgFee) XXX_Marshal

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

func (*MsgFee) XXX_Merge

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

func (*MsgFee) XXX_Size

func (m *MsgFee) XXX_Size() int

func (*MsgFee) XXX_Unmarshal

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

type MsgFeeBucket

type MsgFeeBucket struct {
	orm.Bucket
}

func NewMsgFeeBucket

func NewMsgFeeBucket() *MsgFeeBucket

NewMsgFeeBucket returns a bucket for keeping track of fees for eeach message type. Message fees are indexed by the corresponding message path.

func (*MsgFeeBucket) Create

func (b *MsgFeeBucket) Create(db weave.KVStore, mf *MsgFee) (orm.Object, error)

Create adds given message fee instance to the store.

func (*MsgFeeBucket) MessageFee

func (b *MsgFeeBucket) MessageFee(db weave.KVStore, msgPath string) (*coin.Coin, error)

Fee returns the fee value for a given message path. It returns an empty fee and no error if the message fee is not declared.

func (*MsgFeeBucket) Save

func (b *MsgFeeBucket) 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