Skip to content

Commit

Permalink
get node sync info and check for catching up
Browse files Browse the repository at this point in the history
  • Loading branch information
likhita-809 committed Mar 24, 2022
1 parent 418a335 commit 46f2b2d
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions x/auth/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
clientrpc "github.com/cosmos/cosmos-sdk/client/rpc"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/query"
Expand Down Expand Up @@ -101,11 +100,17 @@ func GetAccountCmd() *cobra.Command {
queryClient := types.NewQueryClient(clientCtx)
res, err := queryClient.Account(cmd.Context(), &types.QueryAccountRequest{Address: key.String()})
if err != nil {
height, err2 := clientrpc.GetChainHeight(clientCtx)
if err2 != nil {
return err2
node, err := clientCtx.GetNode()
if err != nil {
return err
}
if height != 0 {
status, err := node.Status(context.Background())
if err != nil {
return err
}
catchingUp := status.SyncInfo.CatchingUp

if !catchingUp {
return errors.Wrapf(err, "your node may be syncing, please check node status using `/status`")
}
return err
Expand Down

1 comment on commit 46f2b2d

@tac0turtle
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this approach looks good to me

Please sign in to comment.