I need to save the query historial in Hyperledger Fabric, for example if I have a marble Object and I query it 2 times, I would like to retrieve the query historial. I already try call a query with PEER INVOKE and then use GetHistorialForKey function but it does not work because of the asset is not been modify
You'd have to turn your queries into invokes, which would result in them being subject to the rules of invoke and slowing them down.
Related
I'm new to hyperledger fabric and I'm trying to query a chaincode for a specific key. I can retrieve the json data for the key but I would also like to get the block number and transaction id related to the last PutState call which created/updated the data I'm retrieving from couchDB. Is there a way to do that?
Thanks in advance
Responding to help anyone who could have the same problem and to check if the solution I adopted makes any sense. So as I understand Hyperledger allows you to get the transaction id before your transaction is submitted to the blockchain wich I found peculiar after having worked with ethereum. Using golang me and my colleagues found this line:
txID := ctx.GetStub().GetTxID();
So our solution was to save the transaction id inside the data we are storing in the blockchain, to easily retrieve it by a simple query (to couchDB for example).
In the end we retrieved the informations bound to the txid by calling the "GetBlockByTxID" sc of the "qscc" chaincode (present by default in every channel of hyperledger as far as I understand) using the "fabric-network" node module, and decoded it using "fabric-common" node module's BlockDecoder:
result = BlockDecoder.decode(result)
I am trying to create a chaincode with different assets types.
Imagine that I have a chaincode where I store the users created and also the transactions where the users receive points.
How can I create a chaincode in a way that I am able to queryAllUsers and queryAllPointsTransactions? without using lists as it is available in this github https://github.com/IBM/customer-loyalty-program-hyperledger-fabric-VSCode
Because when using lists we have problems with multiple clients and with multiple transactions at the same time.
Does anyone can help me on this?
Thanks a lot!
PutState the asset separately from each key, and use the function below.
GetQueryResult
GetStateByRange
What is the difference between add/update assets directly vs add/update assets through transaction. Which is the right way to do?
We can add/update assets using API then why we perform transaction on assets? Is this like a log/trace to track what and when things updated on assets? What If I made changes in assets directly without any transaction entries? or should I do changes through transactions on assets?
For Example:
asset Myasset identified by asset_id {
o String asset_id
--> User admin
o String firstname
o String lastname
o Boolean status default=true
}
transaction UpdateMyasset {
o Myasset certificate
o Boolean status default=true
}
So should I use UpdateMyasset to create assets or directly use Myasset? When should I use transaction?
this is actually a very good question.
you are correct, there are two ways to create / update assets and that part has never sit right with me. The API, by default, gives you endpoints to create / update assets.
In my mind that is a problem, because it's bypassing any kind of business rules you might have. These rules can be specified and applied however via a transaction. At that point you can check your asset, make sure everything is good and if all business rules are fulfilled, then you can create / update your asset.
What I think should be done in a serious, non POC kind of application, is to completely disable the asset endpoints and only create / update assets via transactions and only once the business rules have been applied and your assets properly validated.
We have set up a hyperledger fabric network and uploaded a history of transactions. Realized that part of these transactions are incorrect and hence we want to exclude them from chaincode queries.
From whatever I understand, the shim API DelState can be used to delete an asset from World state and hence this will not appear in chaincode queries.
But, we do not want to delete the entire asset. We just want to mark few transactions as invalid.
I'm using bigchain db in our project. Currently we are using transaction model to create assets and transfer it. But now we want to implement block model. When I go through the documentation I can't find how to create a block? Is there any specific url or any function or do we have to use same url as like for transaction model for example http://ourserver.com:8080/api/v1/ ? Can any one help me in this. Thank you.
As with Bitcoin, one submits a transaction to a BigchainDB network and then it's up to the network (i.e. the nodes in the network) to put that transaction in a block (or not, if the transaction is invalid).