Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApiRequester ¶
type ApiRequester interface { GetChainNftMintTimestamp(ctx context.Context, denomId, tokenId string) (int64, error) GetPayoutAddressFromNode(ctx context.Context, cudosAddress, network string) (string, error) GetDenomNftTransferHistory(ctx context.Context, collectionDenomId string, lastPaymentTimestamp, periodEnd int64) ([]types.NftTransferEvent, error) GetHasuraCollectionNftMintEvents(ctx context.Context, collectionDenomId string) (types.NftMintHistory, error) GetFarmTotalHashPowerFromPoolToday(ctx context.Context, farmName, sinceTimestamp string) (float64, error) GetFarmStartTime(ctx context.Context, farmName string) (int64, error) GetFarmCollectionsFromHasura(ctx context.Context, farmId int64) (types.CollectionData, error) VerifyCollection(ctx context.Context, denomId string) (bool, error) GetFarmCollectionsWithNFTs(ctx context.Context, denomIds []string) ([]types.Collection, error) SendMany(ctx context.Context, destinationAddressesWithAmount map[string]float64) (string, error) BumpFee(ctx context.Context, txId string) (string, error) GetWalletTransaction(ctx context.Context, txId string) (*types.BtcWalletTransaction, error) }
type BtcClient ¶
type BtcClient interface { LoadWallet(walletName string) (*btcjson.LoadWalletResult, error) UnloadWallet(walletName *string) error WalletPassphrase(passphrase string, timeoutSecs int64) error WalletLock() error GetRawTransactionVerbose(txHash *chainhash.Hash) (*btcjson.TxRawResult, error) ListUnspent() ([]btcjson.ListUnspentResult, error) GetBalance(account string) (btcutil.Amount, error) RawRequest(method string, params []json.RawMessage) (json.RawMessage, error) }
type CollectionProcessResult ¶
type CollectionProcessResult struct { CUDOMaintenanceFeeBtcDecimal decimal.Decimal FarmMaintenanceFeeBtcDecimal decimal.Decimal NftRewardsAfterFeesBtcDecimal decimal.Decimal CollectionPaymentAllocation types.CollectionPaymentAllocation NftStatistics []types.NFTStatistics }
type InfrastructureHelper ¶ added in v1.0.8
type NftProcessResult ¶
type NftProcessResult struct { CudoPartOfMaintenanceFeeBtcDecimal decimal.Decimal MaintenanceFeeBtcDecimal decimal.Decimal RewardForNftAfterFeeBtcDecimal decimal.Decimal AllNftOwnersForTimePeriodWithRewardPercent map[string]float64 NftOwnersForPeriod []types.NFTOwnerInformation NftPeriodStart int64 NftPeriodEnd int64 }
type PayService ¶
type PayService struct {
// contains filtered or unexported fields
}
func NewPayService ¶
func NewPayService(config *infrastructure.Config, apiRequester ApiRequester, helper InfrastructureHelper, btcNetworkParams *types.BtcNetworkParams) *PayService
func (*PayService) Execute ¶
Processes all approved farms by iterating through them and calling the processFarm function for each farm. In case of an error while processing a farm, the function logs the error message and sends an email notification (limited to once per half hour) to inform about the failure.
type RetryService ¶
type RetryService struct {
// contains filtered or unexported fields
}
func NewRetryService ¶
func NewRetryService(config *infrastructure.Config, apiRequester ApiRequester, helper InfrastructureHelper, btcNetworkParams *types.BtcNetworkParams) *RetryService
func (*RetryService) Execute ¶
Checks the confirmation status of pending transactions, updates the status for those with confirmations, and retries transactions that have not been confirmed within the specified time frame.
1. Retrieve unconfirmed transaction hashes from the storage with the TransactionPending status.
Iterate through the unconfirmed transaction hashes and do the following: a. Create a chainhash.Hash object from the transaction hash string. b. Retrieve the verbose transaction information from the btcClient. c. If the transaction has confirmations countgreater than 0, append the transaction hash to the txToConfirm slice. Otherwise, append the transaction object to the txToRetry slice.
Update the status of transactions that have confirmations to TransactionCompleted in the storage.
Iterate through the transactions that need to be retried and do the following: a. Check if enough time has passed since the transaction was sent based on the RBFTransactionRetryDelayInSeconds configuration value. b. If the delay requirement is met, call the retryTransaction() function to attempt to resend the transaction with a higher fee.
type Storage ¶
type Storage interface { GetApprovedFarms(ctx context.Context) ([]types.Farm, error) GetPayoutTimesForNFT(ctx context.Context, collectionDenomId, nftId string) ([]types.NFTStatistics, error) SaveStatistics(ctx context.Context, receivedRewardForFarmBtcDecimal decimal.Decimal, collectionPaymentAllocationsStatistics []types.CollectionPaymentAllocation, destinationAddressesWithAmount map[string]types.AmountInfo, statistics []types.NFTStatistics, txHash string, farmId int64, farmSubAccountName string) error GetTxHashesByStatus(ctx context.Context, status string) ([]types.TransactionHashWithStatus, error) UpdateTransactionsStatus(ctx context.Context, txHashesToMarkCompleted []string, status string) error SaveTxHashWithStatus(ctx context.Context, txHash, status, farmSubAccountName string, farmPaymentId int64, retryCount int) error SaveRBFTransactionInformation(ctx context.Context, oldTxHash, oldTxStatus, newRBFTxHash, newRBFTXStatus, farmSubAccountName string, farmPaymentId int64, retryCount int) error GetUTXOTransaction(ctx context.Context, txId string) (types.UTXOTransaction, error) GetLastUTXOTransactionByFarmId(ctx context.Context, farmId int64) (types.UTXOTransaction, error) GetCurrentAcummulatedAmountForAddress(ctx context.Context, key string, farmId int64) (decimal.Decimal, error) UpdateThresholdStatus(ctx context.Context, processedTransactions string, paymentTimestamp int64, addressesWithThresholdToUpdateBtcDecimal map[string]decimal.Decimal, farmId int64) error SetInitialAccumulatedAmountForAddress(ctx context.Context, address string, farmId int64, amount int) error GetFarmAuraPoolCollections(ctx context.Context, farmId int64) ([]types.AuraPoolCollection, error) }