models

package
v0.0.0-...-7bb605a Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//FeePolicyConstant 每笔交易,不论金额,固定收费
	FeePolicyConstant = iota
	//FeePolicyPercent 每笔交易固定收取一定比例的费用
	FeePolicyPercent
	//FeePolicyCombined 以上两种方式的组合
	FeePolicyCombined
)

Variables

This section is empty.

Functions

func DeleteAccountAllFeeRate

func DeleteAccountAllFeeRate(account common.Address, db *gorm.DB) (err error)

func UpdataAccountDefaultFeePolicy

func UpdataAccountDefaultFeePolicy(account common.Address, fee *Fee, db *gorm.DB) error

设置某个账户的缺省收费,新创建的通道都会按照此缺省设置进行

func UpdateAccountTokenFee

func UpdateAccountTokenFee(account, token common.Address, fee *Fee, db *gorm.DB) error

Types

type AccountFee

type AccountFee struct {
	Account         string `gorm:"primary_key"`
	FeePolicy       int    //收费模式
	FeeConstantPart string //固定费用
	FeePercentPart  int64  //比例费用
}

AccountFee 账户的缺省收费

type AccountTokenFee

type AccountTokenFee struct {
	gorm.Model             //auto id createat updataat deleteat
	Token           string `gorm:"index"` //调用者保证Token+Account必须是唯一的
	Account         string `gorm:"index"` //调用者保证Token+Account必须是唯一的
	FeePolicy       int
	FeeConstantPart string
	FeePercentPart  int64
}

AccountTokenFee 某个账户针对某个Token的缺省收费

type BalanceProof

type BalanceProof struct {
	Nonce           uint64      `json:"nonce"`
	TransferAmount  *big.Int    `json:"transfer_amount"`
	LocksRoot       common.Hash `json:"locks_root"`
	ChannelID       common.Hash `json:"channel_identifier"`
	OpenBlockNumber int64       `json:"open_block_number"`
	AdditionalHash  common.Hash `json:"addition_hash"`
	Signature       []byte      `json:"signature"`
}

type ChannelParticipantFee

type ChannelParticipantFee struct {
	ID              int
	ChannelID       string `gorm:"index"`
	Participant     string `gorm:"index"`
	Token           string
	FeePolicy       int
	FeeConstantPart string //固定部分是一个整数,比如一次收取1token
	FeePercentPart  int64  //0表示不收费,1000表示收费千分之一
}

ChannelParticipantFee 存储通道一方的收费信息

type ChannelParticipantInfo

type ChannelParticipantInfo struct {
	ID                     int
	ChannelID              string `gorm:"index"`
	Participant            string
	Nonce                  uint64
	Balance                string
	Deposit                string
	LockedAmount           string
	TransferedAmount       string
	IgnoreMediatedTransfer bool
}

func (*ChannelParticipantInfo) BalanceValue

func (c *ChannelParticipantInfo) BalanceValue() *big.Int

func (*ChannelParticipantInfo) Fee

func (c *ChannelParticipantInfo) Fee(token common.Address, db *gorm.DB) *Fee

type Fee

type Fee struct {
	FeePolicy   int      `json:"fee_policy"`
	FeeConstant *big.Int `json:"fee_constant" `
	FeePercent  int64    `json:"fee_percent"`
}

Fee 为了使用方便 外部定义

func GetAccountFeePolicy

func GetAccountFeePolicy(account common.Address, db *gorm.DB) (fee *Fee)

GetAccountFeePolicy 获取某个账户的缺省收费,新创建的通道都会按照此缺省设置进行

func GetAccountTokenFee

func GetAccountTokenFee(account, token common.Address, db *gorm.DB) (fee *Fee, err error)

func GetChannelFeeRate

func GetChannelFeeRate(channelIdentifier common.Hash, participant, token common.Address, db *gorm.DB) (fee *Fee)

GetChannelFeeRate get channel's fee rate

type TokenFee

type TokenFee struct {
	Token           string `gorm:"primary_key"`
	FeePolicy       int
	FeeConstantPart string
	FeePercentPart  int64
}

TokenFee 针对某种token 的缺省收费,暂不启用

Jump to

Keyboard shortcuts

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