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

pass the network driver to the constructor #714

Merged
merged 3 commits into from
Dec 25, 2024
Merged

pass the network driver to the constructor #714

merged 3 commits into from
Dec 25, 2024

Conversation

adecaro
Copy link
Contributor

@adecaro adecaro commented Dec 13, 2024

This PR simplify the constructors used to create a new channel. It also replaces certain dependencies with interfaces and not structs.

This PR is tested against FTS in hyperledger-labs/fabric-token-sdk#804

Copy link
Member

@mbrandenburger mbrandenburger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good to me. Just two comments.

@@ -0,0 +1,39 @@
#!/bin/bash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this script belongs to the fts repo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really meant to have a script that updates FTS with the current FSC commit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand. However, I think this script should move to the FTS repo as it creates a PR on the FTS repo.

Such a script could support multiple strategies:

  • Get the commit hash from any local git clone / working branch.
  • Get the lastest commit hash from main
  • Provide the commit hash as a parameter to the script and update all go.mod files inside the project.

I believe the right way would be to use dependabot and schedule a daily check if the main branch on FSC has something new. As dependabot only "detects" versioned updated (not individual commits) it won't work like that. You can create a GH action that is fired once per day to check if there is a new commit on FSC main branch and then create a PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, I'll remove the script.

platform/fabric/sdk/dig/generic/providers.go Outdated Show resolved Hide resolved
committerService := p.newCommitter(
nw.ConfigService(),
committerService, err := p.newCommitter(
nw,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we pass the whole nw? We just want a few services, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, but we don't know before hand which services we might need. These constructors are called during the invocation of this function type NewChannelFunc = func(network driver.FabricNetworkService, name string, quiet bool) (driver.Channel, error). It seems fair to me that also the constructors get network. No?

@@ -133,6 +137,16 @@ func (o *Service) SetConsensusType(consensusType ConsensusType) error {
return nil
}

func (f *Service) SetConfigOrderers(o channelconfig.Orderer, orderers []*grpc.ConnectionConfig) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We pass o that already contains Consenters and orderers. Do we need both? We could only pass ordererType.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, we can simplify this.

type LedgerConstructor func(
channelName string,
nw driver.FabricNetworkService,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if it's a good idea to replace the actual dependencies by a struct that contains these and many more. This creates a tighter coupling and looser cohesion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, but we don't know before hand which services we might need. These constructors are called during the invocation of this function type NewChannelFunc = func(network driver.FabricNetworkService, name string, quiet bool) (driver.Channel, error). It seems fair to me that also the constructors get network. No?

Copy link
Contributor

@alexandrosfilios alexandrosfilios left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@alexandrosfilios alexandrosfilios left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alexandrosfilios alexandrosfilios merged commit 5b0424a into main Dec 25, 2024
20 checks passed
@alexandrosfilios alexandrosfilios deleted the f-ndc branch December 25, 2024 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants