Skip to content

Commit

Permalink
wait sync
Browse files Browse the repository at this point in the history
  • Loading branch information
renaynay committed Aug 1, 2022
1 parent bf3d38c commit d4ac4c7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions service/state/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package state

import (
"context"
"fmt"

"github.com/celestiaorg/celestia-node/header"
"github.com/celestiaorg/celestia-node/header/sync"
"github.com/celestiaorg/nmt/namespace"
Expand Down Expand Up @@ -40,15 +38,17 @@ func (s *Service) SubmitPayForData(
}

func (s *Service) Balance(ctx context.Context) (*Balance, error) {
if !s.sync.Finished() {
return nil, fmt.Errorf("node is not synced up to network head yet, balances will not be current")
err := s.sync.WaitSync(ctx)
if err != nil {
return nil, err
}
return s.accessor.Balance(ctx)
}

func (s *Service) BalanceForAddress(ctx context.Context, addr Address) (*Balance, error) {
if !s.sync.Finished() {
return nil, fmt.Errorf("node is not synced up to network head yet, balances will not be current")
err := s.sync.WaitSync(ctx)
if err != nil {
return nil, err
}
return s.accessor.BalanceForAddress(ctx, addr)
}
Expand Down

0 comments on commit d4ac4c7

Please sign in to comment.