Add the /headers[/:from_hash[/:count]]
endpoint
#41
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Opening this as a draft to gather some feedback. I'm pretty sure this won't compile on liquid right now, but I didn't want to invest too much time getting it to run in case there's no interest for this from your end.
Add a new endpoint to download headers in bulk, up to 2000 with a single
request.
Headers are returned in binary form, with the VarInt-encoded number of
items in the body preceeding them.
By default
from_hash
is the current best hash, but a differentstarting block can be specified.
The returned list goes "backwards" returning the
count - 1
blocksbefore
from_hash
plus the header offrom_hash
itself. This allowscaching the response indefinitely, since it's guaranteed that the
headers that come before a given block will never change.
Returns an error if
from_hash
is not a valid block or it isn't foundin the blockchain.
If
count
is greater than the limit of2000
it will be silentlycapped to said value.