How to return data without being able to paginate

Hi!

One of our blocks (genesis one) has 14505 UTXOs as they were part of a preloaded accounts batch. That’s for sure breaking the API, or at least it will take a lot of time to fetch all of them. As the API doesn’t provide paging capabilities on it’s spec, how should we handle this specific use case?

I don’t think this might also apply to other endpoints (not I can think of now) .

Thanks!

One of our blocks (genesis one) has 14505 UTXOs as they were part of a preloaded accounts batch.

Just to make sure we are talking about the same thing, I want to confirm you are referring to this block?

That’s for sure breaking the API, or at least it will take a lot of time to fetch all of them. As the API doesn’t provide paging capabilities on it’s spec, how should we handle this specific use case?

Fortunately, it is possible to “page” on the /block endpoint by directing the client to fetch each transaction separately! All you need to do is populate the other_transactions field in the block response with each transaction identifier that should be fetched.

Additionally, I want to clarify that there is no restriction on either always returning all transactions in /block or always directing the client to always fetch transactions using /block/transaction. For some blocks, you may populate all transactions and for other blocks you may direct the client to make separate requests (you can even populate some transactions in a block and require others to be fetched separately).

This all works correctly as long as you don’t populate a transaction in /block and request the same transaction be fetched using /block/transaction. Clients are not expected to dedup populated transactions!

Examples

If you are curious how this is done, check out this snippet of code in Celo’s Data API implementation:

If you are curious how clients handle this other_transactions field, take a look at this file:

Excellent! It worked like a charm!

It’s worth mentioning that when returning txs using other_transactions might be less performant so we decided to dynamically chose when to use one or the other.

Thanks!

1 Like

Glad to hear this worked! Good call out on dynamically switching when to use other_transactions. I think this would be something very useful to mention in the docs if you’d like to make a PR! Something in this description:

2 Likes

I’m not good at this but here you go https://github.com/coinbase/rosetta-specifications/pull/32

1 Like