purchase

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEPLOYID_NOT_FOUND         = "Depoloy ID not found."
	PURCHASE_TIMEOUT           = "Purchase timeout."
	BLOCK_HEIGHT_TIMEOUT       = "Block height over timeout block"
	INVALID_SIGNATURE_FORMAT   = "Cannot parse signature."
	INVALID_SIGNATURE          = "Invalid Signature."
	INVALID_TIER_JSON          = "Invalid Tier format"
	INVALID_NODE_ID            = "Invalid NodeId."
	NODE_ALREADY_PURCHASED     = "Some node has been purchased."
	INVALID_SELLER_ADDR_FORMAT = "Invalid seller address."
	INVALID_PAYMENT            = "Total amount paid less than reported price"
	INSUFFICIENT_FUND          = "Insufficient fund"
	OVER_LIMIT_PER_ADDR        = "Purchase over limit per address."
	OVER_LIMIT_PER_TIER        = "Purchase over limit per tier."
)

Variables

This section is empty.

Functions

This section is empty.

Types

type PurchaseValidator

type PurchaseValidator struct {
	validator.Validator
}

func New

func New() *PurchaseValidator

func (*PurchaseValidator) NodeSaleExists

func (*PurchaseValidator) ValidPaidAmount

func (v *PurchaseValidator) ValidPaidAmount(
	payload *protobuf.PurchasePayload,
	deploy *entity.NodeSale,
	txPaid uint64,
	tiers []protobuf.Tier,
	buyingTiersCount []uint32,
	network *chaincfg.Params,
) (bool, *entity.MetadataEventPurchase)

func (*PurchaseValidator) ValidTiers

func (v *PurchaseValidator) ValidTiers(
	payload *protobuf.PurchasePayload,
	deploy *entity.NodeSale,
) (bool, TierMap)

func (*PurchaseValidator) ValidTimestamp

func (v *PurchaseValidator) ValidTimestamp(deploy *entity.NodeSale, timestamp time.Time) bool

func (*PurchaseValidator) ValidUnpurchasedNodes

func (v *PurchaseValidator) ValidUnpurchasedNodes(
	ctx context.Context,
	qtx datagateway.NodeSaleDataGatewayWithTx,
	payload *protobuf.PurchasePayload,
) (bool, error)

func (*PurchaseValidator) VerifySignature

func (v *PurchaseValidator) VerifySignature(purchase *protobuf.ActionPurchase, deploy *entity.NodeSale) bool

func (*PurchaseValidator) WithinLimit

func (v *PurchaseValidator) WithinLimit(
	ctx context.Context,
	qtx datagateway.NodeSaleDataGatewayWithTx,
	payload *protobuf.PurchasePayload,
	deploy *entity.NodeSale,
	tiers []protobuf.Tier,
	buyingTiersCount []uint32,
) (bool, error)

func (*PurchaseValidator) WithinTimeoutBlock

func (v *PurchaseValidator) WithinTimeoutBlock(timeOutBlock uint64, blockHeight uint64) bool

type TierMap

type TierMap struct {
	Tiers            []protobuf.Tier
	BuyingTiersCount []uint32
	NodeIdToTier     map[uint32]int32
}

Jump to

Keyboard shortcuts

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