Skip to content

refactor(core-database): block and transaction history services#3644

Merged
faustbrian merged 62 commits intodevelopfrom
refactor/core-database/search
Apr 20, 2020
Merged

refactor(core-database): block and transaction history services#3644
faustbrian merged 62 commits intodevelopfrom
refactor/core-database/search

Conversation

@rainydio
Copy link
Copy Markdown
Contributor

@rainydio rainydio commented Apr 8, 2020

Summary

Two new services are introduced to query historical data.

  • BlockHistoryService to query previously forged blocks, returns Interfaces.IBlockData.
  • TransactionHistoryService to query previously forged transactions, returns Interfaces.ITransactionData.

Interfaces are defined in Contracts.Shared namespace (core-kernel). Implementation is provided by core-database package. Code that previously directly referenced BlockRepository and TransactionRepository from core-database package to get historical data is updated to use those services.

Criteria

Most of the methods accept criteria parameter describing filter condition. It's strictly typed and its syntax naturally describes both simple and complex conditions:

  • Property values are joined with AND.
  • When property value is array, each of array values is joined with OR.
  • Criteria itself also can be array and will be joined with OR.
  • Property values are matched using = operator.
  • Some property values (vendorField) are matched using LIKE operator.
  • Some property values (asset) are matched using @> operator.
  • Numeric properties can also be matched using >= or <= or both.

Here is an example:

const blocks = await blockSearchService.findManyByCriteria({
  version: 1,
  height: { from: 1000 },
  generatorPublicKey: [aliceKey, bobKey],
});

// WHERE
//   version = 1 AND
//   height >= 1000 AND (
//     generator_public_key = :alice_key OR
//     generator_public_key = :bob_key
//   )

description in progress

Fixes #3637

Checklist

  • Documentation
  • Tests
  • Ready to be merged

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 8, 2020

Codecov Report

Merging #3644 into develop will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #3644   +/-   ##
========================================
  Coverage    85.21%   85.21%           
========================================
  Files          505      505           
  Lines        11536    11536           
  Branches      1460     1460           
========================================
  Hits          9830     9830           
  Misses        1702     1702           
  Partials         4        4           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ce9f364...ce9f364. Read the comment docs.

typeGroup: 1,
fee: "0",
amount: "300000000000000",
blockId: expect.anything(), // ? how is that blockId isn't constant
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Block IDs used to be BigInt but are now hex, that is why.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel that this assertion isn't right. I added it as stub. Block id is changing from run to run and it's integer. This is transaction.blockId, should it be hex?

@faustbrian faustbrian marked this pull request as ready for review April 17, 2020 06:45
@faustbrian faustbrian merged commit 2038cd5 into develop Apr 20, 2020
@ghost ghost deleted the refactor/core-database/search branch April 20, 2020 02:26
@ghost ghost removed the Status: Needs Review label Apr 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants