Skip to content

Commit

Permalink
FABGW-20 Specify endorsing organizations (#2578)
Browse files Browse the repository at this point in the history
Implementation of endorsingOrgs in gateway Endorse method.
- The set of endorsing peers from the discovery service is filtered down to only include those from the specified orgs.
- The discovery handling code has been upgraded to step through all given layouts to find a layout that satisfies the endorsingOrgs constraint.

Signed-off-by: andrew-coleman <andrew_coleman@uk.ibm.com>
  • Loading branch information
andrew-coleman authored May 21, 2021
1 parent 6f0bef1 commit b4efe85
Show file tree
Hide file tree
Showing 16 changed files with 385 additions and 210 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ require (
github.com/hyperledger/fabric-chaincode-go v0.0.0-20201119163726-f8ef75b17719
github.com/hyperledger/fabric-config v0.1.0
github.com/hyperledger/fabric-lib-go v1.0.0
github.com/hyperledger/fabric-protos-go v0.0.0-20210422135545-37e930696e2a
github.com/hyperledger/fabric-protos-go v0.0.0-20210505131505-0ac7fd605762
github.com/kr/pretty v0.2.1
github.com/magiconair/properties v1.8.1 // indirect
github.com/mattn/go-runewidth v0.0.4 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ github.com/hyperledger/fabric-lib-go v1.0.0 h1:UL1w7c9LvHZUSkIvHTDGklxFv2kTeva1Q
github.com/hyperledger/fabric-lib-go v1.0.0/go.mod h1:H362nMlunurmHwkYqR5uHL2UDWbQdbfz74n8kbCFsqc=
github.com/hyperledger/fabric-protos-go v0.0.0-20190919234611-2a87503ac7c9/go.mod h1:xVYTjK4DtZRBxZ2D9aE4y6AbLaPwue2o/criQyQbVD0=
github.com/hyperledger/fabric-protos-go v0.0.0-20200424173316-dd554ba3746e/go.mod h1:xVYTjK4DtZRBxZ2D9aE4y6AbLaPwue2o/criQyQbVD0=
github.com/hyperledger/fabric-protos-go v0.0.0-20210422135545-37e930696e2a h1:sJwXhCxTQ7euBj+4w7pomn0CzOgdHkLlUOqtDgsI8IA=
github.com/hyperledger/fabric-protos-go v0.0.0-20210422135545-37e930696e2a/go.mod h1:xVYTjK4DtZRBxZ2D9aE4y6AbLaPwue2o/criQyQbVD0=
github.com/hyperledger/fabric-protos-go v0.0.0-20210505131505-0ac7fd605762 h1:7eZyv7Ly+AY8y0e/8WCitouShlWcjBT9QJGf/8DGqHQ=
github.com/hyperledger/fabric-protos-go v0.0.0-20210505131505-0ac7fd605762/go.mod h1:xVYTjK4DtZRBxZ2D9aE4y6AbLaPwue2o/criQyQbVD0=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
Expand Down
10 changes: 8 additions & 2 deletions internal/pkg/gateway/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (gs *Server) Evaluate(ctx context.Context, request *gp.EvaluateRequest) (*g
return nil, status.Errorf(codes.InvalidArgument, "failed to unpack transaction proposal: %s", err)
}

endorsers, err := gs.registry.endorsers(channel, chaincodeID)
endorsers, err := gs.registry.endorsers(channel, chaincodeID) // TODO next story, implement endorsingOrgs for Evaluate
if err != nil {
return nil, status.Errorf(codes.Unavailable, "%s", err)
}
Expand Down Expand Up @@ -95,7 +95,13 @@ func (gs *Server) Endorse(ctx context.Context, request *gp.EndorseRequest) (*gp.
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "failed to unpack transaction proposal: %s", err)
}
endorsers, err := gs.registry.endorsers(channel, chaincodeID)

var endorsers []*endorser
if len(request.EndorsingOrganizations) > 0 {
endorsers, err = gs.registry.endorsersForOrgs(channel, chaincodeID, request.EndorsingOrganizations)
} else {
endorsers, err = gs.registry.endorsers(channel, chaincodeID)
}
if err != nil {
return nil, status.Errorf(codes.Unavailable, "%s", err)
}
Expand Down
Loading

0 comments on commit b4efe85

Please sign in to comment.