Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
Fixed block headers_model for new QueryParams
Browse files Browse the repository at this point in the history
  • Loading branch information
icellan committed Apr 21, 2022
1 parent 163b9e1 commit f833592
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions model_blockheaders.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,10 @@ func GetUnsyncedBlockHeaders(ctx context.Context, opts ...ModelOps) ([]*BlockHea
"synced": nil,
}

pageSize := 0
page := 0

// Get the records
if err := getModels(
ctx, NewBaseModel(ModelBlockHeader, opts...).Client().Datastore(),
&models, conditions, pageSize, page, "", "", defaultDatabaseReadTimeout,
&models, conditions, nil, defaultDatabaseReadTimeout,
); err != nil {
if errors.Is(err, datastore.ErrNoResults) {
return nil, nil
Expand All @@ -100,10 +97,17 @@ func GetLastBlockHeader(ctx context.Context, opts ...ModelOps) (*BlockHeader, er
// Construct an empty model
var model []BlockHeader

queryParams := &datastore.QueryParams{
Page: 1,
PageSize: 1,
OrderByField: "height",
SortDirection: "desc",
}

// Get the records
if err := getModels(
ctx, NewBaseModel(ModelBlockHeader, opts...).Client().Datastore(),
&model, nil, 1, 1, "height", "desc", defaultDatabaseReadTimeout,
&model, nil, queryParams, defaultDatabaseReadTimeout,
); err != nil {
if errors.Is(err, datastore.ErrNoResults) {
return nil, nil
Expand Down

0 comments on commit f833592

Please sign in to comment.