best way to retrieve elements

+1 vote

Hello everyone,

Currently I'm using the liststreamkeyitems to retrieve periodically items from a stream. My use case would be to periodically ask to the system "what are the latest items that were published, from transaction txid=123... (excluded) & up until now"? What function or combination of functions would you suggest for that? I guess I could to that with both start and count parameters if I had a way to know how many items were published since item txid=123....

Thanks.

[edit]: solved, see below

asked Oct 31, 2016 by financedev
edited Nov 1, 2016 by financedev

1 Answer

0 votes

Your best bet for now is to keep track of the index of the last item retrieved in the application layer. In other words, when you call liststreamkeyitems, pass your internal record of this value in the start parameter, and then increment your internal record based on the number of items you get back. That way next time you'll only be retrieving new items. Note that for this to work reliably, you should use local-ordering=true in this API, in which case different nodes might get differently ordered results.

answered Oct 31, 2016 by MultiChain
That's pretty much what I had in mind. Thanks for the tip.
...