types

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2020 License: Apache-2.0 Imports: 8 Imported by: 14

Documentation

Index

Constants

View Source
const (
	EventTypeSetCount    = "subscription:set_count"
	EventTypeSet         = "subscription:set"
	EventTypeCancel      = "subscription:cancel"
	EventTypeAddQuota    = "subscription:add_quota"
	EventTypeUpdateQuota = "subscription:update_quota"
)
View Source
const (
	AttributeKeyOwner     = "owner"
	AttributeKeyAddress   = "address"
	AttributeKeyID        = "id"
	AttributeKeyNode      = "node"
	AttributeKeyCount     = "count"
	AttributeKeyPlan      = "plan"
	AttributeKeyConsumed  = "consumed"
	AttributeKeyAllocated = "allocated"
)
View Source
const (
	ModuleName     = "subscription"
	ParamsSubspace = ModuleName
	QuerierRoute   = ModuleName
)
View Source
const (
	QuerySubscription            = "subscription"
	QuerySubscriptions           = "subscriptions"
	QuerySubscriptionsForAddress = "subscriptions_for_address"
	QuerySubscriptionsForPlan    = "subscriptions_for_plan"
	QuerySubscriptionsForNode    = "subscriptions_for_node"

	QueryQuota  = "quota"
	QueryQuotas = "quotas"
)
View Source
const (
	Codespace = sdk.CodespaceType(ModuleName)
)
View Source
const (
	DefaultCancelDuration = 6 * time.Hour
)

Variables

View Source
var (
	RouterKey = ModuleName
	StoreKey  = ModuleName
)
View Source
var (
	CountKey                        = []byte{0x00}
	SubscriptionKeyPrefix           = []byte{0x01}
	SubscriptionForAddressKeyPrefix = []byte{0x02}
	SubscriptionForPlanKeyPrefix    = []byte{0x03}
	SubscriptionForNodeKeyPrefix    = []byte{0x04}
	CancelSubscriptionAtKeyPrefix   = []byte{0x05}

	QuotaKeyPrefix = []byte{0x10}
)
View Source
var (
	KeyCancelDuration = []byte("CancelDuration")
)
View Source
var (
	ModuleCdc *codec.Codec
)

Functions

func CancelSubscriptionAtKey

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

func ErrorCanNotSubscribe

func ErrorCanNotSubscribe() sdk.Error

func ErrorDuplicateQuota

func ErrorDuplicateQuota() sdk.Error

func ErrorInvalidField

func ErrorInvalidField(v string) sdk.Error

func ErrorInvalidNodeStatus

func ErrorInvalidNodeStatus() sdk.Error

func ErrorInvalidPlanStatus

func ErrorInvalidPlanStatus() sdk.Error

func ErrorInvalidQuota

func ErrorInvalidQuota() sdk.Error

func ErrorInvalidSubscriptionStatus

func ErrorInvalidSubscriptionStatus() sdk.Error

func ErrorMarshal

func ErrorMarshal() sdk.Error

func ErrorNodeDoesNotExist

func ErrorNodeDoesNotExist() sdk.Error

func ErrorPlanDoesNotExist

func ErrorPlanDoesNotExist() sdk.Error

func ErrorPriceDoesNotExist

func ErrorPriceDoesNotExist() sdk.Error

func ErrorQuotaDoesNotExist

func ErrorQuotaDoesNotExist() sdk.Error

func ErrorSubscriptionDoesNotExist

func ErrorSubscriptionDoesNotExist() sdk.Error

func ErrorUnauthorized

func ErrorUnauthorized() sdk.Error

func ErrorUnknownMsgType

func ErrorUnknownMsgType(v string) sdk.Error

func ErrorUnknownQueryType

func ErrorUnknownQueryType(v string) sdk.Error

func ErrorUnmarshal

func ErrorUnmarshal() sdk.Error

func GetCancelSubscriptionAtKeyPrefix

func GetCancelSubscriptionAtKeyPrefix(at time.Time) []byte

func GetQuotaKeyPrefix

func GetQuotaKeyPrefix(id uint64) []byte

func GetSubscriptionForAddressKeyPrefix

func GetSubscriptionForAddressKeyPrefix(address sdk.AccAddress) []byte

func GetSubscriptionForNodeKeyPrefix

func GetSubscriptionForNodeKeyPrefix(address hub.NodeAddress) []byte

func GetSubscriptionForPlanKeyPrefix

func GetSubscriptionForPlanKeyPrefix(id 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 SubscriptionForAddressKey

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

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"`
	Bandwidth hub.Bandwidth  `json:"bandwidth"`
}

MsgAddQuota is for adding the bandwidth quota for an address.

func NewMsgAddQuota

func NewMsgAddQuota(from sdk.AccAddress, id uint64, address sdk.AccAddress, bandwidth hub.Bandwidth) 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() sdk.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() sdk.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() sdk.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() sdk.Error

type MsgUpdateQuota

type MsgUpdateQuota struct {
	From      sdk.AccAddress `json:"from"`
	ID        uint64         `json:"id"`
	Address   sdk.AccAddress `json:"address"`
	Bandwidth hub.Bandwidth  `json:"bandwidth"`
}

MsgUpdateQuota is for updating the bandwidth quota for an address.

func NewMsgUpdateQuota

func NewMsgUpdateQuota(from sdk.AccAddress, id uint64, address sdk.AccAddress, bandwidth hub.Bandwidth) 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() sdk.Error

type Params

type Params struct {
	CancelDuration time.Duration `json:"cancel_duration"`
}

func DefaultParams

func DefaultParams() Params

func NewParams

func NewParams(cancelDuration 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"`
	Page  int    `json:"page"`
	Limit int    `json:"limit"`
}

func NewQueryQuotasParams

func NewQueryQuotasParams(id uint64, page, 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"`
	Page    int            `json:"page"`
	Limit   int            `json:"limit"`
}

func NewQuerySubscriptionsForAddressParams

func NewQuerySubscriptionsForAddressParams(address sdk.AccAddress, page, limit int) QuerySubscriptionsForAddressParams

type QuerySubscriptionsForNodeParams

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

func NewQuerySubscriptionsForNodeParams

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

type QuerySubscriptionsForPlanParams

type QuerySubscriptionsForPlanParams struct {
	ID    uint64 `json:"id"`
	Page  int    `json:"page"`
	Limit int    `json:"limit"`
}

func NewQuerySubscriptionsForPlanParams

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

type QuerySubscriptionsParams

type QuerySubscriptionsParams struct {
	Page  int `json:"page"`
	Limit int `json:"limit"`
}

func NewQuerySubscriptionsParams

func NewQuerySubscriptionsParams(page, limit int) QuerySubscriptionsParams

type Quota

type Quota struct {
	Address   sdk.AccAddress `json:"address"`
	Consumed  hub.Bandwidth  `json:"consumed"`
	Allocated hub.Bandwidth  `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"`

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

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

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

func (Subscription) Amount

func (s Subscription) Amount(consumed hub.Bandwidth) 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