Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

feat: get block header by hash + store by height #27

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Alex-Werner
Copy link
Contributor

Issue being fixed or feature implemented

This PR allow to store and fetch BlockHeader by their height.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation

if (err && err.name === 'NotFoundError') {
resolve(null);
} else if (err) {
reject(err.message);
} else {
resolve(JSON.parse(data.toString()));
Copy link
Member

Choose a reason for hiding this comment

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

Can we just introduce two functions:

  • getByHeight
  • getByHash

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does the last commit fix that need ?

* @param {String|Number} identifier - Hash or height block identifier
* @returns {Promise<BlockHeader>}
*/
async get(identifier) {
Copy link
Member

Choose a reason for hiding this comment

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

May be don’t need a ploymorphic param here as well?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants