MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / runCreate

Function runCreate

cmd/cql/internal/create.go:99–204  ·  view source on GitHub ↗
(cmd *Command, args []string)

Source from the content-addressed store, hash-verified

97}
98
99func runCreate(cmd *Command, args []string) {
100 commonFlagsInit(cmd)
101
102 if len(args) > 1 {
103 ConsoleLog.Error("create params should set by specific param name like -node")
104 SetExitStatus(1)
105 printCommandHelp(cmd)
106 Exit()
107 }
108
109 for _, miner := range targetMiners.Values {
110 targetMiner, err := hash.NewHashFromStr(miner)
111 if err != nil {
112 ConsoleLog.Error("create target-miners param has invalid node address: ", miner)
113 SetExitStatus(1)
114 return
115 }
116 meta.TargetMiners = append(meta.TargetMiners, proto.AccountAddress(*targetMiner))
117 }
118
119 if node32 > math.MaxUint16 {
120 ConsoleLog.Error("create node param should not greater than uint16")
121 SetExitStatus(1)
122 return
123 }
124 meta.Node = uint16(node32)
125
126 if len(args) == 1 && args[0] != "" {
127 // fill the meta with params
128 if err := json.Unmarshal([]byte(args[0]), &meta); err != nil {
129 ConsoleLog.Error("create node json param is not valid")
130 SetExitStatus(1)
131 return
132 }
133
134 // 0.5.0 version forward compatibility
135 var tempMeta map[string]json.RawMessage
136 if err := json.Unmarshal([]byte(args[0]), &tempMeta); err == nil {
137 for k, v := range tempMeta {
138 switch strings.ToLower(k) {
139 case "targetminers":
140 _ = json.Unmarshal(v, &meta.TargetMiners)
141 case "loadavgpercpu":
142 _ = json.Unmarshal(v, &meta.LoadAvgPerCPU)
143 case "encryptionkey":
144 _ = json.Unmarshal(v, &meta.EncryptionKey)
145 case "useeventualconsistency":
146 _ = json.Unmarshal(v, &meta.UseEventualConsistency)
147 case "consistencylevel":
148 _ = json.Unmarshal(v, &meta.ConsistencyLevel)
149 case "isolationlevel":
150 _ = json.Unmarshal(v, &meta.IsolationLevel)
151 case "gasprice":
152 _ = json.Unmarshal(v, &meta.GasPrice)
153 case "advancepayment":
154 _ = json.Unmarshal(v, &meta.AdvancePayment)
155 }
156 }

Callers

nothing calls this directly

Calls 15

NewHashFromStrFunction · 0.92
AccountAddressTypeAlias · 0.92
CreateFunction · 0.92
WaitDBCreationFunction · 0.92
commonFlagsInitFunction · 0.85
SetExitStatusFunction · 0.85
printCommandHelpFunction · 0.85
ExitFunction · 0.85
configInitFunction · 0.85
waitFunction · 0.85
storeOneDSNFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected