service

package
v0.0.0-...-2958dd6 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2024 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyBillingLocker = util.MutexKey("BillingLocker")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AppBase

type AppBase struct {
	Addr           common.Address            // APP contract address
	PaymentType    contract.PaymentType      // payment type
	CardTracker    common.Address            // VIP card tracker contract address
	ApiWeightToken common.Address            // `ApiWeightToken` contract address
	VipCoin        common.Address            // `VipCoin` contract address
	PendingSeconds *big.Int                  // pending seconds for delaying config
	Resources      map[string]resourceConfig // resource config
	UpdateBlock    int64                     // the last block of which to update resources
}

func (*AppBase) IsBillingMode

func (ab *AppBase) IsBillingMode() bool

func (*AppBase) IsSubscriptionMode

func (ab *AppBase) IsSubscriptionMode() bool

type BillingBatchReceipt

type BillingBatchReceipt = BillingReceipt

type BillingBatchRequest

type BillingBatchRequest struct {
	ResourceUses map[string]int64 `json:"resourceUses"`
	DryRun       bool             `json:"dryRun"`
	App          common.Address   `json:"-"`
	Customer     common.Address   `json:"-"`
}

type BillingReceipt

type BillingReceipt struct {
	App          common.Address             `json:"app,omitempty"`
	Customer     common.Address             `json:"customer,omitempty"`
	Balance      string                     `json:"balance,omitempty"`
	ResourceFees map[string]decimal.Decimal `json:"resourceFees,omitempty"` // resource ID => fee
}

type BillingRequest

type BillingRequest struct {
	ResourceId string         `json:"resourceId"`
	DryRun     bool           `json:"dryRun"`
	App        common.Address `json:"-"`
	Customer   common.Address `json:"-"`
}

type BillingService

type BillingService struct {
	// contains filtered or unexported fields
}

func NewBillingService

func NewBillingService(sqliteStore *sqlite.SqliteStore, chainSvc *BlockchainService) *BillingService

func (*BillingService) Bill

func (*BillingService) BillBatch

func (*BillingService) DelStatements

func (bs *BillingService) DelStatements(billID uint64)

func (*BillingService) GetAndDelStatements

func (bs *BillingService) GetAndDelStatements(billID uint64) map[uint32]int64

func (*BillingService) GetStatements

func (bs *BillingService) GetStatements(billID uint64) map[uint32]int64

type BlockchainService

type BlockchainService struct {
	// contains filtered or unexported fields
}

func NewBlockchainService

func NewBlockchainService(
	sqliteStore *sqlite.SqliteStore, memStore *memdb.MemStore, provider *blockchain.Provider,
) (*BlockchainService, error)

func (*BlockchainService) DecreaseAccountBalance

func (svc *BlockchainService) DecreaseAccountBalance(
	app, address common.Address, amount *big.Int, block int64) (bool, error)

DecreaseAccountBalance decreases APP balance of specific account.

func (*BlockchainService) DeleteAccountStatus

func (svc *BlockchainService) DeleteAccountStatus(app, address common.Address) (*model.AppAccount, error)

DeleteAccountStatus deletes APP account of specific address.

func (*BlockchainService) Deposit

func (bs *BlockchainService) Deposit()

func (*BlockchainService) DepositPending

func (bs *BlockchainService) DepositPending(request *DepositRequest) error

func (*BlockchainService) GetAppConfigResourceWithId

func (svc *BlockchainService) GetAppConfigResourceWithId(
	app common.Address, resourceId string) (*contract.IAppConfigConfigEntry, error)

func (*BlockchainService) GetOrFetchAppAccountStatus

func (svc *BlockchainService) GetOrFetchAppAccountStatus(app, address common.Address) (*model.AppAccount, error)

GetOrFetchAppAccount gets APP account status of specific address.

func (*BlockchainService) IncreaseAccountBalance

func (svc *BlockchainService) IncreaseAccountBalance(
	app, address common.Address, amount *big.Int, block int64) (bool, error)

IncreaseAccountBalance increases APP balance of specific account.

func (*BlockchainService) OnAppCreated

func (bs *BlockchainService) OnAppCreated(event *contract.AppRegistryCreated, rawlog *types.Log) error

func (*BlockchainService) OnConfirmStatus

func (bs *BlockchainService) OnConfirmStatus(
	app, addr common.Address, balance *big.Int, frozen, block int64,
) error

func (*BlockchainService) OnDeposit

func (bs *BlockchainService) OnDeposit(event *contract.AppDeposit, rawlog *types.Log) error

func (*BlockchainService) OnFrozen

func (bs *BlockchainService) OnFrozen(event *contract.AppFrozen, rawlog *types.Log) error

func (*BlockchainService) OnReorgRevert

func (bs *BlockchainService) OnReorgRevert(revertToBlock int64) error

func (*BlockchainService) OnResourceChanged

func (bs *BlockchainService) OnResourceChanged(event *contract.ApiWeightTokenResourceChanged, rawlog *types.Log) error

func (*BlockchainService) OnTransfer

func (bs *BlockchainService) OnTransfer(event *contract.VipCoinTransferSingle, rawlog *types.Log) error

func (*BlockchainService) OnWithdraw

func (bs *BlockchainService) OnWithdraw(event *contract.AppWithdraw, rawlog *types.Log) error

func (*BlockchainService) StatusConfirmQueue

func (bs *BlockchainService) StatusConfirmQueue() <-chan [2]common.Address

func (*BlockchainService) UpdateAccountStatus

func (svc *BlockchainService) UpdateAccountStatus(
	app, address common.Address, balance *big.Int, frozen, block *int64) (*model.AppAccount, error)

UpdateAccountStatus updates APP account status (balance, frozen status etc.,) of specific address.

func (*BlockchainService) ValidateAppOperator

func (svc *BlockchainService) ValidateAppOperator(appAddr, operator common.Address) error

ValidateAppOperator validates if the account address is the valid operator for the APP contract.

func (*BlockchainService) ValidateBillingApp

func (svc *BlockchainService) ValidateBillingApp(app common.Address) error

func (*BlockchainService) WithholdAccountFee

func (svc *BlockchainService) WithholdAccountFee(app, address common.Address, amount *big.Int) (bool, error)

WithholdAccountFee withholds APP fee from specific account.

func (*BlockchainService) WriteOffAccountFee

func (svc *BlockchainService) WriteOffAccountFee(app, address common.Address, amount *big.Int) (bool, error)

WriteOffAccountFee writes off APP fee from specific account.

type DepositRequest

type DepositRequest struct {
	App         common.Address
	Address     common.Address
	Amount      *big.Int
	TxHash      common.Hash
	BlockHash   common.Hash
	BlockNumber int64
	SubmitAt    time.Time
}

type Factory

type Factory struct {
	Blockchain *BlockchainService
	Billing    *BillingService
}

func MustNewFactory

func MustNewFactory(store *sqlite.SqliteStore, memStore *memdb.MemStore, provider *blockchain.Provider) *Factory

Jump to

Keyboard shortcuts

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