How to read a state after writing it into a chaincode

0 votes

I have setup the Fabric as per the instruction using docker and everything works fine. I have a chaincode which stores a value in the world state which I can read afterwards using a query method. When I submit multiple separate requests within a short period of time to store different data in the world state, I need to read th data submitted previously within each request. However, I am unable to read the most recently submitted data.

So I am wondering if there is any way to read the previous data just after storing the subsequent data.

May 28, 2018 in Blockchain by Christine
• 15,790 points
2,043 views

1 answer to this question.

0 votes

Data that is 'written' in chaincode is not yet committed to the database, it is only a proposal to write something to the database at that point. So, waiting a few seconds in the chaincode would not be sufficient. Only committed data is read back in chaincode. Therefore after you make an update in chaincode and get the proposal response, you must submit the transaction to ordering. Only then can the data be read back in chaincode.

However, If you must read the data that you just wrote within the same chaincode function, then you will need to keep a map of the data that has been written and retrieve the value from the map rather than from the committed database.

Hope this helps :)

answered May 28, 2018 by Perry
• 17,100 points

Related Questions In Blockchain

0 votes
1 answer

Hyperledger Composer: How to update a contract after it is saved?

Try this and see if this works: /** * ...READ MORE

answered Nov 9, 2018 in Blockchain by Omkar
• 69,220 points
813 views
0 votes
1 answer

In a Blockchain, how difficult is it to modify the third to last block?

Technically, it's not difficult at all, all ...READ MORE

answered Apr 20, 2018 in Blockchain by Christine
• 15,790 points
1,027 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,451 views
+1 vote
1 answer

Hyperledger - How can I use transaction certificates to enforce privacy?

The transaction certificates don't actually address privacy ...READ MORE

answered Apr 17, 2018 in Blockchain by Perry
• 17,100 points
901 views
+1 vote
2 answers

How to return value from a chaincode in Hyperledger Fabric?

Hyperledger Fabric supports only 2 types of ...READ MORE

answered Jun 13, 2018 in Blockchain by Perry
• 17,100 points
2,956 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP