Skip to content

Commit

Permalink
Problem: fix reindex duplicated command fail when indexed tx is nil (c…
Browse files Browse the repository at this point in the history
…rypto-org-chain#548)

* reindex for unindexed tx

* share common result and output unindexed tx to stderr

* avoid execute next part if nil indexed is found

* update else if suggestion

* Update cmd/cronosd/cmd/reindex-duplicated-tx.go

Co-authored-by: yihuang <[email protected]>
  • Loading branch information
allthatjazzleo and yihuang authored Jun 10, 2022
1 parent 32645d3 commit cdfe53c
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions cmd/cronosd/cmd/reindex-duplicated-tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,33 @@ func ReindexDuplicatedTx() *cobra.Command {
if err != nil {
return err
}
if txResult.Code == 0 && txResult.Code != indexed.Result.Code {
if printTxs {
fmt.Println(height, txIndex)
continue
}
// a success tx but indexed wrong, reindex the tx
result := &abci.TxResult{

// results
var result *abci.TxResult
if !printTxs {
result = &abci.TxResult{
Height: height,
Index: uint32(txIndex),
Tx: tx,
Result: *txResult,
}
}

if indexed == nil {
if printTxs {
fmt.Fprintf(os.Stderr, "%d, txhash: %X was not indexed\n", height, tx.Hash())
continue
}
// reindex the tx
if err := tmDB.txIndexer.Index(result); err != nil {
return err
}
} else if txResult.Code == 0 && txResult.Code != indexed.Result.Code {
if printTxs {
fmt.Println(height, txIndex)
continue
}
// a success tx but indexed wrong, reindex the tx
if err := tmDB.txIndexer.Index(result); err != nil {
return err
}
Expand Down

0 comments on commit cdfe53c

Please sign in to comment.