Skip to content

Commit

Permalink
fix: query error in syncer
Browse files Browse the repository at this point in the history
  • Loading branch information
frrist committed Aug 25, 2020
1 parent 82e5fac commit d1e488e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/lotus-chainwatch/processor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ where rnk <= $1
}
out := map[cid.Cid]*types.BlockHeader{}

minBlock := abi.ChainEpoch(math.MaxInt64)
minBlock := abi.ChainEpoch(math.MaxInt64 - 1)
maxBlock := abi.ChainEpoch(0)
// TODO consider parallel execution here for getting the blocks from the api as is done in fetchMessages()
for rows.Next() {
Expand Down
3 changes: 1 addition & 2 deletions cmd/lotus-chainwatch/syncer/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,7 @@ func (s *Syncer) unsyncedBlocks(ctx context.Context, head *types.TipSet, since u
}

func (s *Syncer) syncedBlocks(since, limit uint64) (map[cid.Cid]struct{}, error) {
// timestamp is used to return a configurable amount of rows based on when they were last added.
rws, err := s.db.Query(`select bs.cid FROM blocks_synced bs left join blocks b on b.cid = bs.cid where b.height <= $1 limit $2`, since, limit)
rws, err := s.db.Query(`select bs.cid FROM blocks_synced bs left join blocks b on b.cid = bs.cid where b.height <= $1 and bs.processed_at is not null limit $2`, since, limit)
if err != nil {
return nil, xerrors.Errorf("Failed to query blocks_synced: %w", err)
}
Expand Down

0 comments on commit d1e488e

Please sign in to comment.