types

package
v0.4.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2021 License: Apache-2.0 Imports: 10 Imported by: 14

Documentation

Index

Constants

View Source
const (
	AttributeKeyOwner     = "owner"
	AttributeKeyAddress   = "address"
	AttributeKeyID        = "id"
	AttributeKeyStatus    = "status"
	AttributeKeyNode      = "node"
	AttributeKeyCount     = "count"
	AttributeKeyPlan      = "plan"
	AttributeKeyConsumed  = "consumed"
	AttributeKeyAllocated = "allocated"
)
View Source
const (
	ModuleName   = "subscription"
	QuerierRoute = ModuleName
)
View Source
const (
	QuerySubscription            = "Subscription"
	QuerySubscriptions           = "Subscriptions"
	QuerySubscriptionsForNode    = "SubscriptionsForNode"
	QuerySubscriptionsForPlan    = "SubscriptionsForPlan"
	QuerySubscriptionsForAddress = "SubscriptionsForAddress"

	QueryQuota  = "Quota"
	QueryQuotas = "Quotas"
)
View Source
const (
	DefaultInactiveDuration = 10 * time.Minute
)

Variables

View Source
var (
	ErrorMarshal                   = errors.Register(ModuleName, 101, "error occurred while marshalling")
	ErrorUnmarshal                 = errors.Register(ModuleName, 102, "error occurred while unmarshalling")
	ErrorUnknownMsgType            = errors.Register(ModuleName, 103, "unknown message type")
	ErrorUnknownQueryType          = errors.Register(ModuleName, 104, "unknown query type")
	ErrorInvalidField              = errors.Register(ModuleName, 105, "invalid field")
	ErrorPlanDoesNotExist          = errors.Register(ModuleName, 106, "plan does not exist")
	ErrorNodeDoesNotExist          = errors.Register(ModuleName, 107, "node does not exist")
	ErrorUnauthorized              = errors.Register(ModuleName, 108, "unauthorized")
	ErrorInvalidPlanStatus         = errors.Register(ModuleName, 109, "invalid plan status")
	ErrorPriceDoesNotExist         = errors.Register(ModuleName, 110, "price does not exist")
	ErrorInvalidNodeStatus         = errors.Register(ModuleName, 111, "invalid node status")
	ErrorSubscriptionDoesNotExist  = errors.Register(ModuleName, 112, "subscription does not exist")
	ErrorInvalidSubscriptionStatus = errors.Register(ModuleName, 113, "invalid subscription status")
	ErrorCanNotSubscribe           = errors.Register(ModuleName, 114, "can not subscribe")
	ErrorInvalidQuota              = errors.Register(ModuleName, 115, "invalid quota")
	ErrorDuplicateQuota            = errors.Register(ModuleName, 116, "duplicate quota")
	ErrorQuotaDoesNotExist         = errors.Register(ModuleName, 117, "quota does not exist")
	ErrorCanNotAddQuota            = errors.Register(ModuleName, 118, "can not add quota")
)
View Source
var (
	EventTypeSetCount    = fmt.Sprintf("%s:set_count", ModuleName)
	EventTypeSet         = fmt.Sprintf("%s:set", ModuleName)
	EventTypeCancel      = fmt.Sprintf("%s:cancel", ModuleName)
	EventTypeAddQuota    = fmt.Sprintf("%s:add_quota", ModuleName)
	EventTypeUpdateQuota = fmt.Sprintf("%s:update_quota", ModuleName)
)
View Source
var (
	ParamsSubspace = ModuleName
	RouterKey      = ModuleName
	StoreKey       = ModuleName
)
View Source
var (
	CountKey                     = []byte{0x00}
	SubscriptionKeyPrefix        = []byte{0x10}
	SubscriptionForNodeKeyPrefix = []byte{0x20}
	SubscriptionForPlanKeyPrefix = []byte{0x30}

	ActiveSubscriptionForAddressKeyPrefix   = []byte{0x40}
	InactiveSubscriptionForAddressKeyPrefix = []byte{0x41}

	InactiveSubscriptionAtKeyPrefix = []byte{0x50}
	QuotaKeyPrefix                  = []byte{0x60}
)
View Source
var (
	KeyInactiveDuration = []byte("InactiveDuration")
)
View Source
var (
	ModuleCdc *codec.Codec
)

Functions

func ActiveSubscriptionForAddressKey added in v0.4.0

func ActiveSubscriptionForAddressKey(address sdk.AccAddress, i uint64) []byte

func GetActiveSubscriptionForAddressKeyPrefix added in v0.4.0

func GetActiveSubscriptionForAddressKeyPrefix(address sdk.AccAddress) []byte

func GetInactiveSubscriptionAtKeyPrefix added in v0.4.0

func GetInactiveSubscriptionAtKeyPrefix(at time.Time) []byte

func GetInactiveSubscriptionForAddressKeyPrefix added in v0.4.0

func GetInactiveSubscriptionForAddressKeyPrefix(address sdk.AccAddress) []byte

func GetQuotaKeyPrefix

func GetQuotaKeyPrefix(id uint64) []byte

func GetSubscriptionForNodeKeyPrefix

func GetSubscriptionForNodeKeyPrefix(address hub.NodeAddress) []byte

func GetSubscriptionForPlanKeyPrefix

func GetSubscriptionForPlanKeyPrefix(id uint64) []byte

func IDFromInactiveSubscriptionAtKey added in v0.4.0

func IDFromInactiveSubscriptionAtKey(key []byte) uint64

func IDFromStatusSubscriptionForAddressKey added in v0.4.0

func IDFromStatusSubscriptionForAddressKey(key []byte) uint64

func IDFromSubscriptionForNodeKey added in v0.4.0

func IDFromSubscriptionForNodeKey(key []byte) uint64

func IDFromSubscriptionForPlanKey added in v0.4.0

func IDFromSubscriptionForPlanKey(key []byte) uint64

func InactiveSubscriptionAtKey added in v0.4.0

func InactiveSubscriptionAtKey(at time.Time, id uint64) []byte

func InactiveSubscriptionForAddressKey added in v0.4.0

func InactiveSubscriptionForAddressKey(address sdk.AccAddress, i uint64) []byte

func ParamsKeyTable

func ParamsKeyTable() params.KeyTable

func QuotaKey

func QuotaKey(id uint64, address sdk.AccAddress) []byte

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

func SubscriptionForNodeKey

func SubscriptionForNodeKey(address hub.NodeAddress, id uint64) []byte

func SubscriptionForPlanKey

func SubscriptionForPlanKey(p, s uint64) []byte

func SubscriptionKey

func SubscriptionKey(id uint64) []byte

Types

type GenesisState

type GenesisState struct {
	Subscriptions GenesisSubscriptions `json:"_"`
	Params        Params               `json:"params"`
}

func DefaultGenesisState

func DefaultGenesisState() GenesisState

func NewGenesisState

func NewGenesisState(subscriptions GenesisSubscriptions, params Params) GenesisState

type GenesisSubscription

type GenesisSubscription struct {
	Subscription Subscription `json:"_"`
	Quotas       Quotas       `json:"quotas"`
}

type GenesisSubscriptions

type GenesisSubscriptions []GenesisSubscription

type MsgAddQuota

type MsgAddQuota struct {
	From    sdk.AccAddress `json:"from"`
	ID      uint64         `json:"id"`
	Address sdk.AccAddress `json:"address"`
	Bytes   sdk.Int        `json:"bytes"`
}

MsgAddQuota is for adding the bandwidth quota for an address.

func NewMsgAddQuota

func NewMsgAddQuota(from sdk.AccAddress, id uint64, address sdk.AccAddress, bytes sdk.Int) MsgAddQuota

func (MsgAddQuota) GetSignBytes

func (m MsgAddQuota) GetSignBytes() []byte

func (MsgAddQuota) GetSigners

func (m MsgAddQuota) GetSigners() []sdk.AccAddress

func (MsgAddQuota) Route

func (m MsgAddQuota) Route() string

func (MsgAddQuota) Type

func (m MsgAddQuota) Type() string

func (MsgAddQuota) ValidateBasic

func (m MsgAddQuota) ValidateBasic() error

type MsgCancel

type MsgCancel struct {
	From sdk.AccAddress `json:"from"`
	ID   uint64         `json:"id"`
}

MsgCancel is for cancelling a subscription.

func NewMsgCancel

func NewMsgCancel(from sdk.AccAddress, id uint64) MsgCancel

func (MsgCancel) GetSignBytes

func (m MsgCancel) GetSignBytes() []byte

func (MsgCancel) GetSigners

func (m MsgCancel) GetSigners() []sdk.AccAddress

func (MsgCancel) Route

func (m MsgCancel) Route() string

func (MsgCancel) Type

func (m MsgCancel) Type() string

func (MsgCancel) ValidateBasic

func (m MsgCancel) ValidateBasic() error

type MsgSubscribeToNode

type MsgSubscribeToNode struct {
	From    sdk.AccAddress  `json:"from"`
	Address hub.NodeAddress `json:"address"`
	Deposit sdk.Coin        `json:"deposit"`
}

MsgSubscribeToNode is for starting a node subscription.

func NewMsgSubscribeToNode

func NewMsgSubscribeToNode(from sdk.AccAddress, address hub.NodeAddress, deposit sdk.Coin) MsgSubscribeToNode

func (MsgSubscribeToNode) GetSignBytes

func (m MsgSubscribeToNode) GetSignBytes() []byte

func (MsgSubscribeToNode) GetSigners

func (m MsgSubscribeToNode) GetSigners() []sdk.AccAddress

func (MsgSubscribeToNode) Route

func (m MsgSubscribeToNode) Route() string

func (MsgSubscribeToNode) Type

func (m MsgSubscribeToNode) Type() string

func (MsgSubscribeToNode) ValidateBasic

func (m MsgSubscribeToNode) ValidateBasic() error

type MsgSubscribeToPlan

type MsgSubscribeToPlan struct {
	From  sdk.AccAddress `json:"from"`
	ID    uint64         `json:"id"`
	Denom string         `json:"denom"`
}

MsgSubscribeToPlan is for starting a plan subscription.

func NewMsgSubscribeToPlan

func NewMsgSubscribeToPlan(from sdk.AccAddress, id uint64, denom string) MsgSubscribeToPlan

func (MsgSubscribeToPlan) GetSignBytes

func (m MsgSubscribeToPlan) GetSignBytes() []byte

func (MsgSubscribeToPlan) GetSigners

func (m MsgSubscribeToPlan) GetSigners() []sdk.AccAddress

func (MsgSubscribeToPlan) Route

func (m MsgSubscribeToPlan) Route() string

func (MsgSubscribeToPlan) Type

func (m MsgSubscribeToPlan) Type() string

func (MsgSubscribeToPlan) ValidateBasic

func (m MsgSubscribeToPlan) ValidateBasic() error

type MsgUpdateQuota

type MsgUpdateQuota struct {
	From    sdk.AccAddress `json:"from"`
	ID      uint64         `json:"id"`
	Address sdk.AccAddress `json:"address"`
	Bytes   sdk.Int        `json:"bytes"`
}

MsgUpdateQuota is for updating the bandwidth quota for an address.

func NewMsgUpdateQuota

func NewMsgUpdateQuota(from sdk.AccAddress, id uint64, address sdk.AccAddress, bytes sdk.Int) MsgUpdateQuota

func (MsgUpdateQuota) GetSignBytes

func (m MsgUpdateQuota) GetSignBytes() []byte

func (MsgUpdateQuota) GetSigners

func (m MsgUpdateQuota) GetSigners() []sdk.AccAddress

func (MsgUpdateQuota) Route

func (m MsgUpdateQuota) Route() string

func (MsgUpdateQuota) Type

func (m MsgUpdateQuota) Type() string

func (MsgUpdateQuota) ValidateBasic

func (m MsgUpdateQuota) ValidateBasic() error

type Params

type Params struct {
	InactiveDuration time.Duration `json:"inactive_duration"`
}

func DefaultParams

func DefaultParams() Params

func NewParams

func NewParams(inactiveDuration time.Duration) Params

func (*Params) ParamSetPairs

func (p *Params) ParamSetPairs() params.ParamSetPairs

func (Params) String

func (p Params) String() string

func (Params) Validate

func (p Params) Validate() error

type QueryQuotaParams

type QueryQuotaParams struct {
	ID      uint64         `json:"id"`
	Address sdk.AccAddress `json:"address"`
}

func NewQueryQuotaParams

func NewQueryQuotaParams(id uint64, address sdk.AccAddress) QueryQuotaParams

type QueryQuotasParams

type QueryQuotasParams struct {
	ID    uint64 `json:"id"`
	Skip  int    `json:"skip"`
	Limit int    `json:"limit"`
}

func NewQueryQuotasParams

func NewQueryQuotasParams(id uint64, skip, limit int) QueryQuotasParams

type QuerySubscriptionParams

type QuerySubscriptionParams struct {
	ID uint64 `json:"id"`
}

func NewQuerySubscriptionParams

func NewQuerySubscriptionParams(id uint64) QuerySubscriptionParams

type QuerySubscriptionsForAddressParams

type QuerySubscriptionsForAddressParams struct {
	Address sdk.AccAddress `json:"address"`
	Status  hub.Status     `json:"status"`
	Skip    int            `json:"skip"`
	Limit   int            `json:"limit"`
}

func NewQuerySubscriptionsForAddressParams

func NewQuerySubscriptionsForAddressParams(address sdk.AccAddress, status hub.Status, skip, limit int) QuerySubscriptionsForAddressParams

type QuerySubscriptionsForNodeParams

type QuerySubscriptionsForNodeParams struct {
	Address hub.NodeAddress `json:"address"`
	Skip    int             `json:"skip"`
	Limit   int             `json:"limit"`
}

func NewQuerySubscriptionsForNodeParams

func NewQuerySubscriptionsForNodeParams(address hub.NodeAddress, skip, limit int) QuerySubscriptionsForNodeParams

type QuerySubscriptionsForPlanParams

type QuerySubscriptionsForPlanParams struct {
	ID    uint64 `json:"id"`
	Skip  int    `json:"skip"`
	Limit int    `json:"limit"`
}

func NewQuerySubscriptionsForPlanParams

func NewQuerySubscriptionsForPlanParams(id uint64, skip, limit int) QuerySubscriptionsForPlanParams

type QuerySubscriptionsParams

type QuerySubscriptionsParams struct {
	Skip  int `json:"skip"`
	Limit int `json:"limit"`
}

func NewQuerySubscriptionsParams

func NewQuerySubscriptionsParams(skip, limit int) QuerySubscriptionsParams

type Quota

type Quota struct {
	Address   sdk.AccAddress `json:"address"`
	Consumed  sdk.Int        `json:"consumed"`
	Allocated sdk.Int        `json:"allocated"`
}

func (Quota) String

func (q Quota) String() string

func (Quota) Validate

func (q Quota) Validate() error

type Quotas

type Quotas []Quota

type Subscription

type Subscription struct {
	ID    uint64         `json:"id"`
	Owner sdk.AccAddress `json:"owner"`

	Node    hub.NodeAddress `json:"node,omitempty"`
	Price   sdk.Coin        `json:"price,omitempty"`
	Deposit sdk.Coin        `json:"deposit,omitempty"`

	Plan   uint64    `json:"plan,omitempty"`
	Expiry time.Time `json:"expiry,omitempty"`

	Free     sdk.Int    `json:"free"`
	Status   hub.Status `json:"status"`
	StatusAt time.Time  `json:"status_at"`
}

func (Subscription) Amount

func (s Subscription) Amount(consumed sdk.Int) sdk.Coin

func (Subscription) String

func (s Subscription) String() string

func (Subscription) Validate

func (s Subscription) Validate() error

type Subscriptions

type Subscriptions []Subscription

Jump to

Keyboard shortcuts

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