How to read stream from the beginning

+2 votes

I need to read the stream that has X (potentially hundreds) messages from the very beginning.

I need to use multiple liststreamitems queries, what parameter values of start/count should I use?

I'm currently using count=200, start=100 to get last messages, but I can't figure the right parametrs for my algorithm to read the stream sequentially from the very start.


I followed the paging comment and made a small experiment, I published 50 messages on the stream with values 00,01,02,...,49

I ran the stream reading with different values of start/count and this is the result:




Are start/count defined in the wrong order?

Even if the are reversed, why does it start from 10 latest messages instead of 10 oldest messages. How can I start from the oldest ones and go up from there?

asked Mar 1, 2017 by Ivo
edited Mar 3, 2017 by Ivo

1 Answer

+1 vote
Best answer

Just pass count=999999 and start=0

answered Mar 1, 2017 by MultiChain
selected Mar 3, 2017 by Ivo
Ok, but is it efficient to download a million transactions every time? I'm pretty sure I will overflow my memory or hit some quota this way. I had something more efficient in mind - a paging mechanism of some sort.
Yes, if you have many items in the stream you should certainly use paging. For example you could set count=100 each time, then start=0, start=100, ...

Note that if you want a guarantee of consistency between the responses from a particular node across time, even for recent items, you should use local-ordering=true. But this means different nodes could respond differently.
See my edit for the effects of the instructions you have just provided.
It looks like you are probably not passing the verbose parameter.
Vebose fixed it! Thanks :)