I'm using hyperledger fabric 2.0. I have successfully ran chaincodes on the fabric network and my data is storing on the couch db. I'm viewing the data stored on the couch DB using
But I want to prove to my faculty that the data is being stored on the transaction log too. Is there any way to view the data that is stored on the transaction log?
If I understand it correctly you basically want to retrieve the ledger data while you're already able to access the world state (couch-db).
One way could be, depending upon what SDK you're using, you can use an instance of 'Channel' and run queries against the ledger data.
Following are the methods available in NodeSDK which could help you to run queries against your ledger:
queryBlock
queryBlockByHash
queryBlockByTxID
queryTransaction
Related
I want to implement Off-Chain data in hyperledger fabric I checked https://github.com/hyperledger/fabric-samples/tree/release-1.4/off_chain_data however instead of couch_DB I want to implement on Amazon DynamoDB.can we do that or there is no option to replace couchDB?
Any help will be great for me.
Thanks
You can be using any DB to store off-chain data.
Let see the process of this example do.
Listen to block events in code (document about addBlockListener function)
If detect a new block added, it will get data of this block and save to DB you config by call function writeValuesToCouchDBP. You should modify this to using Amazon DynamoDB (or any DB you want) instead of CouchDB
I am new in this field and therefore I am still doing studies and researches, I would like to know if JSON files can be imported in Hyperldeger Fabric--if it is better Hyperledeger Fabric or Fabric Composer. more precisely I would like to understand if there is a way to populate the DLT of Hyperledger Fabric automatically.
for now, I have only tried Hyperledger Composer online playground
Fabric don't have any feature to automatically populate the ledger.
You have to develop a solution in order to upoload each Json file and put that on the ledger state.
Any type of data can be inserted on the ledged because it stores byte arrays so its up to you how to serialize.
in case you're asking to making your chaincode or smart contract like talking to the file system and read file or even call some API to collect JSON files,
it could be done but this will break your transaction flow specially during the endorsement process due to during the endorsement process it's expected from each peer to return the same value after executing the transaction against the chaincode to consider the transaction is a valid transaction,
so in case one of the endorsers failed to call the API or failed to read file from file system the transaction will considered to be invalid.
so it's not recommended to do any third party activity in your chaincode or smart contract even if it's possible to do so.
about populating the ledger it can be done it's eventually a database so you can dump it's data, However, if you're trying to backup to recover the ledger in case the whole network down it's impossible due to when you'll reinstall the network the whole config and certificates which were bounded to the transaction will be changed so it has no sense to do it.
I understand there is world state and ledger.
1) World state is stored in Level DB or Couch DB
2) Ledger is stored in the form of LevelDB - /var/hyperledger
How about the events ? Where are they stored ? Especially what will happen when a new peer needs to pull the existing events. I was not able to find any documentation. It will be nice if someone can point me to the right information
A peer can't subscribe to historical events, and they are not stored anywhere in Fabric.
Hyperledger Composer stores transaction details (including events) in the Historian, which you can query to extract event details. See this answer for an example.
background:
I am developing Hyperledger Fabric Network(v1.1) and are using couchdb.
For continuing operation. It is necessary to persist data go each component(peer, orderer etc..).
Issue:
I don't know what I should persist couchdb's data for continuing operation in production environment.
Question:
(1)Should I persist these data in the below? And, if there is insufficient, please tell me that what I should persist data.
/opt/couchdb/data
/opt/couchdb/etc
(2)If I don't persist these couchdb's data. what will happen? (For example,
querying error,clush the data and difference from block's data).Please tell me.
sincerely.
If you don't persist the CouchDB data, then if you delete or upgrade the container you will lose the data. The good news is that if you have persisted the ledger from your peer, it will rebuild the data in CouchDB on startup but of course this will delay how long it takes for the peer to be able to serve any type of request.
The CouchDB image uses /opt/couchdb/data as the volume where it stores the data so you'll want to mount an external volume there.
I am able to save my data in CouchDB.As per my understanding, the ledger(stored inside blocks) contains the history of changes.
Is there any way to query that ledger?
How will I know which block I need to query (There are 100s of blocks and the data is in particular ledger in the block) Basically, I just want to see a history of particular data from the block and I do not know the block number.
Is it possible?
Any help/suggestion/comment would be appreciated.
Using the Node.js SDK you can query the ledger in multiple ways:
Query via chaincode: In this you write your code in the chaincode to query the ledger and call this using the Node.js SDK. This is when you don't have the TX ID or the Block ID.
Follow the query method in this example to write the query chaincode: https://github.com/hyperledger/fabric-samples/blob/release-1.1/balance-transfer/artifacts/src/github.com/example_cc/node/example_cc.js
Query Couch DB directly: In this you write the SDK code to query the ledger directly without going through the chaincode. This is when you know the TX ID or the Block ID.
Follow this example to write the SDK for the queries: https://github.com/hyperledger/fabric-samples/blob/release-1.1/balance-transfer/app/query.js
You can install composer-rest-server. It will start loopback server and exposes rest APIs for all the assets and historian. You can query historian to get all the transactions.