-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create a Commit object for a given transaction ID #195
Comments
The qscc chaincode already offers a GetTransactionByID transaction function that does not block waiting for a commit, but could be polled until a transaction is committed, so that capability may be good enough that this feature does not need to be included in the Fabric Gateway API. |
@bestbeforetoday We are currently going with the above approach to query the transaction state before re-submission and decode the response with
But I think it would be helpful to have the above suggested implementation as a part of Gateway SDK itself. FYR @bviswana101 |
@tskvivekmani One other option for you, if you are checking for a transaction you submit and using the finer-grained transaction flow, is to keep hold of the Commit object you get back from calling The Commit object can be serialized for use in a different application run by calling its Using Node.js as an example, the code might look something like this, although the flow is similar in all client languages: const proposal = contract.newProposal('transactionName');
const transaction = await proposal.endorse();
const commit = await transaction.submit();
const serializedCommit = commit.getBytes();
// Store the serialized commit bytes for later use
const deserializedCommit = gateway.newCommit(serializedCommit);
const status = await deserializedCommit.getStatus(); This capability was included as part of a general pattern of supporting recovery from application failures by allowing objects at each stage of the transaction flow to be persisted (issue #394). |
Thanks for the reply @bestbeforetoday. We're currently persisting proposal bytes in order to re-submit (w/ same proposal to eliminate version bumps) if encountered any errors. So wouldn't it be an overhead to persist commit object to query txn state. --
In this case, To know of the response/result of the transaction, we would still need to query the TxnID right. |
You are correct that the serialized Commit object does not store the transaction result. Neither does the serialized Proposal object. You do see the transaction result on the Transaction object returned from A transaction recorded on the blockchain is only assigned a To get the result of a transaction that is actually recorded on the blockchain, re-endorsing the same proposal is not a good approach since the ledger state may be different from when the original transaction was endorsed and therefore you may get a different result. To see the transaction result you should probably either store the transaction result you received when doing the first endorsement, or use the qscc system chaincode to get the transaction and interrogate its protocol buffer message to check the result. I should add that this issue is just intended to allow use of the CommitStatus capability offered by Fabric Gateway as an alternative to using the qscc chaincode, for cases where you didn't submit a given transaction have no access to the Commit object created as part of that flow. |
As an application developer
I want to create a Commit object directly from a specified transaction ID
So that I can obtain the validation code for an arbitrary transaction
Currently Commit objects are only obtained by submitting a transaction. It is convenient to be able to check the commit status of a given transaction, which may not have been previously submitted by the current client application process.
Suggested implementation is to provide a
newCommit()
method onNetwork
that takes a transaction ID as a parameter. Gateway already has anewSignedCommit()
method for use in off-line signing, and this would mirror the pattern for Proposal, which has bothnewProposal
on Contract andnewSignedProposal
on Gateway.Tasks:
NewCommit()
receiver function for Network, with unit tests and Godoc.newCommit()
method on Network, with unit tests and Typedoc.newCommit()
method on Network, with unit tests and Javadoc.The text was updated successfully, but these errors were encountered: