schema

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: Apache-2.0 Imports: 6 Imported by: 5

Documentation

Index

Constants

View Source
const (
	AllowStreamMinItemSize = 5 * 1024 * 1024    // 5 MB
	AllowMaxRespDataSize   = 50 * 1024 * 1024   // 50 MB
	SubmitMaxSize          = 1024 * 1024 * 1024 // 1 GB
)
View Source
const (
	DefaultPaymentExpiredRange = int64(2592000) // 30 days
	DefaultExpectedRange       = 50             // block height range
)
View Source
const (
	WaitOnChain    = "waiting"
	PendingOnChain = "pending"
	SuccOnChain    = "success"
	FailedOnChain  = "failed"

	// order payment status
	UnPayment      = "unpaid"
	SuccPayment    = "paid"
	ExpiredPayment = "expired"

	// ReceiptEverTx Status
	UnSpent   = "unspent"
	Spent     = "spent"
	UnRefund  = "unrefund"
	Refund    = "refunded"
	RefundErr = "refundErr"

	MaxPerOnChainSize = 2 * 1024 * 1024 * 1024 // 2 GB

	TmpFileDir = "./tmpFile"
)
View Source
const (
	ManifestType = "application/x.arweave-manifest+json"
	ContentType  = "Content-Type"
	ManiData     = `` /* 652-byte string literal not displayed */

)
View Source
const (
	TaskTypeBroadcast     = "broadcast"      // include tx and tx data
	TaskTypeBroadcastMeta = "broadcast_meta" //  not include tx data
	TaskTypeSync          = "sync"
	TaskTypeSyncManifest  = "sync_manifest" // sync manifest
)
View Source
const (
	ConstTx = `` /* 1866-byte string literal not displayed */

)

Variables

View Source
var (
	ErrNotExist = errors.New("not_exist_record")
	ErrNotFound = errors.New("not_found")
	ErrExist    = errors.New("s3_bucket_exist")

	ErrExistTx    = errors.New("tx_exist")
	ErrTaskClosed = errors.New("task_closed")
	ErrFetchData  = errors.New("fetch_tx_data_from_peers")

	ErrDataTooBig    = errors.New("tx_data_too_big")
	ErrNullData      = errors.New("null_data")
	ErrLocalNotExist = errors.New("not_exist_local") // need to get data from gateway
	ErrPageNotFound  = errors.New("page_not_found")  // e.g manifest data not contain index path
	ErrNotImplement  = errors.New("method not implement")
)
View Source
var (
	// bucket
	ChunkBucket           = "chunk-bucket"              // key: chunkStartOffset, val: chunk
	TxDataEndOffSetBucket = "tx-data-end-offset-bucket" // key: dataRoot+dataSize; val: txDataEndOffSet
	TxMetaBucket          = "tx-meta-bucket"            // key: txId, val: arTx; not include data
	ConstantsBucket       = "constants-bucket"

	// tasks
	TaskIdPendingPoolBucket = "task-pending-pool-bucket" // key: taskId(taskType+"-"+arId), val: "0x01"
	TaskBucket              = "task-bucket"              // key: taskId(taskType+"-"+arId), val: task

	// bundle bucketName
	BundleItemBinary = "bundle-item-binary"
	BundleItemMeta   = "bundle-item-meta"

	// parse arTx data to bundle items
	BundleWaitParseArIdBucket = "bundle-wait-parse-arId-bucket" // key: arId, val: "0x01"
	BundleArIdToItemIdsBucket = "bundle-arId-to-itemIds-bucket" // key: arId, val: json.marshal(itemIds)

	//statistic
	StatisticBucket = "order-statistic-bucket"
)

Functions

This section is empty.

Types

type AliyunKV added in v1.2.4

type AliyunKV struct {
	UseAliyun bool   `yaml:"useAliyun"`
	Endpoint  string `yaml:"endpoint"`
	AccKey    string `yaml:"accKey"`
	SecretKey string `yaml:"secretKey"`
	Prefix    string `yaml:"prefix"`
}

type ArFee

type ArFee struct {
	Base     int64
	PerChunk int64
}

type AutoApiKey added in v1.0.31

type AutoApiKey struct {
	ID        uint      `gorm:"primarykey" json:"id"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`

	ApiKey       string `gorm:"index:apikey01,unique"`
	EncryptedKey string

	Address      string `gorm:"index:apikey02,unique"`
	PubKey       string
	TokenBalance datatypes.JSONMap // key: symbol,val: balance
}

type Config added in v1.2.4

type Config struct {
	RollupKeyPath  string `yaml:"rollupKeyPath"`
	Pay            string `yaml:"pay"`
	ArNode         string `yaml:"arNode"`
	Mysql          string `yaml:"mysql"`
	Port           string `yaml:"port"`
	Manifest       bool   `yaml:"manifest"`
	NoFee          bool   `yaml:"noFee"`
	BundleInterval int    `yaml:"bundleInterval"`
	Tags           string `yaml:"tags"`

	BoltDir   string    `yaml:"boltDir"`
	S3KV      S3KV      `yaml:"s3KV"`
	AliyunKV  AliyunKV  `yaml:"aliyunKV"`
	MongoDBKV MongoDBKV `yaml:"mongoDBKV"`

	Kafka Kafka `yaml:"kafka"`
}

type DailyStatistic added in v1.1.3

type DailyStatistic struct {
	Date   string `json:"date"`
	Result Result `json:"result"`
}

type Fee

type Fee struct {
	Currency string          `json:"currency"`
	Decimals int             `json:"decimals"`
	Base     decimal.Decimal `json:"base"`
	PerChunk decimal.Decimal `json:"perChunk"`
}

type IndexPath added in v1.0.8

type IndexPath struct {
	Path string `json:"path"`
}

type Kafka added in v1.2.4

type Kafka struct {
	Start bool   `yaml:"start"`
	Uri   string `yaml:"uri"`
}

type KafkaBundleItem added in v1.1.5

type KafkaBundleItem struct {
	SignatureType int         `json:"signatureType"`
	Signature     string      `json:"signature"`
	Owner         string      `json:"owner"`  //  utils.Base64Encode(pubkey)
	Target        string      `json:"target"` // optional, if exist must length 32, and is base64 str
	Anchor        string      `json:"anchor"` // optional, if exist must length 32, and is base64 str
	Tags          []types.Tag `json:"tags"`
	Id            string      `json:"id"`

	Size    int64  `json:"size"`
	Address string `json:"address"`
	Type    string `json:"type"` // data type
}

type KafkaOnChainInfo added in v1.1.5

type KafkaOnChainInfo struct {
	BundleIn  string   `json:"bundleIn"`
	ItemIds   []string `json:"itemIds"`
	Id        string   `json:"id"` // blockId
	Height    int64    `json:"height"`
	Timestamp int64    `json:"timestamp"`
	Previous  string   `json:"previous"`
}

type KafkaOrderInfo added in v1.1.5

type KafkaOrderInfo struct {
	ID       uint
	ItemId   string `json:"itemId"`
	Signer   string `json:"signer"` // item signer
	SignType int    `json:"signType"`
	Size     int64  `json:"size"`
}

type Manifest added in v1.0.13

type Manifest struct {
	ID          uint   `gorm:"primarykey" json:"-"`
	ManifestUrl string `gorm:"index:idxMani0,unique" json:"manifestUrl"`
	ManifestId  string `json:"manifestId"` // arId
}

type ManifestData added in v1.0.8

type ManifestData struct {
	Manifest string              `json:"manifest"` // must be "arweave/paths"
	Version  string              `json:"version"`  // currently "0.1.0"
	Index    IndexPath           `json:"index"`
	Paths    map[string]Resource `json:"paths"`
}

type MongoDBKV added in v1.2.4

type MongoDBKV struct {
	UseMongoDB bool   `yaml:"useMongoDB"`
	Uri        string `yaml:"uri"`
}

type OnChainTx

type OnChainTx struct {
	gorm.Model
	ArId        string
	CurHeight   int64
	BlockId     string
	BlockHeight int64
	DataSize    string
	Reward      string         // onchain arTx reward
	Status      string         // "pending","success"
	ItemIds     datatypes.JSON // json.marshal(itemIds)
	ItemNum     int
	Kafka       bool
}

type Order

type Order struct {
	ID        uint      `gorm:"primarykey" json:"id"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`

	ItemId   string `gorm:"index:idx0" json:"itemId"` // bundleItem id
	Signer   string `gorm:"index:idx1" json:"signer"` // item signer
	SignType int    `json:"signType"`

	Size               int64  `json:"size"`
	Currency           string `json:"currency"` // payment token symbol
	Decimals           int    `json:"decimals"`
	Fee                string `json:"fee"`
	PaymentExpiredTime int64  `json:"paymentExpiredTime"` // uint s
	ExpectedBlock      int64  `json:"expectedBlock"`

	PaymentStatus string `gorm:"index:idx0" json:"paymentStatus"` // "unpaid", "paid", "expired"
	PaymentId     string `json:"paymentId"`                       // everHash

	OnChainStatus string `gorm:"index:idx5" json:"onChainStatus"` // "waiting","pending","success","failed"
	ApiKey        string `gorm:"index:idx2" json:"-"`
	Sort          bool   `json:"sort"`                     // upload items to arweave by sequence
	Kafka         bool   `gorm:"index:idx0"  json:"kafka"` // send to kafka
}

type OrderStatistic added in v1.1.3

type OrderStatistic struct {
	ID            uint      `gorm:"primarykey"`
	Date          time.Time `json:"date"`
	Totals        int64     `json:"totals"`
	TotalDataSize int64     `json:"totalDataSize"`
}

type PaymentMeta added in v1.2.3

type PaymentMeta struct {
	AppName string   `json:"appName"`
	Action  string   `json:"action"`
	ItemIds []string `json:"itemIds"`
}

type PeerCount

type PeerCount struct {
	Peer  string
	Count int64
}

type Range added in v1.1.3

type Range struct {
	Start string
	End   string
}

type ReceiptEverTx

type ReceiptEverTx struct {
	RawId    uint64 `grom:"primarykey"` // everTx rawId
	EverHash string `gorm:"unique"`
	Nonce    int64  // ms
	Symbol   string
	TokenTag string
	From     string
	Amount   string
	Data     string
	Sig      string

	Status string //  "unspent","spent", "unrefund", "refund"
	ErrMsg string
}

type ResBundler

type ResBundler struct {
	Bundler string `json:"bundler"`
}

type Resource added in v1.0.8

type Resource struct {
	TxId string `json:"id"`
}

type RespApiKey added in v1.0.31

type RespApiKey struct {
	EstimateCap string            `json:"estimateCap"`
	Tokens      map[string]TokBal `json:"tokens"` // tokenTag
}

type RespErr

type RespErr struct {
	Err string `json:"error"`
}

func (RespErr) Error

func (r RespErr) Error() string

type RespFee

type RespFee struct {
	Currency string `json:"currency"`
	Decimals int    `json:"decimals"`
	FinalFee string `json:"finalFee"` // uint
}

type RespGetOrder added in v1.1.8

type RespGetOrder struct {
	ID uint `json:"id"`
	RespOrder
	PaymentStatus string `json:"paymentStatus"` // "unpaid", "paid", "expired"
	PaymentId     string `json:"paymentId"`
	OnChainStatus string `json:"onChainStatus"` // "waiting","pending","success","failed"
	Sort          bool   `json:"sort"`
}

type RespItemId added in v1.0.7

type RespItemId struct {
	ItemId string `json:"itemId"` // bundleItem id
	Size   int64  `json:"size"`
}

type RespOrder

type RespOrder struct {
	ItemId             string `json:"itemId"` // bundleItem id
	Size               int64  `json:"size"`
	Bundler            string `json:"bundler"`  // fee receiver address
	Currency           string `json:"currency"` // payment token symbol
	Decimals           int    `json:"decimals"`
	Fee                string `json:"fee"`
	PaymentExpiredTime int64  `json:"paymentExpiredTime"`
	ExpectedBlock      int64  `json:"expectedBlock"`
}

type RespReceiptEverTx added in v1.1.2

type RespReceiptEverTx struct {
	RawId     uint64 `json:"rawId"` // everTx rawId
	EverHash  string `json:"everHash"`
	Timestamp int64  `json:"timestamp"` // ms
	Symbol    string `json:"symbol"`
	Amount    string `json:"amount"`
	Decimals  int    `json:"decimals"`
}

type Result added in v1.1.3

type Result struct {
	Status        string `json:"status"`
	Totals        int64  `json:"totals"`
	TotalDataSize int64  `json:"totalDataSize"`
}

type S3KV added in v1.2.4

type S3KV struct {
	UseS3     bool   `yaml:"useS3"`
	User4Ever bool   `yaml:"user4Ever"`
	AccKey    string `yaml:"accKey"`
	SecretKey string `yaml:"secretKey"`
	Prefix    string `yaml:"prefix"`
	Region    string `yaml:"region"`
	Endpoint  string `yaml:"endpoint"`
}

type Task

type Task struct {
	ArId           string `json:"arId"`
	TaskType       string `json:"taskType"`
	CountSuccessed int64  `json:"countSuccessed"`
	CountFailed    int64  `json:"countFailed"`
	TotalPeer      int    `json:"totalPeer"`
	Timestamp      int64  `json:"timestamp"` // begin timestamp
	Close          bool   `json:"close"`
}

type TimeRange added in v1.1.3

type TimeRange struct {
	Start time.Time
	End   time.Time
}

type TokBal added in v1.1.0

type TokBal struct {
	Symbol   string `json:"symbol"`
	Decimals int    `json:"decimals"`
	Balance  string `json:"balance"`
}

type TokenPrice

type TokenPrice struct {
	Symbol    string `gorm:"primarykey"` // token symbol
	Decimals  int
	Price     float64 // unit is USD
	ManualSet bool    // manual set
	UpdatedAt time.Time
}

Jump to

Keyboard shortcuts

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