Skip to content
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

feat: expose ChannelProvider from the gateway #244

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mblottiere
Copy link
Contributor

We have a use case where given a Getway we need to query the ledger for some information (retrieving block from txID).

Being able to obtain the ChannelProvider is convenient since we can then create ledger.Client as needed.
I wonder however if it is desirable to expose such a low level component. Maybe something like gateway.GetLedger(...) would be more appropriate? Let me know what you think.

@mblottiere mblottiere requested a review from a team as a code owner July 29, 2022 08:59
This can be a useful escape hatch when one needs a ledger client and
already has a Gateway available.

Signed-off-by: Matthieu Blottière <[email protected]>
@codecov
Copy link

codecov bot commented Jul 29, 2022

Codecov Report

Merging #244 (d36373a) into main (965abe3) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #244   +/-   ##
=======================================
  Coverage   76.23%   76.23%           
=======================================
  Files         193      193           
  Lines       14103    14103           
=======================================
  Hits        10752    10752           
  Misses       2384     2384           
  Partials      967      967           
Impacted Files Coverage Δ
pkg/gateway/gateway.go 86.84% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us.

@bestbeforetoday
Copy link
Member

You can get a block by transaction ID by evaluating the GetBlockByTxID transaction function on the qscc system chaincode. It takes two parameters: channel name and transaction ID. The implementation is here:

https://github.com/hyperledger/fabric/blob/cde0248c947f45e46bdf454ee5f6da42ebc79658/core/scc/qscc/query.go#L125-L126

This assumes that invocation of system chaincode works OK for fabric-sdk-go, which I haven't tried. It does work with fabric-gateway.

@stale
Copy link

stale bot commented Jun 8, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jun 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants