From 89d21dfcbd954d699aad52d31368d67e63e8d2c0 Mon Sep 17 00:00:00 2001 From: Matthew Whitehead Date: Wed, 5 Jul 2023 13:14:48 +0100 Subject: [PATCH] Add an option '--remote-node-deploy' to treat remote nodes like local nodes Signed-off-by: Matthew Whitehead --- cmd/init.go | 3 ++- .../blockchain/ethereum/remoterpc/remoterpc_provider.go | 9 ++++++++- internal/stacks/stack_manager.go | 1 + pkg/types/options.go | 3 ++- pkg/types/stack.go | 3 ++- 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/cmd/init.go b/cmd/init.go index 6feb3a20..b49b2cf1 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -1,4 +1,4 @@ -// Copyright © 2021 Kaleido, Inc. +// Copyright © 2023 Kaleido, Inc. // // SPDX-License-Identifier: Apache-2.0 // @@ -263,5 +263,6 @@ func init() { initCmd.PersistentFlags().StringVar(&initOptions.IPFSMode, "ipfs-mode", "private", fmt.Sprintf("Set the mode in which IFPS operates. Options are: %v", fftypes.FFEnumValues(types.IPFSMode))) initCmd.PersistentFlags().StringArrayVar(&initOptions.OrgNames, "org-name", []string{}, "Organization name") initCmd.PersistentFlags().StringArrayVar(&initOptions.NodeNames, "node-name", []string{}, "Node name") + initCmd.PersistentFlags().BoolVar(&initOptions.RemoteNodeDeploy, "remote-node-deploy", false, "Enable or disable deployment of FireFly contracts on remote nodes") rootCmd.AddCommand(initCmd) } diff --git a/internal/blockchain/ethereum/remoterpc/remoterpc_provider.go b/internal/blockchain/ethereum/remoterpc/remoterpc_provider.go index 244a6ecd..254189c6 100644 --- a/internal/blockchain/ethereum/remoterpc/remoterpc_provider.go +++ b/internal/blockchain/ethereum/remoterpc/remoterpc_provider.go @@ -1,4 +1,4 @@ -// Copyright © 2022 Kaleido, Inc. +// Copyright © 2023 Kaleido, Inc. // // SPDX-License-Identifier: Apache-2.0 // @@ -94,6 +94,13 @@ func (p *RemoteRPCProvider) PostStart(fistTimeSetup bool) error { } func (p *RemoteRPCProvider) DeployFireFlyContract() (*types.ContractDeploymentResult, error) { + if p.stack.RemoteNodeDeploy { + contract, err := ethereum.ReadFireFlyContract(p.ctx, p.stack) + if err != nil { + return nil, err + } + return p.connector.DeployContract(contract, "FireFly", p.stack.Members[0], nil) + } return nil, fmt.Errorf("you must pre-deploy your FireFly contract when using a remote RPC endpoint") } diff --git a/internal/stacks/stack_manager.go b/internal/stacks/stack_manager.go index d80e27e8..8a864e75 100644 --- a/internal/stacks/stack_manager.go +++ b/internal/stacks/stack_manager.go @@ -112,6 +112,7 @@ func (s *StackManager) InitStack(options *types.InitOptions) (err error) { ChannelName: options.ChannelName, ChaincodeName: options.ChaincodeName, CustomPinSupport: options.CustomPinSupport, + RemoteNodeDeploy: options.RemoteNodeDeploy, } tokenProviders, err := types.FFEnumArray(s.ctx, options.TokenProviders) diff --git a/pkg/types/options.go b/pkg/types/options.go index ca593e42..a33bdfe4 100644 --- a/pkg/types/options.go +++ b/pkg/types/options.go @@ -1,4 +1,4 @@ -// Copyright © 2022 Kaleido, Inc. +// Copyright © 2023 Kaleido, Inc. // // SPDX-License-Identifier: Apache-2.0 // @@ -63,6 +63,7 @@ type InitOptions struct { ChannelName string ChaincodeName string CustomPinSupport bool + RemoteNodeDeploy bool } const IPFSMode = "ipfs_mode" diff --git a/pkg/types/stack.go b/pkg/types/stack.go index 63bfb0db..5163ae34 100644 --- a/pkg/types/stack.go +++ b/pkg/types/stack.go @@ -1,4 +1,4 @@ -// Copyright © 2021 Kaleido, Inc. +// Copyright © 2023 Kaleido, Inc. // // SPDX-License-Identifier: Apache-2.0 // @@ -49,6 +49,7 @@ type Stack struct { ChannelName string `json:"channelName,omitempty"` ChaincodeName string `json:"chaincodeName,omitempty"` CustomPinSupport bool `json:"customPinSupport,omitempty"` + RemoteNodeDeploy bool `json:"remoteNodeDeploy,omitempty"` InitDir string `json:"-"` RuntimeDir string `json:"-"` StackDir string `json:"-"`