service

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2018 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCodespace sdk.CodespaceType = 8

	CodeInvalidIDL               sdk.CodeType = 100
	CodeSvcDefExists             sdk.CodeType = 101
	CodeSvcDefNotExists          sdk.CodeType = 102
	CodeInvalidOutputPrivacyEnum sdk.CodeType = 103
	CodeInvalidOutputCachedEnum  sdk.CodeType = 104
	CodeInvalidServiceName       sdk.CodeType = 105
	CodeInvalidChainId           sdk.CodeType = 106
	CodeInvalidAuthor            sdk.CodeType = 107
	CodeInvalidMethodName        sdk.CodeType = 108

	CodeSvcBindingExists     sdk.CodeType = 109
	CodeSvcBindingNotExists  sdk.CodeType = 110
	CodeInvalidDefChainId    sdk.CodeType = 111
	CodeInvalidBindingType   sdk.CodeType = 112
	CodeInvalidLevel         sdk.CodeType = 113
	CodeInvalidPriceCount    sdk.CodeType = 114
	CodeInvalidRefundDeposit sdk.CodeType = 115
	CodeLtMinProviderDeposit sdk.CodeType = 116
	CodeInvalidDisable       sdk.CodeType = 117
	CodeInvalidEnable        sdk.CodeType = 118
)
View Source
const (
	// name to idetify transaction types
	MsgType = "service"
)

Variables

This section is empty.

Functions

func ErrDisable

func ErrDisable(codespace sdk.CodespaceType, msg string) sdk.Error

func ErrEnable

func ErrEnable(codespace sdk.CodespaceType, msg string) sdk.Error

func ErrInvalidAuthor

func ErrInvalidAuthor(codespace sdk.CodespaceType) sdk.Error

func ErrInvalidBindingType

func ErrInvalidBindingType(codespace sdk.CodespaceType, bindingType BindingType) sdk.Error

func ErrInvalidChainId

func ErrInvalidChainId(codespace sdk.CodespaceType) sdk.Error

func ErrInvalidDefChainId

func ErrInvalidDefChainId(codespace sdk.CodespaceType) sdk.Error

func ErrInvalidIDL

func ErrInvalidIDL(codespace sdk.CodespaceType, msg string) sdk.Error

func ErrInvalidLevel

func ErrInvalidLevel(codespace sdk.CodespaceType, level Level) sdk.Error

func ErrInvalidMethodName

func ErrInvalidMethodName(codespace sdk.CodespaceType) sdk.Error

func ErrInvalidOutputCachedEnum

func ErrInvalidOutputCachedEnum(codespace sdk.CodespaceType, value string) sdk.Error

func ErrInvalidOutputPrivacyEnum

func ErrInvalidOutputPrivacyEnum(codespace sdk.CodespaceType, value string) sdk.Error

func ErrInvalidPriceCount

func ErrInvalidPriceCount(codespace sdk.CodespaceType, priceCount int, methodCount int) sdk.Error

func ErrInvalidServiceName

func ErrInvalidServiceName(codespace sdk.CodespaceType, msg string) sdk.Error

func ErrLtMinProviderDeposit

func ErrLtMinProviderDeposit(codespace sdk.CodespaceType, coins sdk.Coins) sdk.Error

func ErrRefundDeposit

func ErrRefundDeposit(codespace sdk.CodespaceType, msg string) sdk.Error

func ErrSvcBindingExists

func ErrSvcBindingExists(codespace sdk.CodespaceType) sdk.Error

func ErrSvcBindingNotExists

func ErrSvcBindingNotExists(codespace sdk.CodespaceType) sdk.Error

func ErrSvcDefExists

func ErrSvcDefExists(codespace sdk.CodespaceType, defChainId, svcDefName string) sdk.Error

func ErrSvcDefNotExists

func ErrSvcDefNotExists(codespace sdk.CodespaceType, defChainId, svcDefName string) sdk.Error

func GetBindingsSubspaceKey

func GetBindingsSubspaceKey(chainId, serviceName string) []byte

Key for getting all methods on a service from the store

func GetMethodPropertyKey

func GetMethodPropertyKey(chainId, serviceName string, id int) []byte

id can not zero

func GetMethodsSubspaceKey

func GetMethodsSubspaceKey(chainId, serviceName string) []byte

Key for getting all methods on a service from the store

func GetServiceBindingKey

func GetServiceBindingKey(defChainId, name, bindChainId string, provider sdk.AccAddress) []byte

func GetServiceDefinitionKey

func GetServiceDefinitionKey(chainId, name string) []byte

func InitGenesis

func InitGenesis(ctx sdk.Context, data GenesisState)

InitGenesis - store genesis parameters

func NewError

func NewError(codespace sdk.CodespaceType, code sdk.CodeType, msg string) sdk.Error

func NewHandler

func NewHandler(k Keeper) sdk.Handler

handle all "service" type messages.

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

Register concrete types on codec codec

func SortAddresses

func SortAddresses(addrs []sdk.AccAddress)

Sorts Addresses

func SortByteArrays

func SortByteArrays(src [][]byte) [][]byte

Public

func SvcBindingEqual

func SvcBindingEqual(bindingA, bindingB SvcBinding) bool

Types

type BindingType

type BindingType byte
const (
	Global BindingType = 0x01
	Local  BindingType = 0x02
)

func BindingTypeFromString

func BindingTypeFromString(str string) (BindingType, error)

String to BindingType byte, Returns ff if invalid.

func (BindingType) Format

func (bt BindingType) Format(s fmt.State, verb rune)

For Printf / Sprintf, returns bech32 when using %s

func (BindingType) MarshalJSON

func (bt BindingType) MarshalJSON() ([]byte, error)

Marshals to JSON using string

func (BindingType) String

func (bt BindingType) String() string

Turns BindingType byte to String

func (*BindingType) UnmarshalJSON

func (bt *BindingType) UnmarshalJSON(data []byte) error

Unmarshals from JSON assuming Bech32 encoding

type GenesisState

type GenesisState struct {
	MaxRequestTimeout  int64
	MinProviderDeposit sdk.Coins
}

GenesisState - all service state that must be provided at genesis

func DefaultGenesisState

func DefaultGenesisState() GenesisState

get raw genesis raw message for testing

func DefaultGenesisStateForTest

func DefaultGenesisStateForTest() GenesisState

get raw genesis raw message for testing

func NewGenesisState

func NewGenesisState(maxRequestTimeout int64, minProviderDeposit sdk.Coins) GenesisState

func WriteGenesis

func WriteGenesis(ctx sdk.Context) GenesisState

WriteGenesis - output genesis parameters

type Keeper

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

func NewKeeper

func NewKeeper(cdc *codec.Codec, key sdk.StoreKey, ck bank.Keeper, codespace sdk.CodespaceType) Keeper

func (Keeper) AddMethods

func (k Keeper) AddMethods(ctx sdk.Context, svcDef SvcDef) sdk.Error

func (Keeper) AddServiceBinding

func (k Keeper) AddServiceBinding(ctx sdk.Context, svcBinding SvcBinding) (sdk.Error, bool)

func (Keeper) AddServiceDefinition

func (k Keeper) AddServiceDefinition(ctx sdk.Context, svcDef SvcDef)

func (Keeper) Codespace

func (k Keeper) Codespace() sdk.CodespaceType

return the codespace

func (Keeper) Disable

func (k Keeper) Disable(ctx sdk.Context, defChainID, defName, bindChainID string, provider sdk.AccAddress) (sdk.Error, bool)

func (Keeper) Enable

func (k Keeper) Enable(ctx sdk.Context, defChainID, defName, bindChainID string, provider sdk.AccAddress, deposit sdk.Coins) (sdk.Error, bool)

func (Keeper) GetMethods

func (k Keeper) GetMethods(ctx sdk.Context, chainId, name string) sdk.Iterator

Gets all the methods in a specific service

func (Keeper) GetServiceBinding

func (k Keeper) GetServiceBinding(ctx sdk.Context, defChainID, defName, bindChainID string, provider sdk.AccAddress) (svcBinding SvcBinding, found bool)

func (Keeper) GetServiceDefinition

func (k Keeper) GetServiceDefinition(ctx sdk.Context, chainId, name string) (svcDef SvcDef, found bool)

func (Keeper) RefundDeposit

func (k Keeper) RefundDeposit(ctx sdk.Context, defChainID, defName, bindChainID string, provider sdk.AccAddress) (sdk.Error, bool)

func (Keeper) UpdateServiceBinding

func (k Keeper) UpdateServiceBinding(ctx sdk.Context, svcBinding SvcBinding) (sdk.Error, bool)

type Level

type Level struct {
	AvgRspTime int64 `json:"avg_rsp_time"`
	UsableTime int64 `json:"usable_time"`
}

type MessagingType

type MessagingType byte
const (
	Unicast   MessagingType = 0x01
	Multicast MessagingType = 0x02
)

func MessagingTypeFromString

func MessagingTypeFromString(str string) (MessagingType, error)

String to messagingType byte, Returns ff if invalid.

func (MessagingType) Format

func (mt MessagingType) Format(s fmt.State, verb rune)

For Printf / Sprintf, returns bech32 when using %s

func (MessagingType) MarshalJSON

func (mt MessagingType) MarshalJSON() ([]byte, error)

Marshals to JSON using string

func (MessagingType) String

func (mt MessagingType) String() string

Turns MessagingType byte to String

func (*MessagingType) UnmarshalJSON

func (mt *MessagingType) UnmarshalJSON(data []byte) error

Unmarshals from JSON assuming Bech32 encoding

type MethodProperty

type MethodProperty struct {
	ID            int               `json:"id"`
	Name          string            `json:"name"`
	Description   string            `json:"description"`
	OutputPrivacy OutputPrivacyEnum `json:"output_privacy"`
	OutputCached  OutputCachedEnum  `json:"output_cached"`
}

type MsgSvcBind

type MsgSvcBind struct {
	DefName     string         `json:"def_name"`
	DefChainID  string         `json:"def_chain_id"`
	BindChainID string         `json:"bind_chain_id"`
	Provider    sdk.AccAddress `json:"provider"`
	BindingType BindingType    `json:"binding_type"`
	Deposit     sdk.Coins      `json:"deposit"`
	Prices      []sdk.Coin     `json:"price"`
	Level       Level          `json:"level"`
}

MsgSvcBinding - struct for bind a service

func NewMsgSvcBind

func NewMsgSvcBind(defChainID, defName, bindChainID string, provider sdk.AccAddress, bindingType BindingType, deposit sdk.Coins, prices []sdk.Coin, level Level) MsgSvcBind

func (MsgSvcBind) GetSignBytes

func (msg MsgSvcBind) GetSignBytes() []byte

func (MsgSvcBind) GetSigners

func (msg MsgSvcBind) GetSigners() []sdk.AccAddress

func (MsgSvcBind) Route

func (msg MsgSvcBind) Route() string

func (MsgSvcBind) Type

func (msg MsgSvcBind) Type() string

func (MsgSvcBind) ValidateBasic

func (msg MsgSvcBind) ValidateBasic() sdk.Error

type MsgSvcBindingUpdate

type MsgSvcBindingUpdate struct {
	DefName     string         `json:"def_name"`
	DefChainID  string         `json:"def_chain_id"`
	BindChainID string         `json:"bind_chain_id"`
	Provider    sdk.AccAddress `json:"provider"`
	BindingType BindingType    `json:"binding_type"`
	Deposit     sdk.Coins      `json:"deposit"`
	Prices      []sdk.Coin     `json:"price"`
	Level       Level          `json:"level"`
}

MsgSvcBindingUpdate - struct for update a service binding

func NewMsgSvcBindingUpdate

func NewMsgSvcBindingUpdate(defChainID, defName, bindChainID string, provider sdk.AccAddress, bindingType BindingType, deposit sdk.Coins, prices []sdk.Coin, level Level) MsgSvcBindingUpdate

func (MsgSvcBindingUpdate) GetSignBytes

func (msg MsgSvcBindingUpdate) GetSignBytes() []byte

func (MsgSvcBindingUpdate) GetSigners

func (msg MsgSvcBindingUpdate) GetSigners() []sdk.AccAddress

func (MsgSvcBindingUpdate) Route

func (msg MsgSvcBindingUpdate) Route() string

func (MsgSvcBindingUpdate) Type

func (msg MsgSvcBindingUpdate) Type() string

func (MsgSvcBindingUpdate) ValidateBasic

func (msg MsgSvcBindingUpdate) ValidateBasic() sdk.Error

type MsgSvcDef

type MsgSvcDef struct {
	SvcDef
}

MsgSvcDef - struct for define a service

func NewMsgSvcDef

func NewMsgSvcDef(name, chainId, description string, tags []string, author sdk.AccAddress, authorDescription, idlContent string) MsgSvcDef

func (MsgSvcDef) GetSignBytes

func (msg MsgSvcDef) GetSignBytes() []byte

func (MsgSvcDef) GetSigners

func (msg MsgSvcDef) GetSigners() []sdk.AccAddress

func (MsgSvcDef) Route

func (msg MsgSvcDef) Route() string

func (MsgSvcDef) Type

func (msg MsgSvcDef) Type() string

func (MsgSvcDef) ValidateBasic

func (msg MsgSvcDef) ValidateBasic() sdk.Error

type MsgSvcDisable

type MsgSvcDisable struct {
	DefName     string         `json:"def_name"`
	DefChainID  string         `json:"def_chain_id"`
	BindChainID string         `json:"bind_chain_id"`
	Provider    sdk.AccAddress `json:"provider"`
}

MsgSvcDisable - struct for disable a service binding

func NewMsgSvcDisable

func NewMsgSvcDisable(defChainID, defName, bindChainID string, provider sdk.AccAddress) MsgSvcDisable

func (MsgSvcDisable) GetSignBytes

func (msg MsgSvcDisable) GetSignBytes() []byte

func (MsgSvcDisable) GetSigners

func (msg MsgSvcDisable) GetSigners() []sdk.AccAddress

func (MsgSvcDisable) Route

func (msg MsgSvcDisable) Route() string

func (MsgSvcDisable) Type

func (msg MsgSvcDisable) Type() string

func (MsgSvcDisable) ValidateBasic

func (msg MsgSvcDisable) ValidateBasic() sdk.Error

type MsgSvcEnable

type MsgSvcEnable struct {
	DefName     string         `json:"def_name"`
	DefChainID  string         `json:"def_chain_id"`
	BindChainID string         `json:"bind_chain_id"`
	Provider    sdk.AccAddress `json:"provider"`
	Deposit     sdk.Coins      `json:"deposit"`
}

MsgSvcEnable - struct for enable a service binding

func NewMsgSvcEnable

func NewMsgSvcEnable(defChainID, defName, bindChainID string, provider sdk.AccAddress, deposit sdk.Coins) MsgSvcEnable

func (MsgSvcEnable) GetSignBytes

func (msg MsgSvcEnable) GetSignBytes() []byte

func (MsgSvcEnable) GetSigners

func (msg MsgSvcEnable) GetSigners() []sdk.AccAddress

func (MsgSvcEnable) Route

func (msg MsgSvcEnable) Route() string

func (MsgSvcEnable) Type

func (msg MsgSvcEnable) Type() string

func (MsgSvcEnable) ValidateBasic

func (msg MsgSvcEnable) ValidateBasic() sdk.Error

type MsgSvcRefundDeposit

type MsgSvcRefundDeposit struct {
	DefName     string         `json:"def_name"`
	DefChainID  string         `json:"def_chain_id"`
	BindChainID string         `json:"bind_chain_id"`
	Provider    sdk.AccAddress `json:"provider"`
}

MsgSvcRefundDeposit - struct for refund deposit from a service binding

func NewMsgSvcRefundDeposit

func NewMsgSvcRefundDeposit(defChainID, defName, bindChainID string, provider sdk.AccAddress) MsgSvcRefundDeposit

func (MsgSvcRefundDeposit) GetSignBytes

func (msg MsgSvcRefundDeposit) GetSignBytes() []byte

func (MsgSvcRefundDeposit) GetSigners

func (msg MsgSvcRefundDeposit) GetSigners() []sdk.AccAddress

func (MsgSvcRefundDeposit) Route

func (msg MsgSvcRefundDeposit) Route() string

func (MsgSvcRefundDeposit) Type

func (msg MsgSvcRefundDeposit) Type() string

func (MsgSvcRefundDeposit) ValidateBasic

func (msg MsgSvcRefundDeposit) ValidateBasic() sdk.Error

type OutputCachedEnum

type OutputCachedEnum byte
const (
	OffChainCached OutputCachedEnum = 0x01
	NoCached       OutputCachedEnum = 0x02
)

func OutputCachedEnumFromString

func OutputCachedEnumFromString(str string) (OutputCachedEnum, error)

String to outputCachedEnum byte, Returns ff if invalid.

func (OutputCachedEnum) Format

func (oe OutputCachedEnum) Format(s fmt.State, verb rune)

For Printf / Sprintf, returns bech32 when using %s

func (OutputCachedEnum) MarshalJSON

func (oe OutputCachedEnum) MarshalJSON() ([]byte, error)

Marshals to JSON using string

func (OutputCachedEnum) String

func (oe OutputCachedEnum) String() string

Turns OutputCachedEnum byte to String

func (*OutputCachedEnum) UnmarshalJSON

func (oe *OutputCachedEnum) UnmarshalJSON(data []byte) error

Unmarshals from JSON assuming Bech32 encoding

type OutputPrivacyEnum

type OutputPrivacyEnum byte
const (
	NoPrivacy        OutputPrivacyEnum = 0x01
	PubKeyEncryption OutputPrivacyEnum = 0x02
)

func OutputPrivacyEnumFromString

func OutputPrivacyEnumFromString(str string) (OutputPrivacyEnum, error)

String to outputPrivacyEnum byte, Returns ff if invalid.

func (OutputPrivacyEnum) Format

func (oe OutputPrivacyEnum) Format(s fmt.State, verb rune)

For Printf / Sprintf, returns bech32 when using %s

func (OutputPrivacyEnum) MarshalJSON

func (oe OutputPrivacyEnum) MarshalJSON() ([]byte, error)

Marshals to JSON using string

func (OutputPrivacyEnum) String

func (oe OutputPrivacyEnum) String() string

Turns OutputCachedEnum byte to String

func (*OutputPrivacyEnum) UnmarshalJSON

func (oe *OutputPrivacyEnum) UnmarshalJSON(data []byte) error

Unmarshals from JSON assuming Bech32 encoding

type SvcBinding

type SvcBinding struct {
	DefName       string         `json:"def_name"`
	DefChainID    string         `json:"def_chain_id"`
	BindChainID   string         `json:"bind_chain_id"`
	Provider      sdk.AccAddress `json:"provider"`
	BindingType   BindingType    `json:"binding_type"`
	Deposit       sdk.Coins      `json:"deposit"`
	Prices        []sdk.Coin     `json:"price"`
	Level         Level          `json:"level"`
	Available     bool           `json:"available"`
	DisableHeight int64          `json:"disable_height"`
}

func NewSvcBinding

func NewSvcBinding(defChainID, defName, bindChainID string, provider sdk.AccAddress, bindingType BindingType, deposit sdk.Coins, prices []sdk.Coin, level Level, available bool, disableHeight int64) SvcBinding

NewSvcBinding returns a new SvcBinding with the provided values.

type SvcDef

type SvcDef struct {
	Name              string         `json:"name"`
	ChainId           string         `json:"chain_id"`
	Description       string         `json:"description"`
	Tags              []string       `json:"tags"`
	Author            sdk.AccAddress `json:"author"`
	AuthorDescription string         `json:"author_description"`
	IDLContent        string         `json:"idl_content"`
}

func NewSvcDef

func NewSvcDef(name, chainId, description string, tags []string, author sdk.AccAddress, authorDescription, idlContent string) SvcDef

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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