From f8335921f6677b6914374f2334adcd1f903bbc1d Mon Sep 17 00:00:00 2001 From: Siggi Date: Thu, 21 Apr 2022 14:54:18 +0200 Subject: [PATCH] Fixed block headers_model for new QueryParams --- model_blockheaders.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/model_blockheaders.go b/model_blockheaders.go index aca6a87e..c1adaf34 100644 --- a/model_blockheaders.go +++ b/model_blockheaders.go @@ -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 @@ -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