model

package
v0.0.0-...-47f881f Latest Latest
Warning

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

Go to latest
Published: May 23, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SCAN_BLOCK_INFO = "scan_block_info"
	ARWEAVE         = "arweave"
)
View Source
const (
	CONTENT_TABLE = "content"
)
View Source
const (
	SCAN_BLOCK_FAIL_INFO = "scan_block_fail_info"
)

Variables

This section is empty.

Functions

func GetAuthorCount

func GetAuthorCount(db *xorm.Engine, from, to int64, app string) (int64, error)

func GetContentCount

func GetContentCount(db *xorm.Engine, from, to int64, app string) (int64, error)

func GetLastHeight

func GetLastHeight(db *xorm.Engine) (int64, error)

func InitMySQLXorm

func InitMySQLXorm(addr string, showSQL bool) *xorm.Engine

InitMySQLXorm ..

func InsertFailRecord

func InsertFailRecord(db *xorm.Engine, height int64) (err error)

func InsertOne

func InsertOne(db *xorm.Engine, height int64) error

func SaveContentsToDB

func SaveContentsToDB(session *xorm.Session, contents []*Content) error

func UpdateArticleAndBlockInfoInTransaction

func UpdateArticleAndBlockInfoInTransaction(db *xorm.Engine, contents []*Content, s *ScanBlockInfo, r *ScanBlockFailRecord) error

func UpdateBlockInfoInTransaction

func UpdateBlockInfoInTransaction(db *xorm.Engine, height int64) error

Types

type Article

type Article struct {
	Body  string `json:"body"`
	Title string `json:"title"`
}

type ArticleDigest

type ArticleDigest struct {
	Ar             Article `json:"content"`
	OriginalDigest string  `json:"originalDigest"`
}

func ArticleDigestFromJSONStr

func ArticleDigestFromJSONStr(v []byte) (*ArticleDigest, error)

func (*ArticleDigest) ToJSONStr

func (ad *ArticleDigest) ToJSONStr() (string, error)

type CheckTag

type CheckTag struct {
	AppName     string
	Contributor string
	Address     string
}

func (*CheckTag) IsValid

func (c *CheckTag) IsValid(apps map[string]string, addrs map[string]string) bool

type Content

type Content struct {
	ID             int    `xorm:"int(10) 'id' pk autoincr" json:"-"`
	Ts             int64  `xorm:"'ts' bigint(1) not null default 0 " json:"ts"`
	Height         int64  `xorm:"'height' bigint(1) not null default 0 index" json:"height"`
	TxHash         string `xorm:"'tx_hash' varchar(100) not null index" json:"tx_hash"`
	From           string `xorm:"'trans_from' varchar(200) not null " json:"from"`
	To             string `xorm:"'trans_to' varchar(200) not null " json:"to"`
	Content        string `xorm:"'content' text not null " json:"content"`
	Title          string `xorm:"'title' text not null " json:"title"`
	Contributor    string `xorm:"'contributor' varchar(200) not null " json:"contributor"`
	OriginalDigest string `xorm:"'original_digest' varchar(200) not null " json:"original_digest"`
	AppName        string `xorm:"'app_name' varchar(100) not null " json:"app_name"`
}

func GetContentByHash

func GetContentByHash(db *xorm.Engine, hash string) (*Content, error)

func GetContents

func GetContents(db *xorm.Engine, ts, height int64, from, to, contributor, appName string, offset, limit int64) (contents []*Content, total int64, err error)

func GetTop

func GetTop(db *xorm.Engine, top int, app string) (contents []*Content, total int64, err error)
func Search(db *xorm.Engine, key string, offset, limit int64, app string) (contents []*Content, total int64, err error)

func (*Content) Empty

func (c *Content) Empty() bool

func (*Content) SaveToDB

func (c *Content) SaveToDB(db *xorm.Engine) error

func (*Content) String

func (c *Content) String() string

func (*Content) TableName

func (c *Content) TableName() string

type Contributor

type Contributor struct {
	Contributor string `xorm:"'contributor' varchar(200)" json:"contributor"`
}

type HistoryBlock

type HistoryBlock struct {
	Timestamp int64 `json:"timestamp"`
	Height    int64 `json:"height"`
	Txs       struct {
		Docs []struct {
			Transfers []struct {
				From []struct {
					Address string `json:"address"`
				} `json:"from"`
			} `json:"transfers"`
			Hash  string `json:"hash"`
			Extra struct {
				Tags []struct {
					Name  string `json:"name"`
					Value string `json:"value"`
				} `json:"tags"`
			} `json:"extra"`
		} `json:"docs"`
		HasNextPage bool `json:"hasNextPage"`
		NextPage    int  `json:"nextPage"`
	} `json:"txs"`
}

func HistoryBlockFromJSONStr

func HistoryBlockFromJSONStr(v []byte) (*HistoryBlock, error)

func (*HistoryBlock) GetContentInfo

func (hb *HistoryBlock) GetContentInfo(addr string, app string) (contents []*Content)

func (*HistoryBlock) ToJSONStr

func (hb *HistoryBlock) ToJSONStr() (string, error)

type HistoryFail

type HistoryFail struct {
	ID     int   `xorm:"int(10) 'id' pk autoincr" json:"-"`
	Height int64 `xorm:"'height' bigint(1) not null default 0 " json:"height"`
}

func GetAllHistoryFail

func GetAllHistoryFail(db *xorm.Engine, limit, offset int) ([]*HistoryFail, int64, error)

func (*HistoryFail) Delete

func (hf *HistoryFail) Delete(db *xorm.Engine) error

func (*HistoryFail) TableName

func (hf *HistoryFail) TableName() string

type ScanBlockFailRecord

type ScanBlockFailRecord struct {
	ID         int    `xorm:"int(10) 'id' pk autoincr" json:"-"`
	Height     int64  `xorm:"'height' bigint(1) not null default 0 " json:"last_height"`
	DataSource string `xorm:"'data_source' varchar(100) not null" json:"data_source"`
}

func GetFailRecords

func GetFailRecords(db *xorm.Engine) (rs []*ScanBlockFailRecord, total int64, err error)

func (*ScanBlockFailRecord) DeleteFailRecords

func (s *ScanBlockFailRecord) DeleteFailRecords(session *xorm.Session) (err error)

func (*ScanBlockFailRecord) TableName

func (s *ScanBlockFailRecord) TableName() string

type ScanBlockInfo

type ScanBlockInfo struct {
	ID         int    `xorm:"int(10) 'id' pk autoincr" json:"-"`
	LastHeight int64  `xorm:"'last_height' bigint(1) not null default 0 " json:"last_height"`
	DataSource string `xorm:"'data_source' varchar(100) not null index" json:"data_source"`
	Ts         int64  `xorm:"'ts' bigint(1) not null default 0 " json:"ts"`
}

func GetScanBlockInfo

func GetScanBlockInfo(db *xorm.Engine) (*ScanBlockInfo, error)

func (*ScanBlockInfo) TableName

func (s *ScanBlockInfo) TableName() string

func (*ScanBlockInfo) Upsert

func (s *ScanBlockInfo) Upsert(session *xorm.Session) error

Jump to

Keyboard shortcuts

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