parent
f25f798443
commit
e57473e2d2
|
@ -28,7 +28,6 @@ message MsgNewAuction {
|
||||||
// verified providers just specifies who's allowed to bid on the lease auction.
|
// verified providers just specifies who's allowed to bid on the lease auction.
|
||||||
// STORED IN MEMORY. DOES NOT GET WRITTEN TO CHAIN STATE.
|
// STORED IN MEMORY. DOES NOT GET WRITTEN TO CHAIN STATE.
|
||||||
repeated string verifiedProviders = 7;
|
repeated string verifiedProviders = 7;
|
||||||
|
|
||||||
// hardware specs (mandatory)
|
// hardware specs (mandatory)
|
||||||
repeated string gpus = 8;
|
repeated string gpus = 8;
|
||||||
uint64 cpuCores = 9;
|
uint64 cpuCores = 9;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package cli
|
package cli
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"colinear/x/colinearcore/types"
|
"colinear/x/colinearcore/types"
|
||||||
|
@ -15,12 +16,12 @@ var _ = strconv.Itoa(0)
|
||||||
|
|
||||||
func CmdNewAuction() *cobra.Command {
|
func CmdNewAuction() *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "new-auction [name] [description] [ceiling] [denom] [end date] [verified providers (separated by spaces)...]",
|
Use: "new-auction [name] [description] [ceiling] [denom] [end date] [verified providers (json string)] [gpus (json string)] [cpu cores] [cpu arch] [memory (MB)] [storage (GB)]",
|
||||||
Short: "Broadcast message newAuction",
|
Short: "Broadcast message newAuction",
|
||||||
// Args: cobra.ExactArgs(5),
|
Args: cobra.ExactArgs(10),
|
||||||
// below: we're hardcoding the max providers param since we
|
// below: we're hardcoding the max providers param since we
|
||||||
// can't check chain params locally
|
// can't check chain params locally
|
||||||
Args: cobra.RangeArgs(5, 1005),
|
// Args: cobra.RangeArgs(10, 1010),
|
||||||
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||||
argName := args[0]
|
argName := args[0]
|
||||||
argDescription := args[1]
|
argDescription := args[1]
|
||||||
|
@ -28,23 +29,57 @@ func CmdNewAuction() *cobra.Command {
|
||||||
argDenom := args[3]
|
argDenom := args[3]
|
||||||
argLeaseEnd := args[4]
|
argLeaseEnd := args[4]
|
||||||
|
|
||||||
|
vProvString := args[5]
|
||||||
|
gpusString := args[6]
|
||||||
|
cpuCores := args[7]
|
||||||
|
cpuArch := args[8]
|
||||||
|
memMb := args[9]
|
||||||
|
storageGb := args[10]
|
||||||
|
|
||||||
verifiedProviders := []string{}
|
verifiedProviders := []string{}
|
||||||
if len(args) >= 6 {
|
gpuModels := []string{}
|
||||||
// set to remaining arguments
|
|
||||||
verifiedProviders = args[5:]
|
|
||||||
}
|
|
||||||
|
|
||||||
clientCtx, err := client.GetClientTxContext(cmd)
|
clientCtx, err := client.GetClientTxContext(cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// try to marshal JSON lists
|
||||||
|
if err := json.Unmarshal([]byte(vProvString), &verifiedProviders); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := json.Unmarshal([]byte(gpusString), &gpuModels); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// try to parse int strings
|
||||||
|
|
||||||
var le int
|
var le int
|
||||||
le, err = strconv.Atoi(argLeaseEnd)
|
le, err = strconv.Atoi(argLeaseEnd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nCpuCores, err := strconv.Atoi(cpuCores)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
nCpuArch, err := strconv.Atoi(cpuArch)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
nMemMb, err := strconv.Atoi(memMb)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
nStorageGb, err := strconv.Atoi(storageGb)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
msg := types.NewMsgNewAuction(
|
msg := types.NewMsgNewAuction(
|
||||||
clientCtx.GetFromAddress().String(),
|
clientCtx.GetFromAddress().String(),
|
||||||
argName,
|
argName,
|
||||||
|
@ -53,6 +88,11 @@ func CmdNewAuction() *cobra.Command {
|
||||||
argDenom,
|
argDenom,
|
||||||
uint64(le),
|
uint64(le),
|
||||||
verifiedProviders,
|
verifiedProviders,
|
||||||
|
gpuModels,
|
||||||
|
uint64(nCpuCores),
|
||||||
|
types.CpuArchitecture(nCpuArch),
|
||||||
|
uint64(nMemMb),
|
||||||
|
uint64(nStorageGb),
|
||||||
)
|
)
|
||||||
if err := msg.ValidateBasic(); err != nil {
|
if err := msg.ValidateBasic(); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -9,15 +9,29 @@ const TypeMsgNewAuction = "new_auction"
|
||||||
|
|
||||||
var _ sdk.Msg = &MsgNewAuction{}
|
var _ sdk.Msg = &MsgNewAuction{}
|
||||||
|
|
||||||
func NewMsgNewAuction(creator string, name string, description string, ceiling string, denom string, leaseEnd uint64, vProviders []string) *MsgNewAuction {
|
func NewMsgNewAuction(
|
||||||
|
// auction params
|
||||||
|
creator string, name string, description string, ceiling string, denom string, leaseEnd uint64, vProviders []string,
|
||||||
|
// hardware specs
|
||||||
|
gpus []string, cpuCores uint64, cpuArch CpuArchitecture, memMb uint64, storageGb uint64,
|
||||||
|
) *MsgNewAuction {
|
||||||
return &MsgNewAuction{
|
return &MsgNewAuction{
|
||||||
Creator: creator,
|
Creator: creator,
|
||||||
|
|
||||||
|
// creation params
|
||||||
Name: name,
|
Name: name,
|
||||||
Description: description,
|
Description: description,
|
||||||
Ceiling: ceiling,
|
Ceiling: ceiling,
|
||||||
Denom: denom,
|
Denom: denom,
|
||||||
LeaseEnd: leaseEnd,
|
LeaseEnd: leaseEnd,
|
||||||
VerifiedProviders: vProviders,
|
VerifiedProviders: vProviders,
|
||||||
|
|
||||||
|
// hardware
|
||||||
|
Gpus: gpus,
|
||||||
|
CpuCores: cpuCores,
|
||||||
|
CpuArch: cpuArch,
|
||||||
|
MemMb: memMb,
|
||||||
|
StorageGb: storageGb,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue