types

package
v0.7.8-rc2 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2020 License: Apache-2.0 Imports: 7 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
)
View Source
const DefaultOrderBiddingDuration int64 = int64(12342)

DefaultOrderBiddingDuration is the default time limit for an Order being active. After the duration, the Order is automatically closed. ( 24(hr) * 3600(seconds per hour) ) / 7s-Block

View Source
const MaxBiddingDuration int64 = DefaultOrderBiddingDuration * int64(30)

MaxBiddingDuration is roughly 30 days of block height

Variables

View Source
var (
	// ErrNameDoesNotExist is the error when name does not exist
	ErrNameDoesNotExist = sdkerrors.Register(ModuleName, errNameDoesNotExist, "Name does not exist")
	// ErrInvalidRequest is the error for invalid request
	ErrInvalidRequest = sdkerrors.Register(ModuleName, errInvalidRequest, "Invalid request")
	// ErrDeploymentExists is the error when already deployment exists
	ErrDeploymentExists = sdkerrors.Register(ModuleName, errDeploymentExists, "Deployment exists")
	// ErrDeploymentNotFound is the error when deployment not found
	ErrDeploymentNotFound = sdkerrors.Register(ModuleName, errDeploymentNotFound, "Deployment not found")
	// ErrDeploymentClosed is the error when deployment is closed
	ErrDeploymentClosed = sdkerrors.Register(ModuleName, errDeploymentClosed, "Deployment closed")
	// ErrOwnerAcctMissing is the error for owner account missing
	ErrOwnerAcctMissing = sdkerrors.Register(ModuleName, errOwnerAcctMissing, "Owner account missing")
	// ErrInvalidGroups is the error when groups are empty
	ErrInvalidGroups = sdkerrors.Register(ModuleName, errInvalidGroups, "Invalid groups")
	// ErrInvalidDeploymentID is the error for invalid deployment id
	ErrInvalidDeploymentID = sdkerrors.Register(ModuleName, errInvalidDeploymentID, "Invalid: deployment id")
	// ErrEmptyVersion is the error when version is empty
	ErrEmptyVersion = sdkerrors.Register(ModuleName, errEmptyVersion, "Invalid: empty version")
	// ErrInternal is the error for internal error
	ErrInternal = sdkerrors.Register(ModuleName, errInternal, "internal error")
	// ErrInvalidDeployment = is the error when deployment does not pass validation
	ErrInvalidDeployment = sdkerrors.Register(ModuleName, errInvalidDeployment, "Invalid deployment")
	// ErrInvalidGroupID is the error when already deployment exists
	ErrInvalidGroupID = sdkerrors.Register(ModuleName, errInvalidGroupID, "Deployment exists")
	// ErrGroupNotFound is the keeper's error for not finding a group
	ErrGroupNotFound = sdkerrors.Register(ModuleName, errGroupNotFound, "Group not found")
	// ErrGroupClosed is the error when deployment is closed
	ErrGroupClosed = sdkerrors.Register(ModuleName, errGroupClosed, "Group already closed")
	// ErrGroupNotOpen indicates the Group state has progressed beyond initial Open.
	ErrGroupNotOpen = sdkerrors.Register(ModuleName, errGroupNotOpen, "Group not open")
	// ErrGroupSpecInvalid indicates a GroupSpec has invalid configuration
	ErrGroupSpecInvalid = sdkerrors.Register(ModuleName, errGroupSpec, "GroupSpec invalid")
)
View Source
var DeploymentStateMap = map[string]DeploymentState{
	"active": DeploymentActive,
	"closed": DeploymentClosed,
}

DeploymentStateMap is used to decode deployment 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 ParseEVDeploymentVersion added in v0.7.8

func ParseEVDeploymentVersion(attrs []sdk.Attribute) ([]byte, error)

ParseEVDeploymentVersion returns the Deployment's SDL sha256 sum

func ParseEvent

func ParseEvent(ev sdkutil.Event) (sdkutil.ModuleEvent, error)

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

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 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) String added in v0.7.8

func (id DeploymentID) String() string

String method for deployment IDs

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 + 1 // active
	// DeploymentClosed is used when state of deployment is closed
	DeploymentClosed // closed
)

func (DeploymentState) String added in v0.7.4

func (i DeploymentState) String() string

type EventDeploymentClosed added in v0.7.6

type EventDeploymentClosed struct {
	Context sdkutil.BaseModuleEvent `json:"context"`
	ID      DeploymentID            `json:"id"`
}

EventDeploymentClosed struct

func NewEventDeploymentClosed added in v0.7.6

func NewEventDeploymentClosed(id DeploymentID) EventDeploymentClosed

func (EventDeploymentClosed) ToSDKEvent added in v0.7.6

func (ev EventDeploymentClosed) ToSDKEvent() sdk.Event

ToSDKEvent method creates new sdk event for EventDeploymentClosed struct

type EventDeploymentCreated added in v0.7.6

type EventDeploymentCreated struct {
	Context sdkutil.BaseModuleEvent `json:"context"`
	ID      DeploymentID            `json:"id"`
	Version []byte                  `json:"version"`
}

EventDeploymentCreated struct

func NewEventDeploymentCreated added in v0.7.6

func NewEventDeploymentCreated(id DeploymentID, version []byte) EventDeploymentCreated

NewEventDeploymentCreated initializes creation event.

func (EventDeploymentCreated) ToSDKEvent added in v0.7.6

func (ev EventDeploymentCreated) ToSDKEvent() sdk.Event

ToSDKEvent method creates new sdk event for EventDeploymentCreated struct

type EventDeploymentUpdated added in v0.7.6

type EventDeploymentUpdated struct {
	Context sdkutil.BaseModuleEvent `json:"context"`
	ID      DeploymentID            `json:"id"`
	Version []byte                  `json:"version"`
}

EventDeploymentUpdated struct

func NewEventDeploymentUpdated added in v0.7.6

func NewEventDeploymentUpdated(id DeploymentID, version []byte) EventDeploymentUpdated

NewEventDeploymentUpdated initializes SDK type

func (EventDeploymentUpdated) ToSDKEvent added in v0.7.6

func (ev EventDeploymentUpdated) ToSDKEvent() sdk.Event

ToSDKEvent method creates new sdk event for EventDeploymentUpdated struct

type EventGroupClosed added in v0.7.6

type EventGroupClosed struct {
	Context sdkutil.BaseModuleEvent `json:"context"`
	ID      GroupID                 `json:"id"`
}

EventGroupClosed provides SDK event to signal group termination

func NewEventGroupClosed added in v0.7.6

func NewEventGroupClosed(id GroupID) EventGroupClosed

func (EventGroupClosed) ToSDKEvent added in v0.7.6

func (ev EventGroupClosed) ToSDKEvent() sdk.Event

ToSDKEvent produces the SDK notification for Event

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 (g Group) ID() GroupID

ID method returns GroupID details of specific group

func (Group) ValidateClosable added in v0.7.5

func (g Group) ValidateClosable() error

ValidateClosable provides error response if group is already closed, and thus should not be closed again, else nil.

func (Group) ValidateOrderable

func (g Group) ValidateOrderable() error

ValidateOrderable method checks whether group status is Open or not

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) String added in v0.7.8

func (id GroupID) String() string

String method provides human readable representation of GroupID.

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     []sdk.Attribute `json:"requirements"`
	Resources        []Resource      `json:"resources"`
	OrderBidDuration int64           `json:"bid-duration"`
}

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 []sdk.Attribute) 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

func (GroupSpec) ValidateBasic added in v0.7.8

func (g GroupSpec) ValidateBasic() error

ValidateBasic asserts non-zero values

type GroupState

type GroupState uint8

GroupState defines state of group

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

func (GroupState) String added in v0.7.4

func (i GroupState) String() string

type MsgCloseDeployment added in v0.6.5

type MsgCloseDeployment struct {
	ID DeploymentID
}

MsgCloseDeployment defines an SDK message for closing deployment

func (MsgCloseDeployment) GetSignBytes added in v0.6.5

func (msg MsgCloseDeployment) GetSignBytes() []byte

GetSignBytes encodes the message for signing

func (MsgCloseDeployment) GetSigners added in v0.6.5

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

GetSigners defines whose signature is required

func (MsgCloseDeployment) Route added in v0.6.5

func (msg MsgCloseDeployment) Route() string

Route implements the sdk.Msg interface

func (MsgCloseDeployment) Type added in v0.6.5

func (msg MsgCloseDeployment) Type() string

Type implements the sdk.Msg interface

func (MsgCloseDeployment) ValidateBasic added in v0.6.5

func (msg MsgCloseDeployment) ValidateBasic() error

ValidateBasic does basic validation with deployment details

type MsgCloseGroup added in v0.7.5

type MsgCloseGroup struct {
	ID GroupID
}

MsgCloseGroup defines SDK message to close a single Group within a Deployment.

func (MsgCloseGroup) GetSignBytes added in v0.7.5

func (msg MsgCloseGroup) GetSignBytes() []byte

GetSignBytes encodes the message for signing

func (MsgCloseGroup) GetSigners added in v0.7.5

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

GetSigners defines whose signature is required

func (MsgCloseGroup) Route added in v0.7.5

func (msg MsgCloseGroup) Route() string

Route implements the sdk.Msg interface for routing

func (MsgCloseGroup) Type added in v0.7.5

func (msg MsgCloseGroup) Type() string

Type implements the sdk.Msg interface exposing message type

func (MsgCloseGroup) ValidateBasic added in v0.7.5

func (msg MsgCloseGroup) ValidateBasic() error

ValidateBasic calls underlying GroupID.Validate() check and returns result

type MsgCreateDeployment added in v0.6.5

type MsgCreateDeployment struct {
	ID      DeploymentID `json:"id"`
	Groups  []GroupSpec  `json:"groups"`
	Version []byte       `json:"version"`
}

MsgCreateDeployment defines an SDK message for creating deployment

func (MsgCreateDeployment) GetSignBytes added in v0.6.5

func (msg MsgCreateDeployment) GetSignBytes() []byte

GetSignBytes encodes the message for signing

func (MsgCreateDeployment) GetSigners added in v0.6.5

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

GetSigners defines whose signature is required

func (MsgCreateDeployment) Route added in v0.6.5

func (msg MsgCreateDeployment) Route() string

Route implements the sdk.Msg interface

func (MsgCreateDeployment) Type added in v0.6.5

func (msg MsgCreateDeployment) Type() string

Type implements the sdk.Msg interface

func (MsgCreateDeployment) ValidateBasic added in v0.6.5

func (msg MsgCreateDeployment) ValidateBasic() error

ValidateBasic does basic validation like check owner and groups length

type MsgUpdateDeployment added in v0.6.5

type MsgUpdateDeployment struct {
	ID      DeploymentID
	Groups  []GroupSpec
	Version []byte
}

MsgUpdateDeployment defines an SDK message for updating deployment

func (MsgUpdateDeployment) GetSignBytes added in v0.6.5

func (msg MsgUpdateDeployment) GetSignBytes() []byte

GetSignBytes encodes the message for signing

func (MsgUpdateDeployment) GetSigners added in v0.6.5

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

GetSigners defines whose signature is required

func (MsgUpdateDeployment) Route added in v0.6.5

func (msg MsgUpdateDeployment) Route() string

Route implements the sdk.Msg interface

func (MsgUpdateDeployment) Type added in v0.6.5

func (msg MsgUpdateDeployment) Type() string

Type implements the sdk.Msg interface

func (MsgUpdateDeployment) ValidateBasic added in v0.6.5

func (msg MsgUpdateDeployment) 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

FullPrice method returns full price of resource

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