I have installed and configured an Hyperledger Blockchain environment in a local machine for testing. I have developed a dApp for "Car Registeration and Taxation System". I have also developed a front-end for Data insertion using Flutter App. The blockchain consists of one node and two members only (Admin and a user). Smart contracts have been developed in Golang. The DB is couchDB. I wanted to test the integrity of the blockchain and did following tests:
I created a Car record and filled the necessary fields and then saved. I then deleted that car using the front-end app, and the record was deleted from chaincode but a new block was also created.
I was able to delete directly from CouchDB using Admin permissions. The record was deleted but no new block created.
Using a same Car-ID which I created earlier, I was able to duplicate the same fields with the same previous Car-ID, and duplicare records got created.
If I update a car with a new owner, the new block gets created, but I am unable to view the previous owner of the car.
5.Multipe car records can be created in the same unique car-ids.
Can anyone please assist, whats going-on? As I read in docs, blockchain does not support duplication and deletion of records, but in my case this is happening. Am I doing something wrong?
Also I wanted to know if the records are created in the ledger or CouchDB?
Your quick assistance is highly appreciated.
- I created a Car record and filled the necessary fields and then saved. I then deleted that car using the front-end app, and the record was deleted from chaincode but a new block was also created.
- I was able to delete directly from CouchDB using Admin permissions. The record was deleted but no new block created.
Blockchain is immutable, so deleting a record in Hyperledger Fabric means it's marked as deleted. Actual data will still be available in the Blockchain. The created new block when you delete a record indicates that the blockchain has marked your record as deleted.
Hyperledger Fabric has two types of states. World State and the Blockchain. CouchDB only holds the World State, which shows the current status of your application data. It uses world state to optimize the queries to retrieve your application data. So, deleting CouchDB records doesn't mean you have deleted the records. The records in CouchDB can be always recreated using the Blockchain state, which keeps all the transactions in blocks stored as files in your peers and orderers related to the particular channel.
- Using a same Car-ID which I created earlier, I was able to duplicate the same fields with the same previous Car-ID, and duplicare records got created.
- If I update a car with a new owner, the new block gets created, but I am unable to view the previous owner of the car.
- Multipe car records can be created in the same unique car-ids.
In Hyperledger Fabric, Blockchain is represented as a key-value store. So, similar to a key-value store, you can put a value multiple times for the same key. You can get the last value you put for a key using stub.getState()
if you need to retrieve the previous values attached to a particular key, you can use stub.getHistoryForKey()
method, which will let you iterate through all the historical values attached to the key.
Also I wanted to know if the records are created in the ledger or CouchDB?
All history of your transactions is stored in the ledger. The current state of your transactions is stored in CouchDB.