list all claims at once (faster)

This commit is contained in:
Niko Storni 2019-10-15 00:29:26 +02:00
parent 77749f05ba
commit 6d2e4aa6e6

View file

@ -660,8 +660,6 @@ func (s *Sync) updateRemoteDB(claims []jsonrpc.Claim, ownClaims []jsonrpc.Claim)
} }
func (s *Sync) getClaims(defaultOnly bool) ([]jsonrpc.Claim, error) { func (s *Sync) getClaims(defaultOnly bool) ([]jsonrpc.Claim, error) {
totalPages := uint64(1)
var allClaims []jsonrpc.Claim
var account *string = nil var account *string = nil
if defaultOnly { if defaultOnly {
a, err := s.getDefaultAccount() a, err := s.getDefaultAccount()
@ -670,15 +668,12 @@ func (s *Sync) getClaims(defaultOnly bool) ([]jsonrpc.Claim, error) {
} }
account = &a account = &a
} }
for page := uint64(1); page <= totalPages; page++ { claims, err := s.daemon.StreamList(account)
claims, err := s.daemon.ClaimList(account, page, 50)
if err != nil { if err != nil {
return nil, errors.Prefix("cannot list claims", err) return nil, errors.Prefix("cannot list claims", err)
} }
allClaims = append(allClaims, (*claims).Claims...)
totalPages = (*claims).TotalPages return *claims, nil
}
return allClaims, nil
} }
func (s *Sync) checkIntegrity() error { func (s *Sync) checkIntegrity() error {