Get the item number for a stream item in a particular transaction

0 votes

Hi MultiChain,

Really enjoying using your software.

I am storing items in a stream, and I'd like to be able to read the item number for a particular item. The reason for this is I want to tidy up some cached data once the item is confirmed a certain number of times, so I was thinking of:

  1. Using "getblockcount" to find out the length of the chain, then calculating N, which is the latest block for which I want to tidy up.
  2. Then calling "getblock N 4" to retrieve the transactions for that block
  3. Then maybe "getstreamitem mystream txid...." to get the items in turn.

But I can't see how to work out the item number from the data returned by getstreamitem.

Maybe I'm thinking about this the wrong way... is the item number actually stored in the database or is it just calculated on the fly when one calls liststreamitems?


asked Jun 16, 2017 by jc127
Ha, just spotted you added 'liststreamblockitems' in beta2, yesterday. That makes things simpler, but still no item number.
I'm asked the dev team about this issue and will reply shortly.

1 Answer

+1 vote
So the answer from the dev team is that this is not straightforward to do, because of how MultiChain performs internal indexing. Presumably you want the item number to map back to some identifier in your cache? If so can I suggest using the txid as an identifier instead? That is the right approach for blockchains anyway.
answered Jun 18, 2017 by MultiChain
Yes, makes sense, thanks.