-1

I am trying to run test_network on hyperledger fabric node release 2.4. See here: https://hyperledger-fabric.readthedocs.io/en/latest/test_network.html#interacting-with-the-network.

I can query the network using ReadAsset and UpdateAsset function.

However, the DeleteAsset function using below query doesn't work.

peer chaincode query -C mychannel -n basic -c '{"Args":["DeleteAsset","idOfasset"]}'

where, idOfasset is the ID or key of asset I am trying to delete from ledger.

Second, if the command would execute, would I be deleting the asset from the world database or the state database? Or let's put it the other way when I execute ReadAsset where does it read from i.e from the world state or the channel state database?

Help would be great, thanks.

Tarzan
  • 3
  • 3

1 Answers1

0

Deleting an asset changes the state of the asset. For any kind of operations which involve modification of the state of the variables, the invoke command is used. Each "Invoke" transaction will be added to the "block" in the ledger. query is used when you just want to query the chaincode for reading the current value of an asset. So use, invoke in lieu of query in your command.

Coming on to your second question

Second, if the command would execute, would I be deleting the asset from the world database or the state database? Or let's put it the other way when I execute ReadAsset where does it read from i.e from the world state or the channel state database?

World and state databases are the same things which are your CouchDB/LevelDB. From Hyperledger Fabric's documentation:

there’s a world state – a database that holds current values of a set of ledger states. The world state makes it easy for a program to directly access the current value of a state rather than having to calculate it by traversing the entire transaction log

You can read more about it here.

Hyperledger Fabric doesn't actually "remove" the asset when a delete operation is performed. Blockchain is immutable and no data on a blockchain will ever be deleted. A deletion is just another transaction saying certain data is deleted so that the world state database can remove that data.

You can refer to this for more info.

Kartik Chauhan
  • 2,779
  • 5
  • 28
  • 39
  • It does make sense. I am able to view the world state but the blockchain seems inaccessible, which is why I am unable to see the new transaction created as a result of executing my Delete command, hence, the consusion. – Tarzan Apr 30 '21 at 10:15