Skip to content

Commit fa59b26

Browse files
authored
Merge pull request #8 from initia-labs/fix/block-events-mode
Fix unmarshalling event mode in finalize block events
2 parents 029db8d + cbdb96d commit fa59b26

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

informative-indexer/db/finalize_block_event.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,25 @@ type FinalizeBlockEvent struct {
4343
}
4444

4545
func (f *FinalizeBlockEvent) Unmarshal(rows pgx.Rows) (map[string]interface{}, error) {
46-
err := rows.Scan(&f.BlockHeight, &f.EventKey, &f.EventValue, &f.EventIndex, &f.Mode)
46+
var modeStr string
47+
48+
err := rows.Scan(&f.BlockHeight, &f.EventKey, &f.EventValue, &f.EventIndex, &modeStr)
4749
if err != nil {
4850
return nil, err
4951
}
5052

53+
mode, parseErr := ParseMode(modeStr)
54+
if parseErr != nil {
55+
return nil, parseErr
56+
}
57+
f.Mode = mode
58+
5159
row := map[string]interface{}{
5260
"block_height": f.BlockHeight,
5361
"event_key": f.EventKey,
5462
"event_value": f.EventValue,
5563
"event_index": f.EventIndex,
56-
"mode": f.Mode,
64+
"mode": f.Mode.String(),
5765
}
5866

5967
return row, nil

informative-indexer/prunner/prunner.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func (p *Prunner) pruningTable(ctx context.Context, tableName string) error {
9797

9898
height, err := db.GetLatestBlockHeight(ctx, p.dbClient)
9999
if err != nil {
100-
return fmt.Errorf("DB: failedto get latest block height: %w", err)
100+
return fmt.Errorf("DB: failed to get latest block height: %w", err)
101101
}
102102

103103
pruningThreshold := height - p.config.PruningKeepBlock

informative-indexer/run.sh

+23
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,29 @@ task__flush() {
5858
--id 1
5959
}
6060

61+
help__prune="prune <..args> : run prune"
62+
task__prune() {
63+
local chain=$1
64+
65+
if [ -z "$chain" ]; then
66+
echo "usage: $0 flush <chain>"
67+
exit
68+
fi
69+
70+
go build -o informative-indexer.bin .
71+
72+
source .env
73+
74+
./informative-indexer.bin prune --db $DB_CONNECTION_STRING \
75+
--backup-bucket-name ${chain}-local-core-informative-data-backup \
76+
--backup-file-prefix events \
77+
--pruning-keep-block 10 \
78+
--pruning-block-interval 10 \
79+
--pruning-interval 1 \
80+
--chain $chain \
81+
--environment local
82+
}
83+
6184
list_all_helps() {
6285
compgen -v | egrep "^help__.*"
6386
}

0 commit comments

Comments
 (0)