Documentation ¶
Index ¶
- Variables
- type CachedPayment
- type Chore
- type Client
- func (client *Client) AllPayments(ctx context.Context, from int64) (payments LatestPayments, err error)
- func (client *Client) ClaimNewEthAddress(ctx context.Context) (_ blockchain.Address, err error)
- func (client *Client) Payments(ctx context.Context, from int64, address string) (payments LatestPayments, err error)
- type Config
- type Header
- type LatestPayments
- type Payment
- type PaymentsDB
- type Service
- func (service *Service) Claim(ctx context.Context, userID uuid.UUID) (_ blockchain.Address, err error)
- func (service *Service) Get(ctx context.Context, userID uuid.UUID) (_ blockchain.Address, err error)
- func (service *Service) GetNewTransactions(ctx context.Context, _ time.Time, lastPaymentMetadata []byte) ([]billing.Transaction, error)
- func (service *Service) Payments(ctx context.Context, wallet blockchain.Address, limit int, offset int64) (_ []payments.WalletPayment, err error)
- func (service *Service) PaymentsWithConfirmations(ctx context.Context, wallet blockchain.Address) (_ []payments.WalletPaymentWithConfirmations, err error)
- func (service *Service) Source() string
- func (service *Service) Type() billing.TransactionType
- type Wallet
- type WalletsDB
Constants ¶
This section is empty.
Variables ¶
var ( // ClientErr is general purpose storjscan client error class. ClientErr = errs.Class("storjscan client") ClientErrUnauthorized = errs.Class("storjscan client unauthorized") )
var ChoreErr = errs.Class("storjscan chore")
ChoreErr is storjscan chore err class.
var ErrNoPayments = errs.New("no payments in the database")
ErrNoPayments represents err when there is no payments in the DB.
var ErrService = errs.Class("storjscan service")
ErrService is storjscan service error class.
Functions ¶
This section is empty.
Types ¶
type CachedPayment ¶ added in v1.58.1
type CachedPayment struct { From blockchain.Address `json:"from"` To blockchain.Address `json:"to"` TokenValue currency.Amount `json:"tokenValue"` USDValue currency.Amount `json:"usdValue"` Status payments.PaymentStatus `json:"status"` BlockHash blockchain.Hash `json:"blockHash"` BlockNumber int64 `json:"blockNumber"` Transaction blockchain.Hash `json:"transaction"` LogIndex int `json:"logIndex"` Timestamp time.Time `json:"timestamp"` }
CachedPayment holds cached data of storjscan payment.
type Chore ¶ added in v1.58.1
Chore periodically queries for new payments from storjscan.
architecture: Chore
func NewChore ¶ added in v1.58.1
func NewChore(log *zap.Logger, client *Client, paymentsDB PaymentsDB, confirmations int, interval time.Duration, disableLoop bool) *Chore
NewChore creates new chore.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is storjscan HTTP API client.
func (*Client) AllPayments ¶ added in v1.84.1
func (client *Client) AllPayments(ctx context.Context, from int64) (payments LatestPayments, err error)
AllPayments retrieves all payments after specified block for wallets associated with particular API key.
func (*Client) ClaimNewEthAddress ¶ added in v1.57.1
ClaimNewEthAddress claims a new ethereum wallet address for the given user.
type Config ¶ added in v1.57.1
type Config struct { Endpoint string `help:"storjscan API endpoint"` Auth struct { Identifier string `help:"basic auth identifier"` Secret string `help:"basic auth secret"` } Interval time.Duration `help:"storjscan chore interval to query new payments for all satellite deposit wallets" default:"1m"` Confirmations int `help:"required number of following blocks in the chain to accept payment as confirmed" default:"15"` DisableLoop bool `help:"flag to disable querying new storjscan payments by storjscan chore" default:"true"` }
Config stores needed information for storjscan service initialization.
type Header ¶
type Header struct { Hash blockchain.Hash Number int64 Timestamp time.Time }
Header holds ethereum blockchain block header data.
type LatestPayments ¶
LatestPayments contains latest payments and latest chain block header.
type Payment ¶
type Payment struct { From blockchain.Address To blockchain.Address TokenValue currency.Amount USDValue currency.Amount BlockHash blockchain.Hash BlockNumber int64 Transaction blockchain.Hash LogIndex int Timestamp time.Time }
Payment holds storjscan payment data.
type PaymentsDB ¶ added in v1.58.1
type PaymentsDB interface { // InsertBatch inserts list of payments into DB. InsertBatch(ctx context.Context, payments []CachedPayment) error // List returns list of all storjscan payments order by block number and log index desc mainly for testing. List(ctx context.Context) ([]CachedPayment, error) // ListWallet returns list of storjscan payments order by block number and log index desc. ListWallet(ctx context.Context, wallet blockchain.Address, limit int, offset int64) ([]CachedPayment, error) // LastBlock returns the highest block known to DB for specified payment status. LastBlock(ctx context.Context, status payments.PaymentStatus) (int64, error) // DeletePending removes all pending transactions from the DB. DeletePending(ctx context.Context) error // ListConfirmed returns list of confirmed storjscan payments greater than the given timestamp. ListConfirmed(ctx context.Context, blockNumber int64, logIndex int) ([]CachedPayment, error) }
PaymentsDB is storjscan payments DB interface.
architecture: Database
type Service ¶ added in v1.57.1
type Service struct {
// contains filtered or unexported fields
}
Service exposes API to interact with storjscan payments provider.
func NewService ¶ added in v1.57.1
func NewService(log *zap.Logger, walletsDB WalletsDB, paymentsDB PaymentsDB, client *Client, neededConfirmations int, bonusRate int64) *Service
NewService creates new storjscan service instance.
func (*Service) Claim ¶ added in v1.57.1
func (service *Service) Claim(ctx context.Context, userID uuid.UUID) (_ blockchain.Address, err error)
Claim gets a new crypto wallet and associates it with a user.
func (*Service) Get ¶ added in v1.57.1
func (service *Service) Get(ctx context.Context, userID uuid.UUID) (_ blockchain.Address, err error)
Get returns the crypto wallet address associated with the given user.
func (*Service) GetNewTransactions ¶ added in v1.62.1
func (service *Service) GetNewTransactions(ctx context.Context, _ time.Time, lastPaymentMetadata []byte) ([]billing.Transaction, error)
GetNewTransactions returns the storjscan payments since the given block number and index as billing transactions type.
func (*Service) Payments ¶ added in v1.60.1
func (service *Service) Payments(ctx context.Context, wallet blockchain.Address, limit int, offset int64) (_ []payments.WalletPayment, err error)
Payments retrieves payments for specific wallet.
func (*Service) PaymentsWithConfirmations ¶ added in v1.84.1
func (service *Service) PaymentsWithConfirmations(ctx context.Context, wallet blockchain.Address) (_ []payments.WalletPaymentWithConfirmations, err error)
PaymentsWithConfirmations returns payments with confirmations count for a particular wallet.
func (*Service) Source ¶ added in v1.62.1
Source defines the billing transaction source for storjscan payments.
func (*Service) Type ¶ added in v1.62.1
func (service *Service) Type() billing.TransactionType
Type defines the billing transaction type for storjscan payments.
type Wallet ¶ added in v1.62.1
type Wallet struct { UserID uuid.UUID Address blockchain.Address }
Wallet associates a user ID and a wallet address.
type WalletsDB ¶
type WalletsDB interface { // Add adds a new storjscan wallet to the DB and associates it with a user. Add(ctx context.Context, userID uuid.UUID, walletAddress blockchain.Address) error // GetWallet returns the wallet address associated with the given user. GetWallet(ctx context.Context, userID uuid.UUID) (blockchain.Address, error) // GetUser returns the userID associated with the given wallet. GetUser(ctx context.Context, wallet blockchain.Address) (uuid.UUID, error) // GetAll returns all saved wallet entries. GetAll(ctx context.Context) (_ []Wallet, err error) }
WalletsDB is an interface which defines functionality of DB which stores user storjscan wallets.
architecture: Database