types

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ModuleName is the module name constant used in many places
	ModuleName = "deployment"

	// StoreKey is the store key string for deployment
	StoreKey = ModuleName

	// RouterKey is the message route for deployment
	RouterKey = ModuleName
)

Variables

View Source
var (
	// ErrNameDoesNotExist is the error when name does not exist
	ErrNameDoesNotExist = sdkerrors.Register(ModuleName, 1, "Name does not exist")
	// ErrInvalidRequest is the error for invalid request
	ErrInvalidRequest = sdkerrors.Register(ModuleName, 2, "Invalid request")
	// ErrDeploymentExists is the error when already deployment exists
	ErrDeploymentExists = sdkerrors.Register(ModuleName, 3, "Deployment exists")
	// ErrDeploymentNotFound is the error when deployment not found
	ErrDeploymentNotFound = sdkerrors.Register(ModuleName, 4, "Deployment not found")
	// ErrDeploymentClosed is the error when deployment is closed
	ErrDeploymentClosed = sdkerrors.Register(ModuleName, 5, "Deployment closed")
	// ErrOwnerAcctMissing is the error for owner account missing
	ErrOwnerAcctMissing = sdkerrors.Register(ModuleName, 6, "Owner account missing")
	// ErrEmptyGroups is the error when groups are empty
	ErrEmptyGroups = sdkerrors.Register(ModuleName, 7, "Invalid: empty groups")
	// ErrInvalidDeploymentID is the error for invalid deployment id
	ErrInvalidDeploymentID = sdkerrors.Register(ModuleName, 8, "Invalid: deployment id")
	// ErrEmptyVersion is the error when version is empty
	ErrEmptyVersion = sdkerrors.Register(ModuleName, 9, "Invalid: empty version")
	// ErrInternal is the error for internal error
	ErrInternal = sdkerrors.Register(ModuleName, 10, "internal error")
)
View Source
var DeploymentStateMap = map[string]DeploymentState{
	"active": DeploymentActive,
	"closed": DeploymentClosed,
}

DeploymentStateMap is used to decode deployment state flag value

View Source
var GroupStateMap = map[string]GroupState{
	"open":         GroupOpen,
	"ordered":      GroupOrdered,
	"matched":      GroupMatched,
	"insufficient": GroupInsufficientFunds,
	"closed":       GroupClosed,
}

GroupStateMap is used to decode group state flag value

Functions

func DeploymentIDEVAttributes

func DeploymentIDEVAttributes(id DeploymentID) []sdk.Attribute

DeploymentIDEVAttributes returns event attribues for given DeploymentID

func GroupIDEVAttributes

func GroupIDEVAttributes(id GroupID) []sdk.Attribute

GroupIDEVAttributes returns event attribues for given GroupID

func MustMarshalJSON

func MustMarshalJSON(o interface{}) []byte

MustMarshalJSON panics if an error occurs. Besides that it behaves exactly like MarshalJSON i.e., encodes json to byte array

func MustUnmarshalJSON

func MustUnmarshalJSON(bz []byte, ptr interface{})

MustUnmarshalJSON panics if an error occurs. Besides that it behaves exactly like UnmarshalJSON.

func ParseEvent

func ParseEvent(ev sdkutil.Event) (interface{}, error)

ParseEvent parses event and returns details of event and error if occured

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec register concrete types on codec

func UnmarshalJSON

func UnmarshalJSON(bz []byte, ptr interface{}) error

UnmarshalJSON decodes bytes into json

Types

type Deployment

type Deployment struct {
	DeploymentID `json:"id"`
	State        DeploymentState `json:"state"`
	Version      []byte          `json:"version"`
}

Deployment stores deploymentID, state and version details

func (Deployment) ID

func (obj Deployment) ID() DeploymentID

ID method returns DeploymentID details of specific deployment

type DeploymentFilters

type DeploymentFilters struct {
	Owner sdk.AccAddress
	// State flag value given
	StateFlagVal string
	// Actual state value decoded from DeploymentStateMap
	State DeploymentState
}

DeploymentFilters defines flags for deployment list filter

type DeploymentID

type DeploymentID struct {
	Owner sdk.AccAddress `json:"owner"`
	DSeq  uint64         `json:"dseq"`
}

DeploymentID stores owner and sequence number

func ParseEVDeploymentID

func ParseEVDeploymentID(attrs []sdk.Attribute) (DeploymentID, error)

ParseEVDeploymentID returns deploymentID details for given event attributes

func (DeploymentID) Equals

func (id DeploymentID) Equals(other DeploymentID) bool

Equals method compares specific deployment with provided deployment

func (DeploymentID) Validate

func (id DeploymentID) Validate() error

Validate method for DeploymentID and returns nil

type DeploymentState

type DeploymentState uint8

DeploymentState defines state of deployment

const (
	// DeploymentActive is used when state of deployment is active
	DeploymentActive DeploymentState = iota
	// DeploymentClosed is used when state of deployment is closed
	DeploymentClosed DeploymentState = iota
)

type EventDeploymentClose

type EventDeploymentClose struct {
	ID DeploymentID
}

EventDeploymentClose struct

func (EventDeploymentClose) ToSDKEvent

func (ev EventDeploymentClose) ToSDKEvent() sdk.Event

ToSDKEvent method creates new sdk event for EventDeploymentClose struct

type EventDeploymentCreate

type EventDeploymentCreate struct {
	ID DeploymentID
}

EventDeploymentCreate struct

func (EventDeploymentCreate) ToSDKEvent

func (ev EventDeploymentCreate) ToSDKEvent() sdk.Event

ToSDKEvent method creates new sdk event for EventDeploymentCreate struct

type EventDeploymentUpdate

type EventDeploymentUpdate struct {
	ID      DeploymentID
	Version []byte // TODO
}

EventDeploymentUpdate struct

func (EventDeploymentUpdate) ToSDKEvent

func (ev EventDeploymentUpdate) ToSDKEvent() sdk.Event

ToSDKEvent method creates new sdk event for EventDeploymentUpdate struct

type Group

type Group struct {
	GroupID   `json:"id"`
	State     GroupState `json:"state"`
	GroupSpec `json:"spec"`
}

Group stores groupID, state and other specifications

func (Group) ID

func (d Group) ID() GroupID

ID method returns GroupID details of specific group

func (Group) ValidateOrderable

func (d Group) ValidateOrderable() error

ValidateOrderable method checks whether group opened or not

type GroupFilters

type GroupFilters struct {
	Owner sdk.AccAddress
	// State flag value given
	StateFlagVal string
	// Actual state value decoded from GroupStateMap
	State GroupState
}

GroupFilters defines flags for group list filter

type GroupID

type GroupID struct {
	Owner sdk.AccAddress `json:"owner"`
	DSeq  uint64         `json:"dseq"`
	GSeq  uint32         `json:"gseq"`
}

GroupID stores owner, deployment sequence number and group sequence number

func MakeGroupID

func MakeGroupID(id DeploymentID, gseq uint32) GroupID

MakeGroupID returns GroupID instance with provided deployment details and group sequence number.

func ParseEVGroupID

func ParseEVGroupID(attrs []sdk.Attribute) (GroupID, error)

ParseEVGroupID returns GroupID details for given event attributes

func (GroupID) DeploymentID

func (id GroupID) DeploymentID() DeploymentID

DeploymentID method returns DeploymentID details with specific group details

func (GroupID) Equals

func (id GroupID) Equals(other GroupID) bool

Equals method compares specific group with provided group

func (GroupID) Validate

func (id GroupID) Validate() error

Validate method for GroupID and returns nil

type GroupSpec

type GroupSpec struct {
	Name         string      `json:"name"`
	Requirements []tmkv.Pair `json:"requirements"`
	Resources    []Resource  `json:"resources"`
}

GroupSpec stores group specifications

func (GroupSpec) GetName

func (g GroupSpec) GetName() string

GetName method returns group name

func (GroupSpec) GetResources

func (g GroupSpec) GetResources() []types.Resource

GetResources method returns resources list in group

func (GroupSpec) MatchAttributes

func (g GroupSpec) MatchAttributes(attrs []tmkv.Pair) bool

MatchAttributes method compares provided attributes with specific group attributes

func (GroupSpec) Price

func (g GroupSpec) Price() sdk.Coin

Price method returns price of group

type GroupState

type GroupState uint8

GroupState defines state of group

const (
	// GroupOpen is used when state of group is open
	GroupOpen GroupState = iota
	// GroupOrdered is used when state of group is ordered
	GroupOrdered GroupState = iota
	// GroupMatched is used when state of group is matched
	GroupMatched GroupState = iota
	// GroupInsufficientFunds is used when group has insufficient funds
	GroupInsufficientFunds GroupState = iota
	// GroupClosed is used when state of group is closed
	GroupClosed GroupState = iota
)

type MsgClose

type MsgClose struct {
	ID DeploymentID
}

MsgClose defines an SDK message for closing deployment

func (MsgClose) GetSignBytes

func (msg MsgClose) GetSignBytes() []byte

GetSignBytes encodes the message for signing

func (MsgClose) GetSigners

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

GetSigners defines whose signature is required

func (MsgClose) Route

func (msg MsgClose) Route() string

Route implements the sdk.Msg interface

func (MsgClose) Type

func (msg MsgClose) Type() string

Type implements the sdk.Msg interface

func (MsgClose) ValidateBasic

func (msg MsgClose) ValidateBasic() error

ValidateBasic does basic validation with deployment details

type MsgCreate

type MsgCreate struct {
	Owner sdk.AccAddress `json:"owner"`
	// Sequence uint64         `json:"sequence"`
	// Version []byte      `json:"version"`
	Groups []GroupSpec `json:"groups"`
}

MsgCreate defines an SDK message for creating deployment

func (MsgCreate) GetSignBytes

func (msg MsgCreate) GetSignBytes() []byte

GetSignBytes encodes the message for signing

func (MsgCreate) GetSigners

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

GetSigners defines whose signature is required

func (MsgCreate) Route

func (msg MsgCreate) Route() string

Route implements the sdk.Msg interface

func (MsgCreate) Type

func (msg MsgCreate) Type() string

Type implements the sdk.Msg interface

func (MsgCreate) ValidateBasic

func (msg MsgCreate) ValidateBasic() error

ValidateBasic does basic validation like check owner and groups length

type MsgUpdate

type MsgUpdate struct {
	ID      DeploymentID
	Version sdk.AccAddress
}

MsgUpdate defines an SDK message for updating deployment

func (MsgUpdate) GetSignBytes

func (msg MsgUpdate) GetSignBytes() []byte

GetSignBytes encodes the message for signing

func (MsgUpdate) GetSigners

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

GetSigners defines whose signature is required

func (MsgUpdate) Route

func (msg MsgUpdate) Route() string

Route implements the sdk.Msg interface

func (MsgUpdate) Type

func (msg MsgUpdate) Type() string

Type implements the sdk.Msg interface

func (MsgUpdate) ValidateBasic

func (msg MsgUpdate) ValidateBasic() error

ValidateBasic does basic validation

type Resource

type Resource struct {
	Unit  types.Unit `json:"unit"`
	Count uint32     `json:"count"`
	Price sdk.Coin   `json:"price"`
}

Resource stores unit, count and price of each resource

func (Resource) FullPrice

func (r Resource) FullPrice() sdk.Coin

func (Resource) GetCount

func (r Resource) GetCount() uint32

GetCount method returns count of resource

func (Resource) GetUnit

func (r Resource) GetUnit() types.Unit

GetUnit method returns unit of resource

Jump to

Keyboard shortcuts

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