Skip to content

Commit

Permalink
Add an option '--remote-node-deploy' to treat remote nodes like local…
Browse files Browse the repository at this point in the history
… nodes

Signed-off-by: Matthew Whitehead <[email protected]>
  • Loading branch information
matthew1001 committed Jul 5, 2023
1 parent 6246b18 commit 65d36b1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion cmd/init.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2021 Kaleido, Inc.
// Copyright © 2023 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down Expand Up @@ -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)
}
9 changes: 8 additions & 1 deletion internal/blockchain/ethereum/remoterpc/remoterpc_provider.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2022 Kaleido, Inc.
// Copyright © 2023 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down Expand Up @@ -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")
}

Expand Down
1 change: 1 addition & 0 deletions internal/stacks/stack_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion pkg/types/options.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2022 Kaleido, Inc.
// Copyright © 2023 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down Expand Up @@ -63,6 +63,7 @@ type InitOptions struct {
ChannelName string
ChaincodeName string
CustomPinSupport bool
RemoteNodeDeploy bool
}

const IPFSMode = "ipfs_mode"
Expand Down
3 changes: 2 additions & 1 deletion pkg/types/stack.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2021 Kaleido, Inc.
// Copyright © 2023 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down Expand Up @@ -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:"-"`
Expand Down

0 comments on commit 65d36b1

Please sign in to comment.