Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hyperledger fabric - is query a new transaction on the blockchain

We are currently making a plan for our hyperledger fabric network. We really need to know the answer to the following question: "Does a query to the blockchain/worldstate add another transaction to the blockchain"?

The docs tells us the following (that's where the confusion occured).

  • "Applications submit transactions which capture changes to the world state, and these transactions end up being committed to the ledger blockchain."
  • "The blockchain is structured as sequential log of interlinked blocks, where each block contains a sequence of transactions, each transaction representing a query or update to the world state."

So does only updates result in new transactions on the blockchain or also queries?

like image 416
M Yil Avatar asked Oct 25 '25 16:10

M Yil


1 Answers

The answer is no, you will not insert another transaction in a block, but a transaction is generated to do the query.

Let me explain better:

When an application wants to insert data into the blockchain, it generates a transaction. The application will contact endorsing peers for making the transaction proposal, check the results, and only if they are equal and correct, the transaction is sent to the ordering service. The ordering service is the only one who is allowed to generate new blocks for the blockchain. The ordering service receive these transactions and insert them into blocks, and then send the blocks to the various peers in order to update their local copy of the ledger.

Instead, when you want to do a query, you generate a transaction to communicate with one or more peer, the peer will send you the answer but here the transaction ends. By ends, I mean that the transaction is not sent to the orderer, he is not contacted at any point when you do a query. This because you query the ledger contained in the peer, which is a local copy of the ledger, and you don't generate a new block.

So, transaction is used to communicate with the peer, but is not sent to the orderer in this case, it is not written inside a block and it is not used for that. Inside blocks you will find only transactions approved by the application after the proposal, which are next validated by the ordering service and can modify the world state.

like image 114
Riki95 Avatar answered Oct 28 '25 03:10

Riki95