From 01a85556a9f40d92105673a50b71655daaf80e0a Mon Sep 17 00:00:00 2001 From: Andrew Richardson Date: Wed, 8 Mar 2023 19:38:32 -0500 Subject: [PATCH 1/2] Add Fabric option for a global (channel-wide) batch pin listener Signed-off-by: Andrew Richardson --- cmd/init_fabric.go | 1 + internal/stacks/stack_manager.go | 7 +++++++ pkg/types/namespace.go | 1 + pkg/types/options.go | 1 + pkg/types/stack.go | 1 + 5 files changed, 11 insertions(+) diff --git a/cmd/init_fabric.go b/cmd/init_fabric.go index ffc158d5..87cb76c7 100644 --- a/cmd/init_fabric.go +++ b/cmd/init_fabric.go @@ -73,5 +73,6 @@ func init() { initFabricCmd.Flags().StringArrayVar(&initOptions.MSPPaths, "msp", nil, "Path to the MSP directory for an org in your Fabric network") initFabricCmd.Flags().StringVar(&initOptions.ChannelName, "channel", "", "The name of the Fabric channel on which the FireFly chaincode has been deployed") initFabricCmd.Flags().StringVar(&initOptions.ChaincodeName, "chaincode", "", "The name given to the FireFly chaincode when it was deployed") + initFabricCmd.Flags().BoolVar(&initOptions.GlobalListener, "global-listener", false, "Configure the blockchain listener to listen for BatchPin events from any chaincode on the channel") initCmd.AddCommand(initFabricCmd) } diff --git a/internal/stacks/stack_manager.go b/internal/stacks/stack_manager.go index fc6c21d3..42fc4835 100644 --- a/internal/stacks/stack_manager.go +++ b/internal/stacks/stack_manager.go @@ -111,6 +111,7 @@ func (s *StackManager) InitStack(options *types.InitOptions) (err error) { IPFSMode: fftypes.FFEnum(options.IPFSMode), ChannelName: options.ChannelName, ChaincodeName: options.ChaincodeName, + GlobalListener: options.GlobalListener, } tokenProviders, err := types.FFEnumArray(s.ctx, options.TokenProviders) @@ -911,6 +912,11 @@ func (s *StackManager) runFirstTimeSetup(options *types.StartOptions) (messages } else { contractLocation = contractDeploymentResult.DeployedContract.Location } + options := make(map[string]interface{}) + if s.Stack.GlobalListener { + options["globalListener"] = true + } + newConfig.Namespaces.Predefined[0].Multiparty = &types.MultipartyConfig{ Enabled: true, Org: orgConfig, @@ -920,6 +926,7 @@ func (s *StackManager) runFirstTimeSetup(options *types.StartOptions) (messages Contract: []*types.ContractConfig{ { Location: contractLocation, + Options: options, }, }, } diff --git a/pkg/types/namespace.go b/pkg/types/namespace.go index ff1f5923..89a80eb5 100644 --- a/pkg/types/namespace.go +++ b/pkg/types/namespace.go @@ -42,6 +42,7 @@ type MultipartyConfig struct { type ContractConfig struct { Location interface{} `yaml:"location"` FirstEvent string `yaml:"firstEvent"` + Options interface{} `yaml:"options"` } type MultipartyOrgConfig struct { diff --git a/pkg/types/options.go b/pkg/types/options.go index 49af5872..efbad3ba 100644 --- a/pkg/types/options.go +++ b/pkg/types/options.go @@ -62,6 +62,7 @@ type InitOptions struct { MSPPaths []string ChannelName string ChaincodeName string + GlobalListener bool } const IPFSMode = "ipfs_mode" diff --git a/pkg/types/stack.go b/pkg/types/stack.go index b19c234e..1ed94c05 100644 --- a/pkg/types/stack.go +++ b/pkg/types/stack.go @@ -48,6 +48,7 @@ type Stack struct { RemoteFabricNetwork bool `json:"remoteFabricNetwork,omitempty"` ChannelName string `json:"channelName,omitempty"` ChaincodeName string `json:"chaincodeName,omitempty"` + GlobalListener bool `json:"globalListener,omitempty"` InitDir string `json:"-"` RuntimeDir string `json:"-"` StackDir string `json:"-"` From 38e4f95c0c757ae87b56affea151cfd32a6104ee Mon Sep 17 00:00:00 2001 From: Andrew Richardson Date: Wed, 29 Mar 2023 11:24:31 -0400 Subject: [PATCH 2/2] Rename "global-listener" to "custom-pin-support" Signed-off-by: Andrew Richardson --- cmd/init_fabric.go | 2 +- internal/stacks/stack_manager.go | 6 +++--- pkg/types/options.go | 2 +- pkg/types/stack.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/init_fabric.go b/cmd/init_fabric.go index 87cb76c7..37d0601d 100644 --- a/cmd/init_fabric.go +++ b/cmd/init_fabric.go @@ -73,6 +73,6 @@ func init() { initFabricCmd.Flags().StringArrayVar(&initOptions.MSPPaths, "msp", nil, "Path to the MSP directory for an org in your Fabric network") initFabricCmd.Flags().StringVar(&initOptions.ChannelName, "channel", "", "The name of the Fabric channel on which the FireFly chaincode has been deployed") initFabricCmd.Flags().StringVar(&initOptions.ChaincodeName, "chaincode", "", "The name given to the FireFly chaincode when it was deployed") - initFabricCmd.Flags().BoolVar(&initOptions.GlobalListener, "global-listener", false, "Configure the blockchain listener to listen for BatchPin events from any chaincode on the channel") + initFabricCmd.Flags().BoolVar(&initOptions.CustomPinSupport, "custom-pin-support", false, "Configure the blockchain listener to listen for BatchPin events from any chaincode on the channel") initCmd.AddCommand(initFabricCmd) } diff --git a/internal/stacks/stack_manager.go b/internal/stacks/stack_manager.go index 42fc4835..c960a7bf 100644 --- a/internal/stacks/stack_manager.go +++ b/internal/stacks/stack_manager.go @@ -111,7 +111,7 @@ func (s *StackManager) InitStack(options *types.InitOptions) (err error) { IPFSMode: fftypes.FFEnum(options.IPFSMode), ChannelName: options.ChannelName, ChaincodeName: options.ChaincodeName, - GlobalListener: options.GlobalListener, + CustomPinSupport: options.CustomPinSupport, } tokenProviders, err := types.FFEnumArray(s.ctx, options.TokenProviders) @@ -913,8 +913,8 @@ func (s *StackManager) runFirstTimeSetup(options *types.StartOptions) (messages contractLocation = contractDeploymentResult.DeployedContract.Location } options := make(map[string]interface{}) - if s.Stack.GlobalListener { - options["globalListener"] = true + if s.Stack.CustomPinSupport { + options["customPinSupport"] = true } newConfig.Namespaces.Predefined[0].Multiparty = &types.MultipartyConfig{ diff --git a/pkg/types/options.go b/pkg/types/options.go index efbad3ba..ca593e42 100644 --- a/pkg/types/options.go +++ b/pkg/types/options.go @@ -62,7 +62,7 @@ type InitOptions struct { MSPPaths []string ChannelName string ChaincodeName string - GlobalListener bool + CustomPinSupport bool } const IPFSMode = "ipfs_mode" diff --git a/pkg/types/stack.go b/pkg/types/stack.go index 1ed94c05..63bfb0db 100644 --- a/pkg/types/stack.go +++ b/pkg/types/stack.go @@ -48,7 +48,7 @@ type Stack struct { RemoteFabricNetwork bool `json:"remoteFabricNetwork,omitempty"` ChannelName string `json:"channelName,omitempty"` ChaincodeName string `json:"chaincodeName,omitempty"` - GlobalListener bool `json:"globalListener,omitempty"` + CustomPinSupport bool `json:"customPinSupport,omitempty"` InitDir string `json:"-"` RuntimeDir string `json:"-"` StackDir string `json:"-"`