Reputation:
all so I have a problem with hyperledger fabric why it is allowed the chaincode to be executed parallel in hyperledger like this:
running push()
2
ending push()
running push()
1
ending push()
running push()
3
ending push()
running push()
5
ending push()
running push()
4
ending push()
So what I am doing here is: - Creating new transaction and sending 2 objects than - Immediately sending another transaction
so before the ledger is update the key should be for example: 3 + 2 = 5 and than again 5 + 1 = 6
but this is wrong in this case because it starts with: 3 + 2 = 5 and before updating the ledger another push is done from the current key 3 + 1 = 4 and not from 5 + 1 = 6.
how can I solve this ?
Upvotes: 1
Views: 429
Reputation: 5140
(I) keep in mind that a chaincode execution is just a simulation of the smart contract logic computation. In other words - the chaincode execution tells you what would be the update to the channel, if the transaction would be committed.
When the client gets back the endorsement from the peer (containing the simulation) - it sends it to the orderer to be scheduled to appear in some block in the next available batch that would cut a block.
Only when the block is persisted into the ledger (and only if the transaction is valid - meaning, it wasn't invalidated by any other transaction in a prior block or in a prior transaction within the block it came from) - next chaincode executions may see the changes of the transaction.
(II)
why it is allowed the chaincode to be executed parallel in hyperledger like this:
So, from (I) it follows that there is no point not to execute the chaincode in parallel, since in any case the end of the chaincode execution doesn't mean that the next execution would read that data.
Upvotes: 4