data

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2022 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const CotaIdLen = 42

Variables

View Source
var ErrInvalidClassInfo = errors.New("class info is invalid")

ProviderSet is data providers

Functions

func GenerateLockHash

func GenerateLockHash(entry biz.Entry) (lockHashStr string, lockHashCRC32 uint32, err error)

func GenerateReceiverLock

func GenerateReceiverLock(slice []byte) biz.Script

func GenerateSenderLock

func GenerateSenderLock(entry biz.Entry) (lockScript biz.Script, err error)

func NewCheckInfoRepo

func NewCheckInfoRepo(data *Data, logger *logger.Logger) biz.CheckInfoRepo

func NewClaimedCotaNftKvPairRepo

func NewClaimedCotaNftKvPairRepo(data *Data, logger *logger.Logger) biz.ClaimedCotaNftKvPairRepo

func NewClassInfoRepo

func NewClassInfoRepo(data *Data, logger *logger.Logger) biz.ClassInfoRepo

func NewDefineCotaNftKvPairRepo

func NewDefineCotaNftKvPairRepo(data *Data, logger *logger.Logger) biz.DefineCotaNftKvPairRepo

func NewHoldCotaNftKvPairRepo

func NewHoldCotaNftKvPairRepo(data *Data, logger *logger.Logger) biz.HoldCotaNftKvPairRepo

func NewInvalidDateRepo

func NewInvalidDateRepo(data *Data, logger *logger.Logger) biz.InvalidDataRepo

func NewIssuerInfoRepo

func NewIssuerInfoRepo(data *Data, logger *logger.Logger) biz.IssuerInfoRepo

func NewKvPairRepo

func NewKvPairRepo(data *Data, logger *logger.Logger) biz.KvPairRepo

func NewMintCotaKvPairRepo

func NewMintCotaKvPairRepo(data *Data, logger *logger.Logger) biz.MintCotaKvPairRepo

func NewRegisterCotaKvPairRepo

func NewRegisterCotaKvPairRepo(data *Data, logger *logger.Logger) biz.RegisterCotaKvPairRepo

func NewTransferCotaKvPairRepo

func NewTransferCotaKvPairRepo(data *Data, logger *logger.Logger) biz.TransferCotaKvPairRepo

func NewWithdrawCotaNftKvPairRepo

func NewWithdrawCotaNftKvPairRepo(data *Data, logger *logger.Logger) biz.WithdrawCotaNftKvPairRepo

func NewWithdrawExtraInfoRepo

func NewWithdrawExtraInfoRepo(data *Data, logger *logger.Logger) biz.WithdrawExtraInfoRepo

Types

type BlockSyncer

type BlockSyncer struct {
	// contains filtered or unexported fields
}

func NewBlockSyncer

func NewBlockSyncer(claimedCotaUsecase *biz.ClaimedCotaNftKvPairUsecase, defineCotaUsecase *biz.DefineCotaNftKvPairUsecase,
	holdCotaUsecase *biz.HoldCotaNftKvPairUsecase, registerCotaUsecase *biz.RegisterCotaKvPairUsecase,
	withdrawCotaUsecase *biz.WithdrawCotaNftKvPairUsecase, cotaWitnessArgsParser CotaWitnessArgsParser,
	kvPairUsecase *biz.SyncKvPairUsecase, mintCotaUsecase *biz.MintCotaKvPairUsecase, transferCotaUsecase *biz.TransferCotaKvPairUsecase,
	issuerInfoUsecase *biz.IssuerInfoUsecase, classInfoUsecase *biz.ClassInfoUsecase) BlockSyncer

func (BlockSyncer) Rollback

func (bp BlockSyncer) Rollback(ctx context.Context, blockNumber uint64) error

func (BlockSyncer) Sync

func (bp BlockSyncer) Sync(ctx context.Context, block *ckbTypes.Block, checkInfo biz.CheckInfo, systemScripts SystemScripts) error

type CheckInfo

type CheckInfo struct {
	ID          uint `gorm:"primaryKey"`
	BlockNumber uint64
	BlockHash   string
	CheckType   biz.CheckType
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

type CkbNodeClient

type CkbNodeClient struct {
	Rpc  rpc.Client
	Mode string
}

func NewCkbNodeClient

func NewCkbNodeClient(conf *config.CkbNode, logger *logger.Logger) (*CkbNodeClient, error)

type ClaimedCotaNftKvPair

type ClaimedCotaNftKvPair struct {
	ID          uint `gorm:"primaryKey"`
	BlockNumber uint64
	CotaId      string
	CotaIdCRC   uint32
	TokenIndex  uint32
	OutPoint    string
	OutPointCrc uint32
	LockHash    string
	LockHashCrc uint32
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

type ClassInfo

type ClassInfo struct {
	ID             uint `gorm:"primaryKey"`
	BlockNumber    uint64
	CotaId         string
	Version        string
	Name           string
	Symbol         string
	Description    string
	Image          string
	Audio          string
	Video          string
	Model          string
	Characteristic string
	Properties     string
	Localization   string
	CreatedAt      time.Time
	UpdatedAt      time.Time
}

type ClassInfoVersion

type ClassInfoVersion struct {
	ID                uint `gorm:"primaryKey"`
	OldBlockNumber    uint64
	BlockNumber       uint64
	CotaId            string
	OldVersion        string
	Version           string
	OldName           string
	Name              string
	OldSymbol         string
	Symbol            string
	OldDescription    string
	Description       string
	OldImage          string
	Image             string
	OldAudio          string
	Audio             string
	OldVideo          string
	Video             string
	OldModel          string
	Model             string
	OldCharacteristic string
	Characteristic    string
	OldProperties     string
	Properties        string
	OldLocalization   string
	Localization      string
	ActionType        uint8 //	0-create 1-update 2-delete
	TxIndex           uint32
	CreatedAt         time.Time
	UpdatedAt         time.Time
}

type CotaWitnessArgsParser

type CotaWitnessArgsParser struct {
	// contains filtered or unexported fields
}

func NewCotaWitnessArgsParser

func NewCotaWitnessArgsParser(client *CkbNodeClient) CotaWitnessArgsParser

func (CotaWitnessArgsParser) Parse

func (c CotaWitnessArgsParser) Parse(tx *ckbTypes.Transaction, txIndex uint32, cotaType SystemScript) ([]biz.Entry, error)

type DBMigration

type DBMigration struct {
	// contains filtered or unexported fields
}

func NewDBMigration

func NewDBMigration(data *Data, logger *logger.Logger) *DBMigration

func (*DBMigration) Down

func (m *DBMigration) Down() error

func (*DBMigration) Up

func (m *DBMigration) Up() error

type Data

type Data struct {
	// contains filtered or unexported fields
}

func NewData

func NewData(conf *config.Database, logger *logger.Logger) (*Data, func(), error)

type DefineCotaNftKvPair

type DefineCotaNftKvPair struct {
	ID          uint `gorm:"primaryKey"`
	BlockNumber uint64
	CotaId      string
	Total       uint32
	Issued      uint32
	Configure   uint8
	LockHash    string
	LockHashCRC uint32
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

type DefineCotaNftKvPairVersion

type DefineCotaNftKvPairVersion struct {
	ID             uint `gorm:"primaryKey"`
	OldBlockNumber uint64
	BlockNumber    uint64
	CotaId         string
	Total          uint32
	OldIssued      uint32
	Issued         uint32
	Configure      uint8
	LockHash       string
	ActionType     uint8 //	0-create 1-update 2-delete
	TxIndex        uint32
	CreatedAt      time.Time
	UpdatedAt      time.Time
}

type HoldCotaNftKvPair

type HoldCotaNftKvPair struct {
	ID             uint `gorm:"primaryKey"`
	BlockNumber    uint64
	CotaId         string
	TokenIndex     uint32
	State          uint8
	Configure      uint8
	Characteristic string
	LockHash       string
	LockHashCRC    uint32
	CreatedAt      time.Time
	UpdatedAt      time.Time
}

type HoldCotaNftKvPairVersion

type HoldCotaNftKvPairVersion struct {
	ID                uint `gorm:"primaryKey"`
	OldBlockNumber    uint64
	BlockNumber       uint64
	CotaId            string
	TokenIndex        uint32
	OldState          uint8
	State             uint8
	Configure         uint8
	OldCharacteristic string
	Characteristic    string
	OldLockHash       string
	LockHash          string
	ActionType        uint8 //	0-create 1-update 2-delete
	TxIndex           uint32
	CreatedAt         time.Time
	UpdatedAt         time.Time
}

type IssuerInfo

type IssuerInfo struct {
	ID           uint `gorm:"primaryKey"`
	BlockNumber  uint64
	LockHash     string
	Version      string
	Name         string
	Avatar       string
	Description  string
	Localization string
	CreatedAt    time.Time
	UpdatedAt    time.Time
}

type IssuerInfoVersion

type IssuerInfoVersion struct {
	ID              uint `gorm:"primaryKey"`
	OldBlockNumber  uint64
	BlockNumber     uint64
	LockHash        string
	OldVersion      string
	Version         string
	OldName         string
	Name            string
	OldAvatar       string
	Avatar          string
	OldDescription  string
	Description     string
	OldLocalization string
	Localization    string
	ActionType      uint8 //	0-create 1-update 2-delete
	TxIndex         uint32
	CreatedAt       time.Time
	UpdatedAt       time.Time
}

type MetadataSyncer

type MetadataSyncer struct {
	// contains filtered or unexported fields
}

func NewMetadataSyncer

func NewMetadataSyncer(
	kvPairUsecase *biz.SyncKvPairUsecase, cotaWitnessArgsParser CotaWitnessArgsParser, issuerInfoUsecase *biz.IssuerInfoUsecase,
	classInfoUsecase *biz.ClassInfoUsecase) MetadataSyncer

func (MetadataSyncer) Rollback

func (bp MetadataSyncer) Rollback(ctx context.Context, blockNumber uint64) error

func (MetadataSyncer) Sync

func (bp MetadataSyncer) Sync(ctx context.Context, block *ckbTypes.Block, checkInfo biz.CheckInfo, systemScripts SystemScripts) error

type Option

type Option func(*Data)

type RegisterCotaKvPair

type RegisterCotaKvPair struct {
	ID          uint `gorm:"primaryKey"`
	BlockNumber uint64
	LockHash    string
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

type Script

type Script struct {
	ID          uint `gorm:"primaryKey"`
	CodeHash    string
	CodeHashCrc uint32
	HashType    int64
	Args        string
	ArgsCrc     uint32
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

type SystemScript

type SystemScript struct {
	CodeHash ckbTypes.Hash
	HashType ckbTypes.ScriptHashType
	Args     []byte
	OutPoint ckbTypes.OutPoint
	DepType  ckbTypes.DepType
}

type SystemScriptOption

type SystemScriptOption func(o *SystemScripts)

type SystemScripts

type SystemScripts struct {
	CotaRegistryType SystemScript
	CotaType         SystemScript
}

func NewSystemScripts

func NewSystemScripts(client *CkbNodeClient, logger *logger.Logger) SystemScripts

type WithdrawCotaNftKvPair

type WithdrawCotaNftKvPair struct {
	ID                   uint `gorm:"primaryKey"`
	BlockNumber          uint64
	CotaId               string
	CotaIdCRC            uint32
	TokenIndex           uint32
	OutPoint             string
	OutPointCrc          uint32
	TxHash               string
	State                uint8
	Configure            uint8
	Characteristic       string
	ReceiverLockScriptId uint
	LockHash             string
	LockHashCrc          uint32
	LockScriptId         uint
	Version              uint8
	CreatedAt            time.Time
	UpdatedAt            time.Time
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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