createrawsendfrom not working as expected

+1 vote

I executed the following command. As per my understanding this should push 2 items into the same stream. One with "G500" as key and the other with "G600" as key. Instead, it pushes the 1st item twice.

multichain-cli testchain createrawsendfrom 1BFNpodjv2J9TxsnLE8wAUKLYGxmx2QsiSnB2a '{}' '[{"for":"doc_data","key":"G500","data":"4f6e65206974656d"} {"for":"doc_data","key":"G600","data":"4f6e6520"}]' send

 

Result on executing multichain-cli testchain liststreamkeyitems doc_data true 10 :

[
    {
        "publishers" : [
            "1BFNpodjv2J9TxsnLE8wAUKLYGxmx2QsiSnB2a"
        ],
        "key" : "G500",
        "data" : "4f6e65206974656d",
        "confirmations" : 22,
        "blockhash" : "00002cbc5de47303754bff071188f6bde32d684845ff6cb072eadc95aab4c691",
        "blockindex" : 1,
        "blocktime" : 1490275633,
        "txid" : "38b5d1442085c027e419a39d5e299c533bb002e674bb55a9d984fadad3a44d15",
        "vout" : 0,
        "valid" : true,
        "time" : 1490275633,
        "timereceived" : 1490275649
    },
    {
        "publishers" : [
            "1BFNpodjv2J9TxsnLE8wAUKLYGxmx2QsiSnB2a"
        ],
        "key" : "G500",
        "data" : "4f6e65206974656d",
        "confirmations" : 22,
        "blockhash" : "00002cbc5de47303754bff071188f6bde32d684845ff6cb072eadc95aab4c691",
        "blockindex" : 1,
        "blocktime" : 1490275633,
        "txid" : "38b5d1442085c027e419a39d5e299c533bb002e674bb55a9d984fadad3a44d15",
        "vout" : 0,
        "valid" : true,
        "time" : 1490275633,
        "timereceived" : 1490275649
    }
]

Note: I'm using multichain version 1.0 alpha 28. Protocol version - 10007

asked Mar 23, 2017 by Cypher
edited Mar 23, 2017 by Cypher

1 Answer

+1 vote
 
Best answer
In general, MultiChain does not allow two items for the same stream in one transaction. You can use the raw transaction APIs to write a transaction which does this, but it's not supported properly by subscribing nodes.
answered Mar 23, 2017 by MultiChain
selected Apr 6, 2017 by Cypher
What I'm actually trying to achieve is to identify a given data by more than one key. Since "publish" command doesn't provide that option, I have to push the same data twice with 2 different keys. Is there any workaround for this?
For now, your best workaround is to use a level of indirection – use one stream for items and the other for an index.

In the first stream, post the item without a key and with the same data as usual. In the second stream, post two items, each with one key, and with the txid of the first item as the data. You can then retrieve using either key, in two steps.

We're working on a more powerful data model in future, that will make all this much easier.
Thank you very much. That would work. If the future data model of multichain could support stream data in json format along with querying feature in noSQL style (obviously excluding delete & update), then it'd be really useful.
...