types

package
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EscrowCollection db collection name
	EscrowCollection = "escrow"
	// CapacityEscrowCollection db collection for escrow info related to capacity info
	CapacityEscrowCollection = "capacity-escrow"
)
View Source
const (
	// AddressCollection db collection name
	AddressCollection = "addresses"
)

Variables

View Source
var (
	// ErrAddressExists error for non existing doc
	ErrAddressExists = errors.New("address(s) for farmer customer already exists")
	// ErrAddressNotFound error for not found
	ErrAddressNotFound = errors.New("address information not found")
)
View Source
var (
	// ErrEscrowExists is returned when trying to save escrow information for a
	// reservation that already has escrow information
	ErrEscrowExists = errors.New("escrow(s) for reservation already exists")
	// ErrEscrowNotFound is returned if escrow information is not found
	ErrEscrowNotFound = errors.New("escrow information not found")
)

Functions

func CapacityReservationPaymentInfoCreate

func CapacityReservationPaymentInfoCreate(ctx context.Context, db *mongo.Database, reservationPaymentInfo CapacityReservationPaymentInformation) error

CapacityReservationPaymentInfoCreate creates the reservation payment information

func CapacityReservationPaymentInfoUpdate

func CapacityReservationPaymentInfoUpdate(ctx context.Context, db *mongo.Database, update CapacityReservationPaymentInformation) error

CapacityReservationPaymentInfoUpdate update reservation payment info

func CustomerAddressCreate

func CustomerAddressCreate(ctx context.Context, db *mongo.Database, cAddress CustomerAddress) error

CustomerAddressCreate creates the reservation payment information

func Setup

func Setup(ctx context.Context, db *mongo.Database) error

Setup sets up indexes for types, must be called at least Onetime during the life time of the object

Types

type CapacityReservationInfo

type CapacityReservationInfo struct {
	// ID of the pool
	ID schema.ID `bson:"id"`
	// CUs to add
	CUs uint64 `bson:"cus"`
	// SUs to add
	SUs uint64 `bson:"sus"`
}

CapacityReservationInfo is information to manipulate a capacity pool once the escrow is fulfilled

type CapacityReservationPaymentInformation

type CapacityReservationPaymentInformation struct {
	ReservationID schema.ID     `json:"id" bson:"_id"`
	FarmerID      schema.ID     `json:"farmer_id" bson:"farmer_id"`
	Address       string        `json:"address" bson:"address"`
	Expiration    schema.Date   `json:"expiration" bson:"expiration"`
	Asset         stellar.Asset `json:"asset" bson:"asset"`
	Amount        xdr.Int64     `json:"amount" bson:"amount"`
	// Paid indicates the capacity reservation escrows have been fully funded,
	// resulting in the new funds being allocated into the pool (creating
	// the pool in case it did not exist yet)
	Paid bool `json:"paid" bson:"paid"`
	// Released means we tried to pay the farmer
	Released bool `json:"released" bson:"released"`
	// Canceled means the escrow got canceled, i.e. client refunded. This can
	// only happen in case the reservation expires.
	Canceled bool `json:"canceled" bson:"canceled"`
	// Cause of cancellation
	Cause string `json:"cause" bson:"cause"`
}

CapacityReservationPaymentInformation stores the reservation payment information

func CapacityReservationPaymentInfoGet

func CapacityReservationPaymentInfoGet(ctx context.Context, db *mongo.Database, id schema.ID) (CapacityReservationPaymentInformation, error)

CapacityReservationPaymentInfoGet a single reservation escrow info using its id

func GetAllActiveCapacityReservationPaymentInfos

func GetAllActiveCapacityReservationPaymentInfos(ctx context.Context, db *mongo.Database) ([]CapacityReservationPaymentInformation, error)

GetAllActiveCapacityReservationPaymentInfos get all active reservation payment information

func GetAllExpiredCapacityReservationPaymentInfos

func GetAllExpiredCapacityReservationPaymentInfos(ctx context.Context, db *mongo.Database) ([]CapacityReservationPaymentInformation, error)

GetAllExpiredCapacityReservationPaymentInfos get all expired reservation payment information

type CustomerAddress

type CustomerAddress struct {
	CustomerTID int64  `bson:"customer_tid" json:"customer_tid"`
	Address     string `bson:"address" json:"address"`
	Secret      string `bson:"secret" json:"secret"`
}

CustomerAddress holds the customer escrow address and key

func CustomerAddressByAddress

func CustomerAddressByAddress(ctx context.Context, db *mongo.Database, address string) (CustomerAddress, error)

CustomerAddressByAddress gets one address using the address

func CustomerAddressGet

func CustomerAddressGet(ctx context.Context, db *mongo.Database, customerTID int64) (CustomerAddress, error)

CustomerAddressGet one address bycustomerTID

type CustomerCapacityEscrowInformation

type CustomerCapacityEscrowInformation struct {
	Address string        `json:"address"`
	Asset   stellar.Asset `json:"asset"`
	Amount  xdr.Int64     `json:"amount"`
}

CustomerCapacityEscrowInformation is the escrow information which will get exposed to the customer once he creates a reservation for capacity

type CustomerEscrowInformation

type CustomerEscrowInformation struct {
	Address string         `json:"address"`
	Asset   stellar.Asset  `json:"asset"`
	Details []EscrowDetail `json:"details"`
}

CustomerEscrowInformation is the escrow information which will get exposed to the customer once he creates a reservation

type EscrowDetail

type EscrowDetail struct {
	FarmerID    schema.ID `bson:"farmer_id" json:"farmer_id"`
	TotalAmount xdr.Int64 `bson:"total_amount" json:"total_amount"`
}

EscrowDetail hold the details of an escrow address

type ReservationPaymentInformation

type ReservationPaymentInformation struct {
	ReservationID schema.ID      `bson:"_id"`
	Address       string         `bson:"address"`
	Expiration    schema.Date    `bson:"expiration"`
	Asset         stellar.Asset  `bson:"asset"`
	Infos         []EscrowDetail `bson:"infos"`
	// Paid indicates the reservation escrows have been fully funded, and
	// the reservation has been moved from the "PAY" state to the "DEPLOY"
	// state
	Paid bool `bson:"paid"`
	// Released indicates the reservation has been fully deployed, and
	// that an attempt was made to pay the farmers. If this flag is set, it is
	// still possible that there are funds on an escrow related to this transaction
	// either because someone funded it after the reservation was already
	// deployed , because there was an error paying the farmers
	// or because there was an error refunding any overpaid amount.
	Released bool `bson:"released"`
	// Canceled indicates that the reservation was canceled, either by the
	// user, or because a workload deployment failed, which resulted in the
	// entire reservation being canceled. As a result, an attempt was made
	// to refund the client. It is possible for this to have failed.
	Canceled bool `bson:"canceled"`
}

ReservationPaymentInformation stores the reservation payment information

func GetAllExpiredReservationPaymentInfos

func GetAllExpiredReservationPaymentInfos(ctx context.Context, db *mongo.Database) ([]ReservationPaymentInformation, error)

GetAllExpiredReservationPaymentInfos get all expired reservation payment information

Jump to

Keyboard shortcuts

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