diff --git a/core/chaincode/handler.go b/core/chaincode/handler.go index a85e0fe4283e012dc7ca98f955a0691390cc89c4..c6f4d3edd2c95ecc33c48acb01a706fca8a03346 100644 --- a/core/chaincode/handler.go +++ b/core/chaincode/handler.go @@ -14,6 +14,7 @@ import ( "time" "github.com/golang/protobuf/proto" + "github.com/hyperledger/fabric/common/channelconfig" "github.com/hyperledger/fabric/common/flogging" commonledger "github.com/hyperledger/fabric/common/ledger" "github.com/hyperledger/fabric/core/aclmgmt/resources" @@ -103,6 +104,13 @@ type UUIDGeneratorFunc func() string func (u UUIDGeneratorFunc) New() string { return u() } +// ApplicationConfigRetriever to retrieve the application configuration for a channel +type ApplicationConfigRetriever interface { + // GetApplicationConfig returns the channelconfig.Application for the channel + // and whether the Application config exists + GetApplicationConfig(cid string) (channelconfig.Application, bool) +} + // Handler implements the peer side of the chaincode stream. type Handler struct { // Keepalive specifies the interval at which keep-alive messages are sent. @@ -143,6 +151,8 @@ type Handler struct { // the peer. ccInstance *sysccprovider.ChaincodeInstance + appConfig ApplicationConfigRetriever + // serialLock is used to serialize sends across the grpc chat stream. serialLock sync.Mutex // chatStream is the bidirectional grpc stream used to communicate with the @@ -1011,6 +1021,11 @@ func (h *Handler) setChaincodeProposal(signedProp *pb.SignedProposal, prop *pb.P func (h *Handler) State() State { return h.state } func (h *Handler) Close() { h.TXContexts.Close() } +// GetApplicationConfig implements the method of the same name in the handlerSupport interface +func (h *Handler) GetApplicationConfig(chainID string) (channelconfig.Application, bool) { + return h.appConfig.GetApplicationConfig(chainID) +} + type State int const (