Skip to content

Commit 3eeb556

Browse files
committed
reset return tx if failed
1 parent 74b72cf commit 3eeb556

File tree

1 file changed

+40
-12
lines changed

1 file changed

+40
-12
lines changed

pokt/executor.go

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func (x *BurnExecutorRunner) HandleInvalidMint(doc models.InvalidMint) bool {
6464
}
6565
} else if doc.Status == models.StatusSubmitted {
6666
log.Debug("[BURN EXECUTOR] Checking invalid mint")
67-
_, err := x.client.GetTx(doc.ReturnTxHash)
67+
tx, err := x.client.GetTx(doc.ReturnTxHash)
6868
if err != nil {
6969
log.Error("[BURN EXECUTOR] Error fetching transaction: ", err)
7070
return false
@@ -75,11 +75,25 @@ func (x *BurnExecutorRunner) HandleInvalidMint(doc models.InvalidMint) bool {
7575
"status": models.StatusSubmitted,
7676
}
7777

78-
update = bson.M{
79-
"$set": bson.M{
80-
"status": models.StatusSuccess,
81-
"updated_at": time.Now(),
82-
},
78+
if tx.TxResult.Code != 0 {
79+
log.Error("[BURN EXECUTOR] Invalid mint return tx failed: ", tx.Hash)
80+
update = bson.M{
81+
"$set": bson.M{
82+
"status": models.StatusConfirmed,
83+
"updated_at": time.Now(),
84+
"return_tx_hash": "",
85+
"return_tx": "",
86+
"signers": []string{},
87+
},
88+
}
89+
} else {
90+
log.Debug("[BURN EXECUTOR] Invalid mint return tx succeeded: ", tx.Hash)
91+
update = bson.M{
92+
"$set": bson.M{
93+
"status": models.StatusSuccess,
94+
"updated_at": time.Now(),
95+
},
96+
}
8397
}
8498
}
8599

@@ -126,7 +140,7 @@ func (x *BurnExecutorRunner) HandleBurn(doc models.Burn) bool {
126140
}
127141
} else if doc.Status == models.StatusSubmitted {
128142
log.Debug("[BURN EXECUTOR] Checking burn")
129-
_, err := x.client.GetTx(doc.ReturnTxHash)
143+
tx, err := x.client.GetTx(doc.ReturnTxHash)
130144
if err != nil {
131145
log.Error("[BURN EXECUTOR] Error fetching transaction: ", err)
132146
return false
@@ -137,11 +151,25 @@ func (x *BurnExecutorRunner) HandleBurn(doc models.Burn) bool {
137151
"status": models.StatusSubmitted,
138152
}
139153

140-
update = bson.M{
141-
"$set": bson.M{
142-
"status": models.StatusSuccess,
143-
"updated_at": time.Now(),
144-
},
154+
if tx.TxResult.Code != 0 {
155+
log.Error("[BURN EXECUTOR] Burn return tx failed: ", tx.Hash)
156+
update = bson.M{
157+
"$set": bson.M{
158+
"status": models.StatusConfirmed,
159+
"updated_at": time.Now(),
160+
"return_tx_hash": "",
161+
"return_tx": "",
162+
"signers": []string{},
163+
},
164+
}
165+
} else {
166+
log.Debug("[BURN EXECUTOR] Burn return tx succeeded: ", tx.Hash)
167+
update = bson.M{
168+
"$set": bson.M{
169+
"status": models.StatusSuccess,
170+
"updated_at": time.Now(),
171+
},
172+
}
145173
}
146174
}
147175

0 commit comments

Comments
 (0)