9
9
"time"
10
10
11
11
"github.com/0chain/blobber/code/go/0chain.net/blobbercore/config"
12
- "github.com/0chain/blobber/code/go/0chain.net/blobbercore/datastore"
13
12
"github.com/0chain/blobber/code/go/0chain.net/core/chain"
14
13
"github.com/0chain/blobber/code/go/0chain.net/core/common"
15
14
"github.com/0chain/blobber/code/go/0chain.net/core/node"
@@ -166,12 +165,7 @@ func validateOnValidators(ctx context.Context, c *ChallengeEntity) error {
166
165
return nil
167
166
}
168
167
169
- func (c * ChallengeEntity ) getCommitTransaction () (* transaction.Transaction , error ) {
170
- ctx := datastore .GetStore ().CreateTransaction (context .TODO ())
171
- defer ctx .Done ()
172
-
173
- tx := datastore .GetStore ().GetTransaction (ctx )
174
-
168
+ func (c * ChallengeEntity ) getCommitTransaction (ctx context.Context ) (* transaction.Transaction , error ) {
175
169
createdTime := common .ToTime (c .CreatedAt )
176
170
logging .Logger .Info ("[challenge]commit" ,
177
171
zap .Any ("challenge_id" , c .ChallengeID ),
@@ -180,24 +174,14 @@ func (c *ChallengeEntity) getCommitTransaction() (*transaction.Transaction, erro
180
174
181
175
if time .Since (common .ToTime (c .CreatedAt )) > config .StorageSCConfig .ChallengeCompletionTime {
182
176
c .CancelChallenge (ctx , ErrExpiredCCT )
183
- if err := tx .Commit ().Error ; err != nil {
184
- logging .Logger .Error ("[challenge]verify(Commit): " ,
185
- zap .Any ("challenge_id" , c .ChallengeID ),
186
- zap .Error (err ))
187
- }
188
- return nil , ErrExpiredCCT
177
+ return nil , nil
189
178
}
190
179
191
180
txn , err := transaction .NewTransactionEntity ()
192
181
if err != nil {
193
182
logging .Logger .Error ("[challenge]createTxn" , zap .Error (err ))
194
183
c .CancelChallenge (ctx , err )
195
- if err := tx .Commit ().Error ; err != nil {
196
- logging .Logger .Error ("[challenge]verify(Commit): " ,
197
- zap .Any ("challenge_id" , c .ChallengeID ),
198
- zap .Error (err ))
199
- }
200
- return nil , err
184
+ return nil , nil
201
185
}
202
186
203
187
sn := & ChallengeResponse {}
@@ -212,12 +196,7 @@ func (c *ChallengeEntity) getCommitTransaction() (*transaction.Transaction, erro
212
196
if err != nil {
213
197
logging .Logger .Info ("Failed submitting challenge to the mining network" , zap .String ("err:" , err .Error ()))
214
198
c .CancelChallenge (ctx , err )
215
- if err := tx .Commit ().Error ; err != nil {
216
- logging .Logger .Error ("[challenge]verify(Commit): " ,
217
- zap .Any ("challenge_id" , c .ChallengeID ),
218
- zap .Error (err ))
219
- }
220
- return nil , err
199
+ return nil , nil
221
200
}
222
201
223
202
err = UpdateChallengeTimingTxnSubmission (c .ChallengeID , txn .CreationDate )
@@ -229,11 +208,5 @@ func (c *ChallengeEntity) getCommitTransaction() (*transaction.Transaction, erro
229
208
zap .Error (err ))
230
209
}
231
210
232
- if err := tx .Commit ().Error ; err != nil {
233
- logging .Logger .Error ("[challenge]verify(Commit): " ,
234
- zap .Any ("challenge_id" , c .ChallengeID ),
235
- zap .Error (err ))
236
- }
237
-
238
211
return txn , nil
239
212
}
0 commit comments