ovrclk / akash

@@ -58,7 +58,7 @@
Loading
58 58
				return err
59 59
			}
60 60
61 -
			return sdkutil.BroadcastTX(clientCtx, cmd.Flags(), msg)
61 +
			return sdkutil.BroadcastTX(cmd.Context(), clientCtx, cmd.Flags(), msg)
62 62
		},
63 63
	}
64 64
@@ -95,7 +95,7 @@
Loading
95 95
				return err
96 96
			}
97 97
98 -
			return sdkutil.BroadcastTX(clientCtx, cmd.Flags(), msg)
98 +
			return sdkutil.BroadcastTX(cmd.Context(), clientCtx, cmd.Flags(), msg)
99 99
		},
100 100
	}
101 101

@@ -26,7 +26,6 @@
Loading
26 26
	genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
27 27
	"github.com/pkg/errors"
28 28
	"github.com/spf13/cobra"
29 -
	"github.com/spf13/pflag"
30 29
31 30
	"github.com/ovrclk/akash/sdkutil"
32 31
	types "github.com/ovrclk/akash/x/cert/types/v1beta2"
@@ -106,7 +105,7 @@
Loading
106 105
				serial = cert.SerialNumber.String()
107 106
			}
108 107
109 -
			return doRevoke(cctx, cmd.Flags(), serial)
108 +
			return doRevoke(cmd, cctx, serial)
110 109
		},
111 110
	}
112 111
@@ -157,7 +156,7 @@
Loading
157 156
	}
158 157
159 158
	if !toGenesis {
160 -
		return sdkutil.BroadcastTX(cctx, cmd.Flags(), msg)
159 +
		return sdkutil.BroadcastTX(cmd.Context(), cctx, cmd.Flags(), msg)
161 160
	}
162 161
163 162
	return addCertToGenesis(cmd, types.GenesisCertificate{
@@ -257,12 +256,12 @@
Loading
257 256
						return err
258 257
					}
259 258
260 -
					return sdkutil.BroadcastTX(cctx, cmd.Flags(), msg)
259 +
					return sdkutil.BroadcastTX(cmd.Context(), cctx, cmd.Flags(), msg)
261 260
				}
262 261
			}
263 262
		} else {
264 263
			if res.Certificates[0].Certificate.IsState(types.CertificateValid) {
265 -
				err = doRevoke(cctx, cmd.Flags(), x509cert.SerialNumber.String())
264 +
				err = doRevoke(cmd, cctx, x509cert.SerialNumber.String())
266 265
				if err == nil {
267 266
					removeFile = true
268 267
				}
@@ -508,7 +507,7 @@
Loading
508 507
	return msg, nil
509 508
}
510 509
511 -
func doRevoke(cctx sdkclient.Context, flags *pflag.FlagSet, serial string) error {
510 +
func doRevoke(cmd *cobra.Command, cctx sdkclient.Context, serial string) error {
512 511
	msg := &types.MsgRevokeCertificate{
513 512
		ID: types.CertificateID{
514 513
			Owner:  cctx.FromAddress.String(),
@@ -516,7 +515,7 @@
Loading
516 515
		},
517 516
	}
518 517
519 -
	return sdkutil.BroadcastTX(cctx, flags, msg)
518 +
	return sdkutil.BroadcastTX(cmd.Context(), cctx, cmd.Flags(), msg)
520 519
}
521 520
522 521
func getConfirmation(cmd *cobra.Command, prompt string) (bool, error) {

@@ -85,7 +85,7 @@
Loading
85 85
				return err
86 86
			}
87 87
88 -
			return sdkutil.BroadcastTX(clientCtx, cmd.Flags(), msg)
88 +
			return sdkutil.BroadcastTX(cmd.Context(), clientCtx, cmd.Flags(), msg)
89 89
		},
90 90
	}
91 91
@@ -125,7 +125,7 @@
Loading
125 125
				return err
126 126
			}
127 127
128 -
			return sdkutil.BroadcastTX(clientCtx, cmd.Flags(), msg)
128 +
			return sdkutil.BroadcastTX(cmd.Context(), clientCtx, cmd.Flags(), msg)
129 129
		},
130 130
	}
131 131

@@ -3,6 +3,7 @@
Loading
3 3
import (
4 4
	"bufio"
5 5
	"context"
6 +
	"encoding/hex"
6 7
	"fmt"
7 8
	"os"
8 9
	"strings"
@@ -19,7 +20,7 @@
Loading
19 20
)
20 21
21 22
const (
22 -
	broadcastBlockRetryTimeout = 30 * time.Second
23 +
	BroadcastBlockRetryTimeout = 300 * time.Second
23 24
	broadcastBlockRetryPeriod  = time.Second
24 25
25 26
	// sadface.
@@ -33,23 +34,22 @@
Loading
33 34
	notFoundErrorMessageSuffix = ") not found"
34 35
)
35 36
36 -
func BroadcastTX(ctx client.Context, flags *pflag.FlagSet, msgs ...sdk.Msg) error {
37 -
37 +
func BroadcastTX(ctx context.Context, cctx client.Context, flags *pflag.FlagSet, msgs ...sdk.Msg) error {
38 38
	// rewrite of https://github.com/cosmos/cosmos-sdk/blob/ca98fda6eae597b1e7d468f96d030b6d905748d7/client/tx/tx.go#L29
39 39
	// to add continuing retries if broadcast-mode=block fails with a timeout.
40 40
41 -
	txf := tx.NewFactoryCLI(ctx, flags)
41 +
	txf := tx.NewFactoryCLI(cctx, flags)
42 42
43 -
	txf, err := PrepareFactory(ctx, txf)
43 +
	txf, err := PrepareFactory(cctx, txf)
44 44
	if err != nil {
45 45
		return err
46 46
	}
47 47
48 -
	txf, err = adjustGas(ctx, txf, msgs...)
48 +
	txf, err = adjustGas(cctx, txf, msgs...)
49 49
	if err != nil {
50 50
		return err
51 51
	}
52 -
	if ctx.Simulate {
52 +
	if cctx.Simulate {
53 53
		return nil
54 54
	}
55 55
@@ -58,36 +58,36 @@
Loading
58 58
		return err
59 59
	}
60 60
61 -
	if ctx.GenerateOnly {
62 -
		json, err := ctx.TxConfig.TxJSONEncoder()(txb.GetTx())
61 +
	if cctx.GenerateOnly {
62 +
		json, err := cctx.TxConfig.TxJSONEncoder()(txb.GetTx())
63 63
		if err != nil {
64 64
			return err
65 65
		}
66 -
		return ctx.PrintString(fmt.Sprintf("%s\n", json))
66 +
		return cctx.PrintString(fmt.Sprintf("%s\n", json))
67 67
	}
68 68
69 -
	ok, err := confirmTx(ctx, txb)
69 +
	ok, err := confirmTx(cctx, txb)
70 70
	if !ok || err != nil {
71 71
		return err
72 72
	}
73 73
74 -
	txb.SetFeeGranter(ctx.GetFeeGranterAddress())
75 -
	err = tx.Sign(txf, ctx.GetFromName(), txb, true)
74 +
	txb.SetFeeGranter(cctx.GetFeeGranterAddress())
75 +
	err = tx.Sign(txf, cctx.GetFromName(), txb, true)
76 76
	if err != nil {
77 77
		return err
78 78
	}
79 79
80 -
	txBytes, err := ctx.TxConfig.TxEncoder()(txb.GetTx())
80 +
	txBytes, err := cctx.TxConfig.TxEncoder()(txb.GetTx())
81 81
	if err != nil {
82 82
		return err
83 83
	}
84 84
85 -
	res, err := doBroadcast(ctx, broadcastBlockRetryTimeout, txBytes)
85 +
	res, err := doBroadcast(ctx, cctx, BroadcastBlockRetryTimeout, txBytes)
86 86
	if err != nil {
87 87
		return err
88 88
	}
89 89
90 -
	return ctx.PrintProto(res)
90 +
	return cctx.PrintProto(res)
91 91
92 92
}
93 93
@@ -119,32 +119,30 @@
Loading
119 119
	return txf, nil
120 120
}
121 121
122 -
func doBroadcast(ctx client.Context, timeout time.Duration, txb ttypes.Tx) (*sdk.TxResponse, error) {
123 -
	switch ctx.BroadcastMode {
122 +
func doBroadcast(ctx context.Context, cctx client.Context, timeout time.Duration, txb ttypes.Tx) (*sdk.TxResponse, error) {
123 +
	switch cctx.BroadcastMode {
124 124
	case flags.BroadcastSync:
125 -
		return ctx.BroadcastTxSync(txb)
125 +
		return cctx.BroadcastTxSync(txb)
126 126
	case flags.BroadcastAsync:
127 -
		return ctx.BroadcastTxAsync(txb)
127 +
		return cctx.BroadcastTxAsync(txb)
128 128
	}
129 129
130 -
	// broadcast-mode=block
130 +
	hash := hex.EncodeToString(txb.Hash())
131 131
132 +
	// broadcast-mode=block
132 133
	// submit with mode commit/block
133 -
	cres, err := ctx.BroadcastTxCommit(txb)
134 -
135 -
	switch {
136 -
	case err == nil:
137 -
		// no error, return
138 -
		return cres, err
139 -
	case err.Error() != timeoutErrorMessage:
140 -
		// other error, return
134 +
	cres, err := cctx.BroadcastTxCommit(txb)
135 +
	if err == nil {
136 +
		// good job
137 +
		return cres, nil
138 +
	} else if !strings.HasSuffix(err.Error(), timeoutErrorMessage) {
141 139
		return cres, err
142 -
	default:
143 -
		// timeout error, continue on to retry
144 140
	}
145 141
142 +
	// timeout error, continue on to retry
143 +
146 144
	// loop
147 -
	lctx, cancel := context.WithTimeout(context.Background(), timeout)
145 +
	lctx, cancel := context.WithTimeout(ctx, timeout)
148 146
	defer cancel()
149 147
150 148
	for lctx.Err() == nil {
@@ -158,7 +156,7 @@
Loading
158 156
159 157
		// check transaction
160 158
		// https://github.com/cosmos/cosmos-sdk/pull/8734
161 -
		res, err := authtx.QueryTx(ctx, cres.TxHash)
159 +
		res, err := authtx.QueryTx(cctx, hash)
162 160
		if err == nil {
163 161
			return res, nil
164 162
		}

@@ -114,7 +114,7 @@
Loading
114 114
				return err
115 115
			}
116 116
117 -
			return sdkutil.BroadcastTX(clientCtx, cmd.Flags(), msg)
117 +
			return sdkutil.BroadcastTX(cmd.Context(), clientCtx, cmd.Flags(), msg)
118 118
		},
119 119
	}
120 120
@@ -158,7 +158,7 @@
Loading
158 158
				Depositor: depositorAcc,
159 159
			}
160 160
161 -
			return sdkutil.BroadcastTX(clientCtx, cmd.Flags(), msg)
161 +
			return sdkutil.BroadcastTX(cmd.Context(), clientCtx, cmd.Flags(), msg)
162 162
		},
163 163
	}
164 164
@@ -187,7 +187,7 @@
Loading
187 187
188 188
			msg := &types.MsgCloseDeployment{ID: id}
189 189
190 -
			return sdkutil.BroadcastTX(clientCtx, cmd.Flags(), msg)
190 +
			return sdkutil.BroadcastTX(cmd.Context(), clientCtx, cmd.Flags(), msg)
191 191
		},
192 192
	}
193 193
@@ -236,7 +236,7 @@
Loading
236 236
				msg.Groups = append(msg.Groups, *group)
237 237
			}
238 238
239 -
			return sdkutil.BroadcastTX(clientCtx, cmd.Flags(), msg)
239 +
			return sdkutil.BroadcastTX(cmd.Context(), clientCtx, cmd.Flags(), msg)
240 240
		},
241 241
	}
242 242
@@ -286,7 +286,7 @@
Loading
286 286
				return err
287 287
			}
288 288
289 -
			return sdkutil.BroadcastTX(clientCtx, cmd.Flags(), msg)
289 +
			return sdkutil.BroadcastTX(cmd.Context(), clientCtx, cmd.Flags(), msg)
290 290
		},
291 291
	}
292 292
@@ -322,7 +322,7 @@
Loading
322 322
				return err
323 323
			}
324 324
325 -
			return sdkutil.BroadcastTX(clientCtx, cmd.Flags(), msg)
325 +
			return sdkutil.BroadcastTX(cmd.Context(), clientCtx, cmd.Flags(), msg)
326 326
		},
327 327
	}
328 328
@@ -358,7 +358,7 @@
Loading
358 358
				return err
359 359
			}
360 360
361 -
			return sdkutil.BroadcastTX(clientCtx, cmd.Flags(), msg)
361 +
			return sdkutil.BroadcastTX(cmd.Context(), clientCtx, cmd.Flags(), msg)
362 362
		},
363 363
	}
364 364
@@ -429,7 +429,7 @@
Loading
429 429
				return err
430 430
			}
431 431
432 -
			return sdkutil.BroadcastTX(clientCtx, cmd.Flags(), msg)
432 +
			return sdkutil.BroadcastTX(cmd.Context(), clientCtx, cmd.Flags(), msg)
433 433
		},
434 434
	}
435 435
@@ -466,7 +466,7 @@
Loading
466 466
			msgTypeURL := types.DepositDeploymentAuthorization{}.MsgTypeURL()
467 467
			msg := authz.NewMsgRevoke(granter, grantee, msgTypeURL)
468 468
469 -
			return sdkutil.BroadcastTX(clientCtx, cmd.Flags(), &msg)
469 +
			return sdkutil.BroadcastTX(cmd.Context(), clientCtx, cmd.Flags(), &msg)
470 470
		},
471 471
	}
472 472

@@ -85,7 +85,7 @@
Loading
85 85
				return err
86 86
			}
87 87
88 -
			return sdkutil.BroadcastTX(clientCtx, cmd.Flags(), msg)
88 +
			return sdkutil.BroadcastTX(cmd.Context(), clientCtx, cmd.Flags(), msg)
89 89
		},
90 90
	}
91 91
@@ -121,7 +121,7 @@
Loading
121 121
				return err
122 122
			}
123 123
124 -
			return sdkutil.BroadcastTX(clientCtx, cmd.Flags(), msg)
124 +
			return sdkutil.BroadcastTX(cmd.Context(), clientCtx, cmd.Flags(), msg)
125 125
		},
126 126
	}
127 127
@@ -170,7 +170,7 @@
Loading
170 170
				return err
171 171
			}
172 172
173 -
			return sdkutil.BroadcastTX(clientCtx, cmd.Flags(), msg)
173 +
			return sdkutil.BroadcastTX(cmd.Context(), clientCtx, cmd.Flags(), msg)
174 174
		},
175 175
	}
176 176
@@ -205,7 +205,7 @@
Loading
205 205
				return err
206 206
			}
207 207
208 -
			return sdkutil.BroadcastTX(clientCtx, cmd.Flags(), msg)
208 +
			return sdkutil.BroadcastTX(cmd.Context(), clientCtx, cmd.Flags(), msg)
209 209
		},
210 210
	}
211 211
@@ -240,7 +240,7 @@
Loading
240 240
				return err
241 241
			}
242 242
243 -
			return sdkutil.BroadcastTX(clientCtx, cmd.Flags(), msg)
243 +
			return sdkutil.BroadcastTX(cmd.Context(), clientCtx, cmd.Flags(), msg)
244 244
		},
245 245
	}
246 246
Files Coverage
app 77.28%
client 2.84%
cmd 8.55%
deploy/cmd 0.00%
events 8.43%
manifest 80.95%
provider 33.49%
pubsub 89.18%
sdkutil 38.33%
sdl 70.27%
testutil 90.67%
types 28.34%
util 43.11%
x 37.73%
docgen/main.go 0.00%
integration/test_helpers.go 5.40%
validation/manifest.go 94.78%
Project Totals (357 files) 38.22%

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading