Skip to content

Batch sync state #174

@hackaugusto

Description

@hackaugusto

Currently a client needs to perform sync calls on a loop, roughly like this:

chain_tip = sync()
while local_block != chain_tip:
    chain_tip = sync()

On the pseudo code above, each call to sync is a gRPC request, that fetchs the data of a single updating block 1. The loop may reutilize a connection, but it still has to perform many round trips (the number of roundtrips depends on how many updating blocks exist). This can be very inefficient for some use cases, for example, an off-chain app, that uses notes as an event mechanism.

For the scenario above, it make sense to have an api that instead of requiring a loop, return a batch of updates:

chain_tip = batch_sync()  # returns multiple updates, instead of a single one
while local_block != chain_tip:
    chain_tip = batch_sync()

We probably still need the loop, because we should have an upper bound on the amount of work the server does per request, lets say produce a response with up to 5MB of data. But this interface should allow for much more efficient syncing on some use cases.

Footnotes

  1. By "updating block", I mean a block that contains a change to an account/nullifier of interest, or a note that matches the user's tags. So a block that matches the search criteria and is returned in the response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions