hyperledger / fabric-sdk-go

https://wiki.hyperledger.org/display/fabric
Apache License 2.0
910 stars 510 forks source link

feat: expose ChannelProvider from the gateway #244

Open mblottiere opened 1 year ago

mblottiere commented 1 year ago

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.

codecov[bot] commented 1 year ago

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 commented 1 year ago

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[bot] commented 1 year ago

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.