Versions in this module Expand all Collapse all v1 v1.1.1 Apr 6, 2023 Changes in this version + const ApikeyPaymentAction + const ItemPaymentAction + const MetricNameSpace + var ERR_TOO_MANY_REQUESTS = errors.New("err_limit_exceeded") + var MANIFEST_ID_NOT_FOUND = errors.New("err_manifest_id_not_found") + func CORSMiddleware() gin.HandlerFunc + func LimiterMiddleware(limit int, period string, ipRateWhitelist *map[string]struct{}) gin.HandlerFunc + func ManifestMiddleware(wdb *Wdb, store *Store) gin.HandlerFunc + type Arseeding struct + EnableManifest bool + NoFee bool + func New(boltDirPath, mySqlDsn string, sqliteDir string, useSqlite bool, ...) *Arseeding + func (s *Arseeding) CalcItemFee(currency string, itemSize int64) (*schema.RespFee, error) + func (s *Arseeding) DelItem(itemId string) error + func (s *Arseeding) FetchAndStoreTx(arId string) (err error) + func (s *Arseeding) GetBundlePerFees() (map[string]schema.Fee, error) + func (s *Arseeding) GetPerFee(tokenSymbol string) *schema.Fee + func (s *Arseeding) ParseAndSaveBundleItems(arId string, data []byte) error + func (s *Arseeding) ProcessSubmitItem(item types.BundleItem, currency string, isNoFeeMode bool, apiKey string, ...) (schema.Order, error) + func (s *Arseeding) Run(port string, bundleInterval int) + func (s *Arseeding) SaveSubmitChunk(chunk types.GetChunk) error + func (s *Arseeding) SaveSubmitTx(arTx types.Transaction) error + func (s *Arseeding) SetPerFee(feeMap map[string]schema.Fee) + type Cache struct + func NewCache(arCli *goar.Client, peerMap map[string]int64) *Cache + func (c *Cache) GetAnchor() string + func (c *Cache) GetConstTx() *types.Transaction + func (c *Cache) GetFee() schema.ArFee + func (c *Cache) GetInfo() types.NetworkInfo + func (c *Cache) GetPeerMap() map[string]int64 + func (c *Cache) GetPeers() []string + func (c *Cache) UpdateAnchor(anchor string) + func (c *Cache) UpdateFee(price schema.ArFee) + func (c *Cache) UpdateInfo(info types.NetworkInfo) + func (c *Cache) UpdatePeers(peerMap map[string]int64) + type Store struct + KVDb rawdb.KeyValueDB + func NewAliyunStore(endpoint, accKey, secretKey, bucketPrefix string) (*Store, error) + func NewBoltStore(boltDirPath string) (*Store, error) + func NewS3Store(accKey, secretKey, region, bucketPrefix, endpoint string) (*Store, error) + func (s *Store) AtomicDelItem(itemId string) (err error) + func (s *Store) AtomicSaveItem(item types.BundleItem) (err error) + func (s *Store) AtomicSyncDataEndOffset(preEndOffset, newEndOffset uint64, dataRoot, dataSize string) error + func (s *Store) Close() error + func (s *Store) DelItemBinary(itemId string) (err error) + func (s *Store) DelItemMeta(itemId string) (err error) + func (s *Store) DelParsedBundleArId(arId string) error + func (s *Store) DelPendingPoolTaskId(taskId string) error + func (s *Store) ExistArIdToItemIds(arId string) bool + func (s *Store) IsExistChunk(chunkStartOffset uint64) bool + func (s *Store) IsExistItemBinary(itemId string) bool + func (s *Store) IsExistPeers() bool + func (s *Store) IsExistTxDataEndOffset(dataRoot, dataSize string) bool + func (s *Store) IsExistTxMeta(arId string) bool + func (s *Store) LoadAllDataEndOffset() (offset uint64) + func (s *Store) LoadAllPendingTaskIds() ([]string, error) + func (s *Store) LoadArIdToItemIds(arId string) (itemIds []string, err error) + func (s *Store) LoadChunk(chunkStartOffset uint64) (chunk *types.GetChunk, err error) + func (s *Store) LoadItemBinary(itemId string) (binaryReader *os.File, itemBinary []byte, err error) + func (s *Store) LoadItemMeta(itemId string) (meta types.BundleItem, err error) + func (s *Store) LoadPeers() (peers map[string]int64, err error) + func (s *Store) LoadTask(taskId string) (tk *schema.Task, err error) + func (s *Store) LoadTxDataEndOffSet(dataRoot, dataSize string) (txDataEndOffset uint64, err error) + func (s *Store) LoadTxMeta(arId string) (arTx *types.Transaction, err error) + func (s *Store) LoadWaitParseBundleArIds() (arIds []string, err error) + func (s *Store) PutTaskPendingPool(taskId string) error + func (s *Store) RollbackAllDataEndOffset(preDataEndOffset uint64) (err error) + func (s *Store) SaveAllDataEndOffset(allDataEndOffset uint64) (err error) + func (s *Store) SaveArIdToItemIds(arId string, itemIds []string) error + func (s *Store) SaveChunk(chunkStartOffset uint64, chunk types.GetChunk) error + func (s *Store) SaveItemBinary(item types.BundleItem) (err error) + func (s *Store) SaveItemMeta(item types.BundleItem) (err error) + func (s *Store) SavePeers(peers map[string]int64) error + func (s *Store) SaveTask(taskId string, tk schema.Task) error + func (s *Store) SaveTxDataEndOffSet(dataRoot, dataSize string, txDataEndOffset uint64) (err error) + func (s *Store) SaveTxMeta(arTx types.Transaction) error + func (s *Store) SaveWaitParseBundleArId(arId string) error + type TaskManager struct + func NewTaskMg() *TaskManager + func (m *TaskManager) AddTask(arid, taskType string) + func (m *TaskManager) BroadcastData(arId, taskType string, tx *types.Transaction, peers []string, txPosted bool) + func (m *TaskManager) BroadcastTxMeta(arId, taskType string, tx *types.Transaction, peers []string) + func (m *TaskManager) CloseTask(arid, taskType string) error + func (m *TaskManager) DelTask(arid, taskType string) + func (m *TaskManager) GetTask(arid, taskType string) *schema.Task + func (m *TaskManager) GetTasks() (tasks map[string]schema.Task) + func (m *TaskManager) GetTxDataFromPeers(arId, taskType string, peers []string) ([]byte, error) + func (m *TaskManager) GetUnconfirmedTxFromPeers(arId, taskType string, peers []string) (*types.Transaction, error) + func (m *TaskManager) IncFailed(arid, taskType string) + func (m *TaskManager) IncSuccessed(arid, taskType string) + func (m *TaskManager) InitTaskMg(boltDb *Store) error + func (m *TaskManager) IsClosed(arid, taskType string) bool + func (m *TaskManager) PopTkChan() <-chan string + func (m *TaskManager) PutToTkChan(arId, taskType string) + func (m *TaskManager) TaskBeginSet(arid, taskType string, totalPeer int) error + type Wdb struct + Db *gorm.DB + func NewMysqlDb(dsn string) *Wdb + func NewSqliteDb(dbDir string) *Wdb + func (w *Wdb) DelManifest(id string) error + func (w *Wdb) ExistApikey(addr string) (bool, schema.AutoApiKey) + func (w *Wdb) ExistPaidOrd(itemId string) bool + func (w *Wdb) ExistProcessedOrderItem(itemId string) (res schema.Order, exist bool) + func (w *Wdb) GetApiKeyDetail(key string) (schema.AutoApiKey, error) + func (w *Wdb) GetApiKeyDetailByAddress(addr string) (res schema.AutoApiKey, err error) + func (w *Wdb) GetArPrice() (float64, error) + func (w *Wdb) GetArTxByStatus(status string) ([]schema.OnChainTx, error) + func (w *Wdb) GetExpiredOrders() ([]schema.Order, error) + func (w *Wdb) GetLastEverRawId() (uint64, error) + func (w *Wdb) GetManifestId(mfUrl string) (string, error) + func (w *Wdb) GetNeedOnChainOrders() ([]schema.Order, error) + func (w *Wdb) GetNeedOnChainOrdersSorted() ([]schema.Order, error) + func (w *Wdb) GetOrdersByApiKey(apiKey string, cursorId int64, pageSize int, sort string) ([]schema.Order, error) + func (w *Wdb) GetOrdersBySigner(signer string, cursorId int64, num int) ([]schema.Order, error) + func (w *Wdb) GetPrices() ([]schema.TokenPrice, error) + func (w *Wdb) GetReceiptsByStatus(status string) ([]schema.ReceiptEverTx, error) + func (w *Wdb) GetUnPaidOrder(itemId string) (schema.Order, error) + func (w *Wdb) InsertApiKey(ak schema.AutoApiKey) error + func (w *Wdb) InsertArTx(tx schema.OnChainTx) error + func (w *Wdb) InsertManifest(mf schema.Manifest) error + func (w *Wdb) InsertOrder(order schema.Order) error + func (w *Wdb) InsertPrices(tps []schema.TokenPrice) error + func (w *Wdb) InsertReceiptTx(tx schema.ReceiptEverTx) error + func (w *Wdb) IsLatestUnpaidOrd(itemId string, CurExpiredTime int64) bool + func (w *Wdb) Migrate(noFee, enableManifest bool) error + func (w *Wdb) UpdateApikeyTokenBal(addr string, newTokBal datatypes.JSONMap) error + func (w *Wdb) UpdateArTx(id uint, arId string, curHeight int64, dataSize, reward string, status string) error + func (w *Wdb) UpdateArTxStatus(arId, status string, tx *gorm.DB) error + func (w *Wdb) UpdateOrdOnChainStatus(itemId, status string, tx *gorm.DB) error + func (w *Wdb) UpdateOrdToExpiredStatus(id uint) error + func (w *Wdb) UpdateOrderPay(id uint, everHash string, paymentStatus string, tx *gorm.DB) error + func (w *Wdb) UpdatePrice(symbol string, newPrice float64) error + func (w *Wdb) UpdateReceiptStatus(rawId uint64, status string, tx *gorm.DB) error + func (w *Wdb) UpdateRefundErr(rawId uint64, errMsg string) error