Documentation ¶
Index ¶
- Constants
- Variables
- type Escrow
- type FarmAPI
- type Free
- func (e *Free) CapacityReservation(reservation capacitytypes.Reservation, _ []string) (detail types.CustomerCapacityEscrowInformation, err error)
- func (e *Free) PaidCapacity() <-chan schema.ID
- func (e *Free) RegisterReservation(reservation workloads.Reservation, _ []string) (detail types.CustomerEscrowInformation, err error)
- func (e *Free) ReservationCanceled(reservationID schema.ID)
- func (e *Free) ReservationDeployed(reservationID schema.ID)
- func (e *Free) Run(ctx context.Context) error
- type GatewayAPI
- type NodeAPI
- type Stellar
- func (e *Stellar) CapacityReservation(reservation capacitytypes.Reservation, supportedCurrencies []string) (types.CustomerCapacityEscrowInformation, error)
- func (e *Stellar) PaidCapacity() <-chan schema.ID
- func (e *Stellar) RegisterReservation(reservation workloads.Reservation, supportedCurrencies []string) (types.CustomerEscrowInformation, error)
- func (e *Stellar) ReservationCanceled(reservationID schema.ID)
- func (e *Stellar) ReservationDeployed(reservationID schema.ID)
- func (e *Stellar) Run(ctx context.Context) error
Constants ¶
const ( // CuPriceDollarMonth CU price per month in dollar CuPriceDollarMonth = 10 // SuPriceDollarMonth SU price per month in dollar SuPriceDollarMonth = 8 // IP4uPriceDollarMonth IPv4U price per month in dollar IP4uPriceDollarMonth = 6 // TftPriceMill tft price in millies TftPriceMill = 100 // 0.01 * 1000 (1mill = 1/1000 of a dollar) )
Price for 1 CU or SU for 1 month is 10$ TFT price is fixed at 0.05 CU and SU price per second is CU -> (10 / 0.15) / (3600 *24*30) = 257.2 SU -> (8 / 0.15) / (3600 *24*30) = 257.2
Variables ¶
var ( // ErrNoCurrencySupported indicates a reservation was offered but none of the currencies // the farmer wants to pay in are currently supported ErrNoCurrencySupported = errors.New("none of the offered currencies are currently supported") // is supported by all farmers used ErrNoCurrencyShared = errors.New("none of the provided currencies is supported by all farmers") )
Functions ¶
This section is empty.
Types ¶
type Escrow ¶
type Escrow interface { Run(ctx context.Context) error RegisterReservation(reservation workloads.Reservation, supportedCurrencies []string) (types.CustomerEscrowInformation, error) ReservationDeployed(reservationID schema.ID) ReservationCanceled(reservationID schema.ID) CapacityReservation(reservation capacitytypes.Reservation, supportedCurrencies []string) (types.CustomerCapacityEscrowInformation, error) PaidCapacity() <-chan schema.ID }
Escrow are responsible for the payment flow of a reservation
type FarmAPI ¶
type FarmAPI interface { // GetByID get a farm from the database using its ID GetByID(ctx context.Context, db *mongo.Database, id int64) (directorytypes.Farm, error) GetFarmCustomPriceForThreebot(ctx context.Context, db *mongo.Database, farmID, threebotID int64) (directorytypes.FarmThreebotPrice, error) }
FarmAPI operations on farm database
type Free ¶
type Free struct {
// contains filtered or unexported fields
}
Free implements the Escrow interface in a way that makes all reservation free
func (*Free) CapacityReservation ¶
func (e *Free) CapacityReservation(reservation capacitytypes.Reservation, _ []string) (detail types.CustomerCapacityEscrowInformation, err error)
CapacityReservation implements the escrow interface
func (*Free) PaidCapacity ¶
PaidCapacity implements the escrow interface
func (*Free) RegisterReservation ¶
func (e *Free) RegisterReservation(reservation workloads.Reservation, _ []string) (detail types.CustomerEscrowInformation, err error)
RegisterReservation implements the escrow interface
func (*Free) ReservationCanceled ¶
ReservationCanceled implements the escrow interface
func (*Free) ReservationDeployed ¶
ReservationDeployed implements the escrow interface
type GatewayAPI ¶ added in v0.4.9
type GatewayAPI interface { // Get a gateway from the database using its ID Get(ctx context.Context, db *mongo.Database, id string) (directorytypes.Gateway, error) }
GatewayAPI operations for gateway database
type NodeAPI ¶
type NodeAPI interface { // Get a node from the database using its ID Get(ctx context.Context, db *mongo.Database, id string, proofs bool) (directorytypes.Node, error) }
NodeAPI operations on node database
type Stellar ¶
type Stellar struct {
// contains filtered or unexported fields
}
Stellar service manages a dedicate wallet for payments for reservations.
func NewStellar ¶
func NewStellar(wallet stellar.Wallet, db *mongo.Database, foundationAddress string, gridNetwork gridnetworks.GridNetwork) *Stellar
NewStellar creates a new escrow object and fetches all addresses for the escrow wallet
func (*Stellar) CapacityReservation ¶
func (e *Stellar) CapacityReservation(reservation capacitytypes.Reservation, supportedCurrencies []string) (types.CustomerCapacityEscrowInformation, error)
CapacityReservation implements Escrow
func (*Stellar) PaidCapacity ¶
PaidCapacity implements Escrow
func (*Stellar) RegisterReservation ¶
func (e *Stellar) RegisterReservation(reservation workloads.Reservation, supportedCurrencies []string) (types.CustomerEscrowInformation, error)
RegisterReservation registers a workload reservation
func (*Stellar) ReservationCanceled ¶
ReservationCanceled informs the escrow of a canceled reservation so it can refund the user
func (*Stellar) ReservationDeployed ¶
ReservationDeployed informs the escrow that a reservation has been successfully deployed, so the escrow can release the funds to the farmer (and refund any excess)