Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Conversation

@jimthematrix
Copy link
Contributor

@jimthematrix jimthematrix commented Jun 10, 2022

Even though the latest recommendation from the Fabric team is to step away from requiring init, a lot of customers still use this approach, and the official docs for Fabric chaincode lifecycle still describes the --init-required parameter, finally the fabric-samples that is used widely by tire-kickers still implements InitLedger().

Added a new SubmitInit() instead of modifying the existing signature to allow backward compatibility

Signed-off-by: Jim Zhang <jim.zhang@kaleido.io>
@jimthematrix jimthematrix requested a review from a team June 10, 2022 14:19
@codecov
Copy link

codecov bot commented Jun 10, 2022

Codecov Report

Merging #236 (1c704ae) into main (7a94fbc) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #236   +/-   ##
=======================================
  Coverage   76.21%   76.22%           
=======================================
  Files         193      193           
  Lines       14098    14103    +5     
=======================================
+ Hits        10745    10750    +5     
  Misses       2385     2385           
  Partials      968      968           
Impacted Files Coverage Δ
pkg/gateway/transaction.go 88.39% <100.00%> (+0.54%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7a94fbc...1c704ae. Read the comment docs.

@troyronda
Copy link
Contributor

@andrew-coleman Do you have any comments about the additional function in the Gateway package?

@bestbeforetoday
Copy link
Member

There are already TransactionOption functional options to set endorsing peers and transient data when calling CreateTransaction(). I think this would be a better fit for creating a Transaction with the isInit flag set. Something like:

func WithInit() TransactionOption {
	return func(txn *Transaction) error {
		txn.isInit = true
		return nil
	}
}

@andrew-coleman
Copy link
Member

Hi Jim, if we were to implement this in the new fabric-gateway Go API, we would almost certainly adopt the pattern as suggested by Mark in the previous comment. Would you be able to do that here?

@jimthematrix
Copy link
Contributor Author

@bestbeforetoday @andrew-coleman thanks for suggesting the options approach, I can switch to that in this PR.

Signed-off-by: Jim Zhang <jim.zhang@kaleido.io>
@jimthematrix jimthematrix changed the title Add SubmitInit() to support chaincodes that require init Add WithInit() to support chaincodes that require init Jun 16, 2022
@andrew-coleman andrew-coleman merged commit e170b98 into hyperledger:main Jun 17, 2022
@andrew-coleman
Copy link
Member

Thanks Jim!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants