Skip to content

Commit

Permalink
updated top_accounts query height
Browse files Browse the repository at this point in the history
  • Loading branch information
MonikaCat committed Mar 14, 2024
1 parent 93511a1 commit 6f9af04
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion cmd/parse/top_accounts/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,15 @@ func allCmd(parseConfig *parsecmdtypes.Config) *cobra.Command {
waitGroup.Add(1)

// Query the latest chain height
height, err := parseCtx.Node.LatestHeight()
latestHeight, err := parseCtx.Node.LatestHeight()
if err != nil {
return fmt.Errorf("error while getting chain latest block height: %s", err)
}

// Set the height 5 blocks lower to avoid error
// codespace sdk code 26: invalid height: cannot query with height in the future
height := latestHeight - 5

// Store all addresses in database
accounts, err := authModule.RefreshTopAccountsList(height)
if err != nil {
Expand Down
6 changes: 5 additions & 1 deletion modules/top_accounts/utils_refresh_all.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ import "fmt"

func (m *Module) RefreshAll(address string) error {
// Query the latest chain height
height, err := m.node.LatestHeight()
latestHeight, err := m.node.LatestHeight()
if err != nil {
return fmt.Errorf("error while getting chain latest block height: %s", err)
}

// Set the height 5 blocks lower to avoid error
// codespace sdk code 26: invalid height: cannot query with height in the future
height := latestHeight - 5

err = m.bankModule.UpdateBalances([]string{address}, height)
if err != nil {
return fmt.Errorf("error while refreshing balance of account %s, error: %s", address, err)
Expand Down

0 comments on commit 6f9af04

Please sign in to comment.