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

Function showAllDatabaseDeposit

cmd/cql/internal/wallet.go:182–230  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

180}
181
182func showAllDatabaseDeposit() {
183 var (
184 req = new(types.QueryAccountSQLChainProfilesReq)
185 resp = new(types.QueryAccountSQLChainProfilesResp)
186 pubKey *asymmetric.PublicKey
187 err error
188 )
189
190 if pubKey, err = kms.GetLocalPublicKey(); err != nil {
191 ConsoleLog.WithError(err).Error("query database chain profile failed")
192 SetExitStatus(1)
193 return
194 }
195
196 if req.Addr, err = crypto.PubKeyHash(pubKey); err != nil {
197 ConsoleLog.WithError(err).Error("query database chain profile failed")
198 SetExitStatus(1)
199 return
200 }
201
202 if err = mux.RequestBP(route.MCCQueryAccountSQLChainProfiles.String(), req, resp); err != nil {
203 if strings.Contains(err.Error(), "can't find method") {
204 // old version block producer
205 ConsoleLog.WithError(err).Warning("query account database profiles is not supported in old version block producer")
206 return
207 }
208
209 ConsoleLog.WithError(err).Error("query account database profiles failed")
210 SetExitStatus(1)
211 return
212 }
213
214 if len(resp.Profiles) == 0 {
215 fmt.Println("found no related database")
216 return
217 }
218
219 fmt.Printf("Database Deposits:\n\n")
220 fmt.Printf("%-64s\tDeposit\tArrears\tAdvancePayment\n", "DatabaseID")
221
222 for _, p := range resp.Profiles {
223 for _, user := range p.Users {
224 if user.Address == req.Addr && user.Permission != nil && user.Permission.Role != types.Void {
225 fmt.Printf("%s\t%d\t%d\t%d\n",
226 p.ID, user.Deposit, user.Arrears, user.AdvancePayment)
227 }
228 }
229 }
230}
231
232func runWallet(cmd *Command, args []string) {
233 commonFlagsInit(cmd)

Callers 1

runWalletFunction · 0.85

Calls 11

GetLocalPublicKeyFunction · 0.92
PubKeyHashFunction · 0.92
RequestBPFunction · 0.92
SetExitStatusFunction · 0.85
ErrorMethod · 0.80
WithErrorMethod · 0.80
ContainsMethod · 0.80
WarningMethod · 0.80
PrintlnMethod · 0.80
StringMethod · 0.45
PrintfMethod · 0.45

Tested by

no test coverage detected