models

package
v0.0.0-...-795c791 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientList

func ClientList(clientName string, client string, notary []string, params *types.PaginationParams) (*types.CommonList, error)

func CloseDB

func CloseDB()

CloseDB closes database connection (unnecessary)

func DeleteNotaryById

func DeleteNotaryById(id uint) error

func GetLastBlockTimeFromNotaryAllowance

func GetLastBlockTimeFromNotaryAllowance() (blockTime int64, err error)

func GetLastEpochFromNotaryAllowance

func GetLastEpochFromNotaryAllowance() (epoch uint64, err error)

func GetProportionOfAllowance

func GetProportionOfAllowance() ([]*types.ProportionOfSomething, error)

Calculate the proportion based on whether it is allocated or not

func GetProportionOfAllowanceByLocation

func GetProportionOfAllowanceByLocation() ([]*types.ProportionOfSomething, error)

Calculate the proportion of notary public quota based on region

func InitClientList

func InitClientList() error

func InitNotaryList

func InitNotaryList() error

func InsertClient

func InsertClient(c *Client) error

func InsertNotary

func InsertNotary(n *Notary) error

func NotaryList

func NotaryList(params *types.PaginationParams) (*types.CommonList, error)

func Setup

func Setup(conf *settingtypes.AppConfig)

Setup initializes the database instance

func TruncateClient

func TruncateClient() error

func TruncateNotary

func TruncateNotary() error

func UpsertClient

func UpsertClient(c *Client) error

func UpsertClientAllowance

func UpsertClientAllowance(c *ClientAllowance) error

func UpsertNotaryAllowance

func UpsertNotaryAllowance(n *NotaryAllowance) error

Types

type Client

type Client struct {
	Model
	Name    string `json:"name" gorm:"size:64;uniqueIndex:uix_client_name_addr"`     //client name
	Website string `json:"website" gorm:"size:255"`                                  //website、social media
	Region  string `json:"region" gorm:"size:64"`                                    //region
	Address string `json:"address" gorm:"size:255;uniqueIndex:uix_client_name_addr"` //client address
}

func GetClientList

func GetClientList(name, address string, offset, size int) (total int, list []*Client, err error)

func (Client) TableName

func (Client) TableName() string

type ClientAllowance

type ClientAllowance struct {
	Model
	Notary    string          `json:"notary" gorm:"size:255;index"`           // notary address
	Client    string          `json:"client" gorm:"size:255;index"`           // client address
	Allowance decimal.Decimal `json:"allowance" gorm:"type:decimal(30,0)"`    // quota
	BlockTime int64           `json:"block_time" gorm:"index"`                // time
	Epoch     uint64          `json:"epoch"`                                  // height
	SignedCid string          `json:"signed_cid" gorm:"size:255;uniqueIndex"` // info signature cid
}

func (ClientAllowance) TableName

func (ClientAllowance) TableName() string

type ClientAllowanceGranted

type ClientAllowanceGranted struct {
	Date    int64           `json:"date"`
	Granted decimal.Decimal `json:"granted"`
}

func GetClientAllowanceGrantedDaily

func GetClientAllowanceGrantedDaily(limit int64) ([]*ClientAllowanceGranted, error)

type Model

type Model struct {
	ID        uint            `gorm:"primarykey" json:"id"`
	CreatedAt types.UnixTime  `json:"created_at"`
	UpdatedAt types.UnixTime  `json:"updated_at"`
	DeletedAt *gorm.DeletedAt `gorm:"index" json:"deleted_at,omitempty"`
}

type Notary

type Notary struct {
	Model
	NotaryName   string `json:"notary_name" gorm:"size:64"`           //notary name
	Organization string `json:"organization" gorm:"size:128"`         //organization
	Address      string `json:"address" gorm:"size:255;unique_index"` //notary address
	Location     string `json:"location" gorm:"size:64"`              //region
	Website      string `json:"website" gorm:"size:255"`              //website、social media
	Remark       string `json:"remark" gorm:"size:255"`               //remark

	GithubUser    string          `json:"github_user" gorm:"size:128"` //github account
	LastLoginTime *types.UnixTime `json:"last_login_time,omitempty"`   //the latest login time
}

func GetNotaryList

func GetNotaryList(offset, size int) (total int, list []*Notary, err error)

func (Notary) TableName

func (Notary) TableName() string

type NotaryAllowance

type NotaryAllowance struct {
	Model
	TxnId     int64           `json:"txn_id"`
	Address   string          `json:"address" gorm:"size:255;index"`          // notary address
	Allowance decimal.Decimal `json:"allowance" gorm:"type:decimal(30,0)"`    // quota
	BlockTime int64           `json:"block_time"`                             // time
	Epoch     uint64          `json:"epoch" gorm:"index"`                     // height
	SignedCid string          `json:"signed_cid" gorm:"size:255;uniqueIndex"` // info signature cid
}

func (NotaryAllowance) TableName

func (NotaryAllowance) TableName() string

Jump to

Keyboard shortcuts

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