arseeding

package module
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: 64 Imported by: 0

README

Arseeding

Arseeding has been handed over to the Permadao community for development and maintenance.
To obtain the latest code, please visit repo.

Documentation

Index

Constants

View Source
const (
	ItemPaymentAction   = "payment"
	ApikeyPaymentAction = "apikeyPayment"
)
View Source
const (
	ItemTopic  = "arseeding_transaction"
	BlockTopic = "arseeding_block"
)
View Source
const (
	MetricNameSpace = "arseeding"
)

Variables

View Source
var (
	ERR_TOO_MANY_REQUESTS = errors.New("err_limit_exceeded")
	MANIFEST_ID_NOT_FOUND = errors.New("err_manifest_id_not_found")
)

Functions

func Base64Address added in v1.1.5

func Base64Address(pubkey string) (string, error)

func CORSMiddleware added in v1.0.13

func CORSMiddleware() gin.HandlerFunc

func LimiterMiddleware added in v1.0.13

func LimiterMiddleware(limit int, period string, ipRateWhitelist *map[string]struct{}) gin.HandlerFunc

LimiterMiddleware period: "S"<Second>,"M"<Minute>,"H"<Hour>,"D"<Day>; limit: limit frequency

func ManifestMiddleware added in v1.0.13

func ManifestMiddleware(s *Arseeding) gin.HandlerFunc

func NewKWriters added in v1.1.5

func NewKWriters(uri string) (map[string]*KWriter, error)

Types

type Arseeding added in v1.0.0

type Arseeding struct {
	KWriters map[string]*KWriter // key: topic

	NoFee          bool // if true, means no bundle fee; default false
	EnableManifest bool
	// contains filtered or unexported fields
}

func New

func New(
	boltDirPath, mySqlDsn string, sqliteDir string, useSqlite bool,
	arWalletKeyPath string, arNode, payUrl string, noFee bool, enableManifest bool,
	useS3 bool, s3AccKey, s3SecretKey, s3BucketPrefix, s3Region, s3Endpoint string,
	use4EVER bool, useAliyun bool, aliyunEndpoint, aliyunAccKey, aliyunSecretKey, aliyunPrefix string,
	useMongoDb bool, mongodbUri string,
	port string, customTags []types.Tag, useKafka bool, kafkaUri string,
) *Arseeding

func (*Arseeding) CalcItemFee added in v1.0.0

func (s *Arseeding) CalcItemFee(currency string, itemSize int64) (*schema.RespFee, error)

func (*Arseeding) Close added in v1.1.5

func (s *Arseeding) Close()

func (*Arseeding) DelItem added in v1.0.0

func (s *Arseeding) DelItem(itemId string) error

func (*Arseeding) FetchAndStoreTx added in v1.0.0

func (s *Arseeding) FetchAndStoreTx(arId string) (err error)

func (*Arseeding) GetBundlePerFees added in v1.0.0

func (s *Arseeding) GetBundlePerFees() (map[string]schema.Fee, error)

func (*Arseeding) GetPerFee added in v1.0.31

func (s *Arseeding) GetPerFee(tokenSymbol string) *schema.Fee

func (*Arseeding) ParseAndSaveBundleItems added in v1.0.0

func (s *Arseeding) ParseAndSaveBundleItems(arId string, data []byte) error

func (*Arseeding) ProcessSubmitItem added in v1.0.0

func (s *Arseeding) ProcessSubmitItem(item types.BundleItem, currency string, isNoFeeMode bool, apiKey string, isSort bool, size int64) (schema.Order, error)

func (*Arseeding) ProduceDailyStatistic added in v1.1.3

func (s *Arseeding) ProduceDailyStatistic()

func (*Arseeding) Run added in v1.0.0

func (s *Arseeding) Run(port string, bundleInterval int)

func (*Arseeding) SaveSubmitChunk added in v1.0.0

func (s *Arseeding) SaveSubmitChunk(chunk types.GetChunk) error

func (*Arseeding) SaveSubmitTx added in v1.0.0

func (s *Arseeding) SaveSubmitTx(arTx types.Transaction) error

func (*Arseeding) SetPerFee added in v1.0.31

func (s *Arseeding) SetPerFee(feeMap map[string]schema.Fee)

func (*Arseeding) UpdateRealTime added in v1.1.3

func (s *Arseeding) UpdateRealTime()

type Cache added in v1.0.0

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

func NewCache added in v1.0.0

func NewCache(arCli *goar.Client, peerMap map[string]int64) *Cache

func (*Cache) GetAnchor added in v1.0.0

func (c *Cache) GetAnchor() string

func (*Cache) GetConstTx added in v1.0.0

func (c *Cache) GetConstTx() *types.Transaction

func (*Cache) GetFee added in v1.0.0

func (c *Cache) GetFee() schema.ArFee

func (*Cache) GetInfo added in v1.0.0

func (c *Cache) GetInfo() types.NetworkInfo

func (*Cache) GetPeerMap added in v1.0.0

func (c *Cache) GetPeerMap() map[string]int64

func (*Cache) GetPeers added in v1.0.0

func (c *Cache) GetPeers() []string

func (*Cache) UpdateAnchor added in v1.0.0

func (c *Cache) UpdateAnchor(anchor string)

func (*Cache) UpdateFee added in v1.0.0

func (c *Cache) UpdateFee(price schema.ArFee)

func (*Cache) UpdateInfo added in v1.0.0

func (c *Cache) UpdateInfo(info types.NetworkInfo)

func (*Cache) UpdatePeers added in v1.0.0

func (c *Cache) UpdatePeers(peerMap map[string]int64)

type KWriter added in v1.1.5

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

func NewKWriter added in v1.1.5

func NewKWriter(topic string, uri string) (*KWriter, error)

func (*KWriter) Close added in v1.1.5

func (kw *KWriter) Close()

func (*KWriter) Write added in v1.1.5

func (kw *KWriter) Write(body []byte) error

type Store

type Store struct {
	KVDb rawdb.KeyValueDB
}

func NewAliyunStore added in v1.0.27

func NewAliyunStore(endpoint, accKey, secretKey, bucketPrefix string) (*Store, error)

func NewBoltStore added in v1.0.0

func NewBoltStore(boltDirPath string) (*Store, error)

func NewMongoDBStore added in v1.1.3

func NewMongoDBStore(ctx context.Context, uri string) (*Store, error)

func NewS3Store added in v1.0.0

func NewS3Store(accKey, secretKey, region, bucketPrefix, endpoint string) (*Store, error)

func (*Store) AtomicDelItem added in v1.0.0

func (s *Store) AtomicDelItem(itemId string) (err error)

func (*Store) AtomicSaveItem added in v1.0.0

func (s *Store) AtomicSaveItem(item types.BundleItem) (err error)

about bundle

func (*Store) AtomicSyncDataEndOffset added in v1.0.0

func (s *Store) AtomicSyncDataEndOffset(preEndOffset, newEndOffset uint64, dataRoot, dataSize string) error

func (*Store) Close

func (s *Store) Close() error

func (*Store) DelItemBinary added in v1.0.0

func (s *Store) DelItemBinary(itemId string) (err error)

func (*Store) DelItemMeta added in v1.0.0

func (s *Store) DelItemMeta(itemId string) (err error)

func (*Store) DelParsedBundleArId added in v1.0.0

func (s *Store) DelParsedBundleArId(arId string) error

func (*Store) DelPendingPoolTaskId added in v1.0.0

func (s *Store) DelPendingPoolTaskId(taskId string) error

func (*Store) ExistArIdToItemIds added in v1.0.0

func (s *Store) ExistArIdToItemIds(arId string) bool

func (*Store) GetRealTimeStatistic added in v1.1.3

func (s *Store) GetRealTimeStatistic() ([]byte, error)

func (*Store) IsExistChunk

func (s *Store) IsExistChunk(chunkStartOffset uint64) bool

func (*Store) IsExistItemBinary added in v1.0.0

func (s *Store) IsExistItemBinary(itemId string) bool

func (*Store) IsExistPeers added in v1.0.0

func (s *Store) IsExistPeers() bool

func (*Store) IsExistTxDataEndOffset

func (s *Store) IsExistTxDataEndOffset(dataRoot, dataSize string) bool

func (*Store) IsExistTxMeta

func (s *Store) IsExistTxMeta(arId string) bool

func (*Store) LoadAllDataEndOffset

func (s *Store) LoadAllDataEndOffset() (offset uint64)

func (*Store) LoadAllPendingTaskIds added in v1.0.0

func (s *Store) LoadAllPendingTaskIds() ([]string, error)

func (*Store) LoadArIdToItemIds added in v1.0.0

func (s *Store) LoadArIdToItemIds(arId string) (itemIds []string, err error)

func (*Store) LoadChunk

func (s *Store) LoadChunk(chunkStartOffset uint64) (chunk *types.GetChunk, err error)

func (*Store) LoadItemBinary added in v1.0.0

func (s *Store) LoadItemBinary(itemId string) (binaryReader *os.File, itemBinary []byte, err error)

func (*Store) LoadItemMeta added in v1.0.0

func (s *Store) LoadItemMeta(itemId string) (meta types.BundleItem, err error)

func (*Store) LoadPeers added in v1.0.0

func (s *Store) LoadPeers() (peers map[string]int64, err error)

func (*Store) LoadTask added in v1.0.0

func (s *Store) LoadTask(taskId string) (tk *schema.Task, err error)

func (*Store) LoadTxDataEndOffSet

func (s *Store) LoadTxDataEndOffSet(dataRoot, dataSize string) (txDataEndOffset uint64, err error)

func (*Store) LoadTxMeta

func (s *Store) LoadTxMeta(arId string) (arTx *types.Transaction, err error)

func (*Store) LoadWaitParseBundleArIds added in v1.0.0

func (s *Store) LoadWaitParseBundleArIds() (arIds []string, err error)

func (*Store) PutTaskPendingPool added in v1.0.0

func (s *Store) PutTaskPendingPool(taskId string) error

func (*Store) RollbackAllDataEndOffset added in v1.0.0

func (s *Store) RollbackAllDataEndOffset(preDataEndOffset uint64) (err error)

func (*Store) SaveAllDataEndOffset

func (s *Store) SaveAllDataEndOffset(allDataEndOffset uint64) (err error)

func (*Store) SaveArIdToItemIds added in v1.0.0

func (s *Store) SaveArIdToItemIds(arId string, itemIds []string) error

func (*Store) SaveChunk

func (s *Store) SaveChunk(chunkStartOffset uint64, chunk types.GetChunk) error

func (*Store) SaveItemBinary added in v1.0.0

func (s *Store) SaveItemBinary(item types.BundleItem) (err error)

func (*Store) SaveItemMeta added in v1.0.0

func (s *Store) SaveItemMeta(item types.BundleItem) (err error)

func (*Store) SavePeers added in v1.0.0

func (s *Store) SavePeers(peers map[string]int64) error

func (*Store) SaveTask added in v1.0.0

func (s *Store) SaveTask(taskId string, tk schema.Task) error

func (*Store) SaveTxDataEndOffSet

func (s *Store) SaveTxDataEndOffSet(dataRoot, dataSize string, txDataEndOffset uint64) (err error)

func (*Store) SaveTxMeta

func (s *Store) SaveTxMeta(arTx types.Transaction) error

func (*Store) SaveWaitParseBundleArId added in v1.0.0

func (s *Store) SaveWaitParseBundleArId(arId string) error

func (*Store) UpdateRealTimeStatistic added in v1.1.3

func (s *Store) UpdateRealTimeStatistic(data []byte) error

type TaskManager added in v1.0.0

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

func NewTaskMg added in v1.0.0

func NewTaskMg() *TaskManager

func (*TaskManager) AddTask added in v1.0.0

func (m *TaskManager) AddTask(arid, taskType string)

func (*TaskManager) BroadcastData added in v1.0.0

func (m *TaskManager) BroadcastData(arId, taskType string, tx *types.Transaction, peers []string, txPosted bool)

func (*TaskManager) BroadcastTxMeta added in v1.0.0

func (m *TaskManager) BroadcastTxMeta(arId, taskType string, tx *types.Transaction, peers []string)

func (*TaskManager) CloseTask added in v1.0.0

func (m *TaskManager) CloseTask(arid, taskType string) error

func (*TaskManager) DelTask added in v1.0.0

func (m *TaskManager) DelTask(arid, taskType string)

func (*TaskManager) GetTask added in v1.0.0

func (m *TaskManager) GetTask(arid, taskType string) *schema.Task

func (*TaskManager) GetTasks added in v1.0.0

func (m *TaskManager) GetTasks() (tasks map[string]schema.Task)

func (*TaskManager) GetTxDataFromPeers added in v1.0.0

func (m *TaskManager) GetTxDataFromPeers(arId, taskType string, peers []string) ([]byte, error)

func (*TaskManager) GetUnconfirmedTxFromPeers added in v1.0.0

func (m *TaskManager) GetUnconfirmedTxFromPeers(arId, taskType string, peers []string) (*types.Transaction, error)

func (*TaskManager) IncFailed added in v1.0.0

func (m *TaskManager) IncFailed(arid, taskType string)

func (*TaskManager) IncSuccessed added in v1.0.0

func (m *TaskManager) IncSuccessed(arid, taskType string)

func (*TaskManager) InitTaskMg added in v1.0.0

func (m *TaskManager) InitTaskMg(boltDb *Store) error

func (*TaskManager) IsClosed added in v1.0.0

func (m *TaskManager) IsClosed(arid, taskType string) bool

func (*TaskManager) PopTkChan added in v1.0.0

func (m *TaskManager) PopTkChan() <-chan string

func (*TaskManager) PutToTkChan added in v1.0.0

func (m *TaskManager) PutToTkChan(arId, taskType string)

func (*TaskManager) TaskBeginSet added in v1.0.0

func (m *TaskManager) TaskBeginSet(arid, taskType string, totalPeer int) error

type Wdb added in v1.0.0

type Wdb struct {
	Db *gorm.DB
}

func NewMysqlDb added in v1.0.23

func NewMysqlDb(dsn string) *Wdb

func NewSqliteDb added in v1.0.23

func NewSqliteDb(dbDir string) *Wdb

func (*Wdb) DelManifest added in v1.0.18

func (w *Wdb) DelManifest(id string) error

func (*Wdb) ExistApikey added in v1.0.31

func (w *Wdb) ExistApikey(addr string) (bool, schema.AutoApiKey)

func (*Wdb) ExistPaidOrd added in v1.0.15

func (w *Wdb) ExistPaidOrd(itemId string) bool

func (*Wdb) ExistProcessedOrderItem added in v1.0.0

func (w *Wdb) ExistProcessedOrderItem(itemId string) (res schema.Order, exist bool)

func (*Wdb) GetApiKeyDepositRecords added in v1.1.2

func (w *Wdb) GetApiKeyDepositRecords(addr string, cursorId int64, num int) ([]schema.ReceiptEverTx, error)

func (*Wdb) GetApiKeyDetail added in v1.0.31

func (w *Wdb) GetApiKeyDetail(key string) (schema.AutoApiKey, error)

func (*Wdb) GetApiKeyDetailByAddress added in v1.0.31

func (w *Wdb) GetApiKeyDetailByAddress(addr string) (res schema.AutoApiKey, err error)

func (*Wdb) GetArPrice added in v1.0.0

func (w *Wdb) GetArPrice() (float64, error)

func (*Wdb) GetArTxByStatus added in v1.0.0

func (w *Wdb) GetArTxByStatus(status string) ([]schema.OnChainTx, error)

func (*Wdb) GetDailyStatisticByDate added in v1.1.3

func (w *Wdb) GetDailyStatisticByDate(r schema.TimeRange) ([]schema.Result, error)

func (*Wdb) GetExpiredOrders added in v1.0.0

func (w *Wdb) GetExpiredOrders() ([]schema.Order, error)

func (*Wdb) GetKafkaOnChains added in v1.1.5

func (w *Wdb) GetKafkaOnChains() ([]schema.OnChainTx, error)

func (*Wdb) GetKafkaOrderInfos added in v1.1.5

func (w *Wdb) GetKafkaOrderInfos() ([]schema.KafkaOrderInfo, error)

func (*Wdb) GetLastEverRawId added in v1.0.0

func (w *Wdb) GetLastEverRawId() (uint64, error)

func (*Wdb) GetManifestId added in v1.0.13

func (w *Wdb) GetManifestId(mfUrl string) (string, error)

func (*Wdb) GetNeedOnChainOrders added in v1.0.0

func (w *Wdb) GetNeedOnChainOrders() ([]schema.Order, error)

func (*Wdb) GetNeedOnChainOrdersSorted added in v1.0.22

func (w *Wdb) GetNeedOnChainOrdersSorted() ([]schema.Order, error)

func (*Wdb) GetOrderRealTimeStatistic added in v1.1.3

func (w *Wdb) GetOrderRealTimeStatistic() ([]byte, error)

func (*Wdb) GetOrderStatisticByDate added in v1.1.3

func (w *Wdb) GetOrderStatisticByDate(r schema.Range) ([]*schema.DailyStatistic, error)

func (*Wdb) GetOrdersByApiKey added in v1.0.7

func (w *Wdb) GetOrdersByApiKey(apiKey string, cursorId int64, pageSize int, sort string) ([]schema.Order, error)

func (*Wdb) GetOrdersBySigner added in v1.0.0

func (w *Wdb) GetOrdersBySigner(signer string, cursorId int64, num int) ([]schema.Order, error)

func (*Wdb) GetPrices added in v1.0.0

func (w *Wdb) GetPrices() ([]schema.TokenPrice, error)

func (*Wdb) GetReceiptsByStatus added in v1.0.0

func (w *Wdb) GetReceiptsByStatus(status string) ([]schema.ReceiptEverTx, error)

func (*Wdb) GetUnPaidOrder added in v1.0.0

func (w *Wdb) GetUnPaidOrder(itemId string) (schema.Order, error)

func (*Wdb) InsertApiKey added in v1.0.31

func (w *Wdb) InsertApiKey(ak schema.AutoApiKey) error

func (*Wdb) InsertArTx added in v1.0.0

func (w *Wdb) InsertArTx(tx schema.OnChainTx) error

func (*Wdb) InsertManifest added in v1.0.13

func (w *Wdb) InsertManifest(mf schema.Manifest) error

func (*Wdb) InsertOrder added in v1.0.0

func (w *Wdb) InsertOrder(order schema.Order) error

func (*Wdb) InsertPrices added in v1.0.0

func (w *Wdb) InsertPrices(tps []schema.TokenPrice) error

func (*Wdb) InsertReceiptTx added in v1.0.0

func (w *Wdb) InsertReceiptTx(tx schema.ReceiptEverTx) error

func (*Wdb) IsLatestUnpaidOrd added in v1.0.15

func (w *Wdb) IsLatestUnpaidOrd(itemId string, CurExpiredTime int64) bool

func (*Wdb) KafkaDone added in v1.1.5

func (w *Wdb) KafkaDone(id uint) error

func (*Wdb) KafkaOnChainDone added in v1.1.5

func (w *Wdb) KafkaOnChainDone(id uint) error

func (*Wdb) Migrate added in v1.0.0

func (w *Wdb) Migrate(noFee, enableManifest bool) error

func (*Wdb) UpdateApikeyTokenBal added in v1.0.31

func (w *Wdb) UpdateApikeyTokenBal(addr string, newTokBal datatypes.JSONMap) error

func (*Wdb) UpdateArTx added in v1.0.0

func (w *Wdb) UpdateArTx(id uint, arId string, curHeight int64, dataSize, reward string, status string) error

func (*Wdb) UpdateArTxStatus added in v1.0.0

func (w *Wdb) UpdateArTxStatus(arId, status string, arTxStatus *types.TxStatus, tx *gorm.DB) error

func (*Wdb) UpdateOrdOnChainStatus added in v1.0.0

func (w *Wdb) UpdateOrdOnChainStatus(itemId, status string, tx *gorm.DB) error

func (*Wdb) UpdateOrdToExpiredStatus added in v1.0.0

func (w *Wdb) UpdateOrdToExpiredStatus(id uint) error

func (*Wdb) UpdateOrderPay added in v1.0.0

func (w *Wdb) UpdateOrderPay(id uint, everHash string, paymentStatus string, tx *gorm.DB) error

func (*Wdb) UpdatePrice added in v1.0.0

func (w *Wdb) UpdatePrice(symbol string, newPrice float64) error

func (*Wdb) UpdateReceiptStatus added in v1.0.0

func (w *Wdb) UpdateReceiptStatus(rawId uint64, status string, tx *gorm.DB) error

func (*Wdb) UpdateRefundErr added in v1.0.0

func (w *Wdb) UpdateRefundErr(rawId uint64, errMsg string) error

func (*Wdb) WhetherExec added in v1.1.3

func (w *Wdb) WhetherExec(r schema.TimeRange) bool

Jump to

Keyboard shortcuts

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