Skip to content

Commit

Permalink
updated migrator
Browse files Browse the repository at this point in the history
  • Loading branch information
MonikaCat committed Jan 22, 2024
1 parent ff70a09 commit f8c35e5
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions database/legacy/msgexec/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ func (db *Migrator) Migrate() error {
log.Info().Msg("** migrating transactions **")
log.Debug().Int("tx count", len(msgTypes)).Msg("processing total transactions")

for _, msgType := range msgTypes {
for i, msgType := range msgTypes {
log.Debug().Str("tx hash", msgType.TransactionHash).Msg("getting transaction....")
fmt.Printf("\n processing %d/%d transaction \n", i, len(msgTypes))

tx, err := db.getMsgExecTransactionsFromDatabase(msgType.TransactionHash)
if err != nil {
Expand All @@ -38,7 +39,8 @@ func (db *Migrator) Migrate() error {
var msgs sdk.ABCIMessageLogs
err = json.Unmarshal([]byte(tx.Logs), &msgs)
if err != nil {
return fmt.Errorf("error while unmarshaling tx logs: %s", err)
skipped++
continue
}

var addresses []string
Expand All @@ -48,9 +50,7 @@ func (db *Migrator) Migrate() error {
for _, attribute := range event.Attributes {
if strings.HasPrefix(attribute.Value, "quick1") || strings.HasPrefix(attribute.Value, "quickvaloper") {
addresses = append(addresses, attribute.Value)

}

}
}
}
Expand All @@ -67,7 +67,9 @@ func (db *Migrator) Migrate() error {
msgType.Height), msgType.PartitionID)

if err != nil {
return fmt.Errorf("error while storing updated message: %s", err)
fmt.Printf("error while storing updated message: %s", err)
skipped++
continue
}
} else {
skipped++
Expand All @@ -85,7 +87,7 @@ func (db *Migrator) Migrate() error {
func (db *Migrator) getAllMsgExecStoredInDatabase() ([]dbtypes.MessageRow, error) {
const msgType = "cosmos.authz.v1beta1.MsgExec"
var rows []dbtypes.MessageRow
err := db.SQL.Select(&rows, `SELECT * FROM message WHERE type = $1`, msgType)
err := db.SQL.Select(&rows, `SELECT * FROM message WHERE type = $1 ORDER BY height ASC`, msgType)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit f8c35e5

Please sign in to comment.