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.

EDIT:

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:

========count=10,start=0
[]
========
========count=10,start=10
[40,41,42,43,44,45,46,47,48,49,]
========
========count=10,start=20
[30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,]
========
========count=10,start=30
[20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,]
========
========count=10,start=40
[10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,

40,41,42,43,44,45,46,47,48,49,]
========
========count=10,start=50
[00,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,

30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,]
========

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 :)
...