@@ -19,15 +19,15 @@ import (
19
19
"github.com/bandprotocol/chain/v2/x/feeds/types"
20
20
)
21
21
22
- func StartSubmitPrices (c * grogucontext.Context , l * grogucontext. Logger ) {
22
+ func StartSubmitPrices (c * grogucontext.Context ) {
23
23
for {
24
24
// Return key and update pending metric when done with SubmitReport whether successfully or not.
25
25
keyIndex := <- c .FreeKeys
26
- go SubmitPrices (c , l , keyIndex )
26
+ go SubmitPrices (c , keyIndex )
27
27
}
28
28
}
29
29
30
- func SubmitPrices (c * grogucontext.Context , l * grogucontext. Logger , keyIndex int64 ) {
30
+ func SubmitPrices (c * grogucontext.Context , keyIndex int64 ) {
31
31
// Return key and update pending metric when done with SubmitReport whether successfully or not.
32
32
defer func () {
33
33
c .FreeKeys <- keyIndex
@@ -70,19 +70,19 @@ GetAllPrices:
70
70
71
71
for sendAttempt := uint64 (1 ); sendAttempt <= c .MaxTry ; sendAttempt ++ {
72
72
var txHash string
73
- l .Info (":e-mail: Sending report transaction attempt: (%d/%d)" , sendAttempt , c .MaxTry )
73
+ c . Logger .Info (":e-mail: Sending report transaction attempt: (%d/%d)" , sendAttempt , c .MaxTry )
74
74
for broadcastTry := uint64 (1 ); broadcastTry <= c .MaxTry ; broadcastTry ++ {
75
- l .Info (":writing_hand: Try to sign and broadcast report transaction(%d/%d)" , broadcastTry , c .MaxTry )
75
+ c . Logger .Info (":writing_hand: Try to sign and broadcast report transaction(%d/%d)" , broadcastTry , c .MaxTry )
76
76
res , err := signAndBroadcast (c , key , msgs , gasAdjustment )
77
77
if err != nil {
78
78
// Use info level because this error can happen and retry process can solve this error.
79
- l .Info (":warning: %s" , err .Error ())
79
+ c . Logger .Info (":warning: %s" , err .Error ())
80
80
time .Sleep (c .RPCPollInterval )
81
81
continue
82
82
}
83
83
if res .Codespace == sdkerrors .RootCodespace && res .Code == sdkerrors .ErrOutOfGas .ABCICode () {
84
84
gasAdjustment += 0.1
85
- l .Info (
85
+ c . Logger .Info (
86
86
":fuel_pump: Tx(%s) is out of gas and will be rebroadcasted with gas adjustment(%f)" ,
87
87
txHash ,
88
88
gasAdjustment ,
@@ -94,7 +94,7 @@ GetAllPrices:
94
94
break
95
95
}
96
96
if txHash == "" {
97
- l . Error (":exploding_head: Cannot try to broadcast more than %d try" , c , c .MaxTry )
97
+ c . Logger . Error (":exploding_head: Cannot try to broadcast more than %d try" , c .MaxTry )
98
98
return
99
99
}
100
100
txFound := false
@@ -103,36 +103,35 @@ GetAllPrices:
103
103
time .Sleep (c .RPCPollInterval )
104
104
txRes , err := authtx .QueryTx (clientCtx , txHash )
105
105
if err != nil {
106
- l .Debug (":warning: Failed to query tx with error: %s" , err .Error ())
106
+ c . Logger .Debug (":warning: Failed to query tx with error: %s" , err .Error ())
107
107
continue
108
108
}
109
109
110
110
if txRes .Code == 0 {
111
- l .Info (":smiling_face_with_sunglasses: Successfully broadcast tx with hash: %s" , txHash )
111
+ c . Logger .Info (":smiling_face_with_sunglasses: Successfully broadcast tx with hash: %s" , txHash )
112
112
return
113
113
}
114
114
if txRes .Codespace == sdkerrors .RootCodespace &&
115
115
txRes .Code == sdkerrors .ErrOutOfGas .ABCICode () {
116
116
// Increase gas adjustment and try to broadcast again
117
117
gasAdjustment += 0.1
118
- l .Info (":fuel_pump: Tx(%s) is out of gas and will be rebroadcasted with gas adjustment(%f)" , txHash , gasAdjustment )
118
+ c . Logger .Info (":fuel_pump: Tx(%s) is out of gas and will be rebroadcasted with gas adjustment(%f)" , txHash , gasAdjustment )
119
119
txFound = true
120
120
break FindTx
121
121
} else {
122
- l . Error (":exploding_head: Tx returned nonzero code %d with log %s, tx hash: %s" , c , txRes .Code , txRes .RawLog , txRes .TxHash )
122
+ c . Logger . Error (":exploding_head: Tx returned nonzero code %d with log %s, tx hash: %s" , txRes .Code , txRes .RawLog , txRes .TxHash )
123
123
return
124
124
}
125
125
}
126
126
if ! txFound {
127
- l .Error (
127
+ c . Logger .Error (
128
128
":question_mark: Cannot get transaction response from hash: %s transaction might be included in the next few blocks or check your node's health." ,
129
- c ,
130
129
txHash ,
131
130
)
132
131
return
133
132
}
134
133
}
135
- l . Error (":anxious_face_with_sweat: Cannot send price with adjusted gas: %d" , c , gasAdjustment )
134
+ c . Logger . Error (":anxious_face_with_sweat: Cannot send price with adjusted gas: %f" , gasAdjustment )
136
135
}
137
136
138
137
func signAndBroadcast (
0 commit comments