txfee

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2020 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Overview

Package txfee implements a fee middleware that computes an additional transaction fee, depending on each transaction binary size.

Txfee extension is configured via `gconf` and price computation can be adjusted.

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 RegisterRoutes

func RegisterRoutes(r weave.Registry, auth x.Authenticator)

func TransactionFee

func TransactionFee(txSize int, baseFee coin.Coin, freeBytes int32) (*coin.Coin, error)

Types

type Configuration

type Configuration struct {
	Metadata *weave.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
	// Owner is present to implement gconf.OwnedConfig interface
	// This defines the Address that is allowed to update the Configuration object and is
	// needed to make use of gconf.NewUpdateConfigurationHandler
	Owner github_com_iov_one_weave.Address `protobuf:"bytes,2,opt,name=owner,proto3,casttype=github.com/iov-one/weave.Address" json:"owner,omitempty"`
	// Free bytes declares the size of the message (in bytes) that is free of
	// charge. Any additional fee is counted only from the size above the free
	// bytes threshold.
	//
	// Transaction fee is computed using the following equation:
	//   ((max(0, bytes_size(tx) - free_bytes) ** 2) * base_fee
	// All computations are done using uint64 precision and only integer values.
	FreeBytes int32 `protobuf:"varint,3,opt,name=free_bytes,json=freeBytes,proto3" json:"free_bytes,omitempty"`
	// Base fee defines the currency and multiplicate for the transaction size
	// fee amount.
	BaseFee coin.Coin `protobuf:"bytes,4,opt,name=base_fee,json=baseFee,proto3" json:"base_fee"`
}

func (*Configuration) Descriptor

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

func (*Configuration) GetBaseFee

func (m *Configuration) GetBaseFee() coin.Coin

func (*Configuration) GetFreeBytes

func (m *Configuration) GetFreeBytes() int32

func (*Configuration) GetMetadata

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

func (*Configuration) GetOwner

func (*Configuration) Marshal

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

func (*Configuration) MarshalTo

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

func (*Configuration) ProtoMessage

func (*Configuration) ProtoMessage()

func (*Configuration) Reset

func (m *Configuration) Reset()

func (*Configuration) Size

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

func (*Configuration) String

func (m *Configuration) String() string

func (*Configuration) Unmarshal

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

func (*Configuration) Validate

func (c *Configuration) Validate() error

func (*Configuration) XXX_DiscardUnknown

func (m *Configuration) XXX_DiscardUnknown()

func (*Configuration) XXX_Marshal

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

func (*Configuration) XXX_Merge

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

func (*Configuration) XXX_Size

func (m *Configuration) XXX_Size() int

func (*Configuration) XXX_Unmarshal

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

type Decorator

type Decorator struct {
}

func NewDecorator

func NewDecorator() *Decorator

NewDecorator returns a transaction fee decorator instance that is adding an additional fee to each processed transaction, depending on that transaction binary size.

This decorator does not directly deduct fees from transaction fee payers account. This decorator depends on presence of cash.DynamicFeeDecorator to withdraw funds equal to the final transaction fee.

func (*Decorator) Check

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

func (*Decorator) Deliver

func (d *Decorator) 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, params weave.GenesisParams, kv weave.KVStore) error

FromGenesis will parse initial account info from genesis and save it to the database

type UpdateConfigurationMsg

type UpdateConfigurationMsg struct {
	Metadata *weave.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
	Patch    *Configuration  `protobuf:"bytes,2,opt,name=patch,proto3" json:"patch,omitempty"`
}

func (*UpdateConfigurationMsg) Descriptor

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

func (*UpdateConfigurationMsg) GetMetadata

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

func (*UpdateConfigurationMsg) GetPatch

func (m *UpdateConfigurationMsg) GetPatch() *Configuration

func (*UpdateConfigurationMsg) Marshal

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

func (*UpdateConfigurationMsg) MarshalTo

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

func (*UpdateConfigurationMsg) Path

func (*UpdateConfigurationMsg) ProtoMessage

func (*UpdateConfigurationMsg) ProtoMessage()

func (*UpdateConfigurationMsg) Reset

func (m *UpdateConfigurationMsg) Reset()

func (*UpdateConfigurationMsg) Size

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

func (*UpdateConfigurationMsg) String

func (m *UpdateConfigurationMsg) String() string

func (*UpdateConfigurationMsg) Unmarshal

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

func (*UpdateConfigurationMsg) Validate

func (m *UpdateConfigurationMsg) Validate() error

func (*UpdateConfigurationMsg) XXX_DiscardUnknown

func (m *UpdateConfigurationMsg) XXX_DiscardUnknown()

func (*UpdateConfigurationMsg) XXX_Marshal

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

func (*UpdateConfigurationMsg) XXX_Merge

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

func (*UpdateConfigurationMsg) XXX_Size

func (m *UpdateConfigurationMsg) XXX_Size() int

func (*UpdateConfigurationMsg) XXX_Unmarshal

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

Jump to

Keyboard shortcuts

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