LibertyDSNP / eth-sdk-ts

TypeScript SDK for DSNP on Ethereum
Apache License 2.0
9 stars 1 forks source link

Feature/fetch logs paged #175

Closed shannonwells closed 3 years ago

shannonwells commented 3 years ago

Problem

We want the ability to fetch BatchPublicationLogData asychronously and lazily loaded. Finishes #179436295

Solution

How next() works:

  1. Calling next() on the iterator makes it search for filtered logs on chain, walkbackBlocks at a time until it gets results.
  2. 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.
  3. Subsequent calls to next() advance the index into the fetched publications until it runs out.
  4. 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:

Change summary:

Steps to Verify:

  1. Tests should all pass.
  2. You should be able to create and use the AsyncPublicationsIterator when you import this version of the sdk.
shannonwells commented 3 years ago

@wilwade I think I got everything.