Skip to content

Commit b5a979b

Browse files
authoredMar 20, 2025
fix bugs (cosmostation#65)
1 parent f5b4a26 commit b5a979b

File tree

5 files changed

+21
-13
lines changed

5 files changed

+21
-13
lines changed
 

‎internal/common/indexer/repository/vigilante_info.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (repo *MetaRepository) InsertVigilanteInfoList(VigilanteInfoList []model.Vi
6868
ExcludeColumn("id").
6969
Exec(ctx)
7070
if err != nil {
71-
return errors.Wrapf(err, "failed to insert validator info list")
71+
return err
7272
}
7373

7474
return nil

‎internal/packages/babylon/btc-lightclient/indexer/sync.go

+10-4
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func (idx *BTCLightClientIndexer) batchSync(lastIndexPoint int64) (
102102

103103
// if there are new hex address in current block, collect their validator hex address to save in database
104104
isNewReporter := false
105-
newRepoterInfoList := make([]indexermodel.VigilanteInfo, 0)
105+
newReporterMap := make(map[string]indexermodel.VigilanteInfo, 0)
106106
for _, bie := range bieSummaryList {
107107
if bie.skip {
108108
continue
@@ -113,23 +113,29 @@ func (idx *BTCLightClientIndexer) batchSync(lastIndexPoint int64) (
113113
_, exist := idx.Vim[e.ReporterAddress]
114114
if !exist {
115115
idx.Debugf("the reporter %s address isn't in current validator info table, the address will be added into the meta table", e.ReporterAddress)
116-
newRepoterInfoList = append(newRepoterInfoList, indexermodel.VigilanteInfo{
116+
117+
newReporterMap[e.ReporterAddress] = indexermodel.VigilanteInfo{
117118
ChainInfoID: idx.ChainInfoID,
118119
OperatorAddress: e.ReporterAddress,
119120
Moniker: "Babylon Vigilante Repoter",
120-
})
121+
}
121122
isNewReporter = true
122123
}
123124
}
124125
}
125126

126127
// this logic will be progressed only when there are new tendermint validators in this block
127128
if isNewReporter {
128-
idx.Debugf("insert new vigilante reporters: %d", len(newRepoterInfoList))
129+
idx.Debugf("insert new vigilante reporters: %d", len(newReporterMap))
130+
newRepoterInfoList := make([]indexermodel.VigilanteInfo, 0)
131+
for _, v := range newReporterMap {
132+
newRepoterInfoList = append(newRepoterInfoList, v)
133+
}
129134
err := idx.InsertVigilanteInfoList(newRepoterInfoList)
130135
if err != nil {
131136
// NOTE: fetch again validator_info list, actually already inserted the list by other indexer service
132137
idx.FetchValidatorInfoList()
138+
idx.Errorf("new reporter list: %v", newRepoterInfoList)
133139
return lastIndexPoint, errors.Wrap(err, "failed to insert new reporter list")
134140
}
135141

‎internal/packages/babylon/covenant-committee/indexer/batch_sync.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package indexer
22

33
import (
4-
"fmt"
54
"time"
65

76
"sync"
@@ -212,7 +211,7 @@ func (idx *CovenantSignatureIndexer) batchSync(lastIndexPointerHeight, newIndexP
212211

213212
// exit loop
214213
if closedCh1 && closedCh2 {
215-
fmt.Println("All channels closed. Exiting loop.")
214+
idx.Debugln("All channels closed. Exiting loop.")
216215
break
217216
}
218217
}

‎internal/packages/block-data-analytics/indexer/sync.go

+1
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ func (idx *BDAIndexer) batchSync(lastIndexPoint int64) (
206206

207207
newIndexPointer := summaryList[endHeight].BlockHeight
208208
newIndexPointerTime := summaryList[endHeight].Timestamp
209+
209210
err := idx.InsertBlockDataList(idx.ChainInfoID, newIndexPointer, modelList1, modelList2)
210211
if err != nil {
211212
return lastIndexPoint, errors.Wrapf(err, "failed to insert from %d to %d height", startHeight, endHeight)

‎internal/packages/block-data-analytics/repository/repository.go

+8-6
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,14 @@ func (repo *BDAIndexerRepository) InsertBlockDataList(
6565
return errors.Wrapf(err, "failed to insert data")
6666
}
6767

68-
_, err = tx.NewInsert().
69-
Model(&blockMessageList).
70-
ExcludeColumn("id").
71-
Exec(ctx)
72-
if err != nil {
73-
return errors.Wrapf(err, "failed to insert data")
68+
if len(blockMessageList) > 0 {
69+
_, err = tx.NewInsert().
70+
Model(&blockMessageList).
71+
ExcludeColumn("id").
72+
Exec(ctx)
73+
if err != nil {
74+
return errors.Wrapf(err, "failed to insert data")
75+
}
7476
}
7577

7678
_, err = tx.

0 commit comments

Comments
 (0)
Please sign in to comment.