Documentation
¶
Index ¶
- Constants
- Variables
- type AppAccount
- func (account *AppAccount) DecreaseBalance(delta *big.Int) bool
- func (account *AppAccount) DecreaseFee(delta *big.Int) bool
- func (account *AppAccount) IncreaseBalance(delta *big.Int)
- func (account *AppAccount) IncreaseFee(delta *big.Int)
- func (account *AppAccount) IsConfirmed() bool
- func (account *AppAccount) IsFrozen() bool
- func (account *AppAccount) TotalBalance() *big.Int
- type Bill
- type BusinessError
Constants ¶
View Source
const ( BillStatusCreated = iota BillStatusSubmitting BillStatusSubmitted BillStatusFailed )
Variables ¶
View Source
var ( // general error ErrNil = &BusinessError{Code: 0, Message: "OK"} ErrValidation = &BusinessError{Code: 1, Message: "Invalid parameter"} ErrInternalServer = &BusinessError{Code: 2, Message: "Internal server error"} ErrAuth = &BusinessError{Code: 3, Message: "Authentication failed"} // specific error ErrAppNotFound = &BusinessError{Code: 10000, Message: "APP not found"} ErrResourceNotFound = &BusinessError{Code: 10001, Message: "Resource not found"} ErrInsufficentBalance = &BusinessError{Code: 10002, Message: "Insufficient balance"} ErrAccountFrozen = &BusinessError{Code: 10003, Message: "Account fronzen"} ErrInvalidAppOperator = &BusinessError{Code: 10004, Message: "Invalid APP operator"} ErrNotBillingApp = &BusinessError{Code: 10005, Message: "Not a billing APP"} )
View Source
var All = []interface{}{ &Bill{}, }
Functions ¶
This section is empty.
Types ¶
type AppAccount ¶
type AppAccount struct { // APP contract address App string // account address Address string // frozen status, 0 means not frozen Frozen int64 // deduction fee Fee decimal.Decimal // pending balance Balance decimal.Decimal // the confirmed block number, math.MaxInt64 means not confirmed ConfirmedBlock int64 }
func NewAppAccount ¶
func NewAppAccount(app, address string, frozen int64, balance *big.Int) *AppAccount
func (*AppAccount) DecreaseBalance ¶
func (account *AppAccount) DecreaseBalance(delta *big.Int) bool
func (*AppAccount) DecreaseFee ¶
func (account *AppAccount) DecreaseFee(delta *big.Int) bool
func (*AppAccount) IncreaseBalance ¶
func (account *AppAccount) IncreaseBalance(delta *big.Int)
func (*AppAccount) IncreaseFee ¶
func (account *AppAccount) IncreaseFee(delta *big.Int)
func (*AppAccount) IsConfirmed ¶
func (account *AppAccount) IsConfirmed() bool
func (*AppAccount) IsFrozen ¶
func (account *AppAccount) IsFrozen() bool
func (*AppAccount) TotalBalance ¶
func (account *AppAccount) TotalBalance() *big.Int
type Bill ¶
type Bill struct { ID uint64 // APP contract address App string `gorm:"size:64;not null;index:idx_app_addr,priority:1"` // account address Address string `gorm:"size:64;not null;index:idx_app_addr,priority:2"` // total deduction fee Fee decimal.Decimal `gorm:"size:128;type:string"` // 0 - created, 1 - submitting, 2 - submitted // record shall be deleted if settlement confirmed Status uint8 `gorm:"default:0"` // transaction hash if submitted TxnHash string `gorm:"size:64;type:string"` // memo Memo string `gorm:"size:256;type:string"` // create date CreatedAt time.Time // update date UpdatedAt time.Time }
Bill bills to settle on blockchain
type BusinessError ¶
type BusinessError struct { Code int `json:"code"` Message string `json:"message"` Data interface{} `json:"data"` }
func IsBusinessError ¶
func IsBusinessError(err error) (*BusinessError, bool)
func (*BusinessError) Error ¶
func (err *BusinessError) Error() string
func (*BusinessError) GetObject ¶
func (be *BusinessError) GetObject(toType interface{}) error
GetObject converts the business error data to an arbitrary type.
The function works as you would expect it from json.Unmarshal()
func (*BusinessError) IsNil ¶
func (err *BusinessError) IsNil() bool
func (*BusinessError) WithData ¶
func (be *BusinessError) WithData(data interface{}) *BusinessError
Click to show internal directories.
Click to hide internal directories.