We want the ability to fetch BatchPublicationLogData asychronously and lazily loaded.
Finishes #179436295
Solution
Create a class AsyncPublicationsIterator that conforms to AsyncIterator (but only in that it has an async next() function)
Create a function that returns the new iterator after doing some range checking.
Tests for same
How next() works:
Calling next() on the iterator makes it search for filtered logs on chain, walkbackBlocks at a time until it gets results.
Once it gets at least one result it, returns an "IteratorResult" which is an object containing a "done" boolean meaning no more results are left, and the next Publication result, or undefined if there are none.
Subsequent calls to next() advance the index into the fetched publications until it runs out.
When next has returned the last of the fetched results, calling next() repeats the process of walking back until it gets results, or until the earliestBlock value has been reached, whichever comes first.
Double Checks:
[x] Did you update the changelog?
[X] Any new modules need to be exported? N/A
[X] Are new methods in the right module? I think so?
[X] Are new methods/modules in core or not (i.e. porcelain or plumbing)?
[X] Do you have good documentation on exported methods?
Change summary:
New class, AsyncPublicationsIterator
Creator function for above
Tests for same
Steps to Verify:
Tests should all pass.
You should be able to create and use the AsyncPublicationsIterator when you import this version of the sdk.
Problem
We want the ability to fetch BatchPublicationLogData asychronously and lazily loaded. Finishes #179436295
Solution
How
next()
works:next()
on the iterator makes it search for filtered logs on chain,walkbackBlocks
at a time until it gets results.next()
advance the index into the fetched publications until it runs out.next()
repeats the process of walking back until it gets results, or until theearliestBlock
value has been reached, whichever comes first.Double Checks:
Change summary:
Steps to Verify: