Get last item published in stream

+1 vote
Am new to multichain.. got basic question about retrieving latest items from stream.

Can one relies on 'liststreamitems' with start = '-1' and count ='1' to retreive last published item in stream?
Is it guarantees that last item appended is always the last item publish.

 if mining time at one of node took longer time than others, can order of items changes from one node to another. and items orders would differ from order they being actually published?

For example, there 3 publishers (a, b & c) subscribed to certain stream 'testStream'.

if (a) then (b) published new record (item1) to 'testStream'.

could (c) see the same order or it can be swapped due to its mining time or other reason?
asked Feb 8, 2019 by Maha

1 Answer

0 votes

The answer is that yes, you can rely on this method to get the last published item, according to the order in the blockchain. If you wanted it according to the order seen by that specific node you would pass true for the local-ordering parameter of liststreamitems but this is not the default behavior.

However please note that it is possible (depending on your miner setup) for there to be a temporary fork in the blockchain, where different nodes see different versions of the latest block, and those two versions have some stream items in a different order. This will resolve quickly, but if you want to make absolutely sure that every node gets the same answer, you should wait for a few confirmations of blocks on top of the item published.

answered Feb 11, 2019 by MultiChain