Skip to content

Commit

Permalink
Merge pull request #15 from DataManagementLab/user-study-test
Browse files Browse the repository at this point in the history
Merging with the improved documentation and comments
Kinshuk94 authored May 19, 2023
2 parents 4f358ff + 608de3c commit d41770d
Showing 15 changed files with 219 additions and 243 deletions.
23 changes: 10 additions & 13 deletions BlockchainEnabler/cmd/add.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
Copyright © 2022 Kinshuk Kislay <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -29,15 +29,13 @@ var ordererInfo string
// addCmd represents the add command
var addCmd = &cobra.Command{
Use: "add",
Short: "A brief description of your command",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Short: "Add command is used to add another organization to the network.",
Long: `The add is executed by the actor when it wants to add another organization to the created network.
1. Add is run by organization which invites other org to join its network.
2. It prepares the network to be joined by other organization.
3. Once successfully executed, the invited organization can use the join command to join the network.`,
RunE: func(cmd *cobra.Command, args []string) error {
fmt.Println("Add called")
fmt.Println("Running add command")

invitePlatformManager = enablerplatform.GetInstance(&logger)
// Loads the network configuration for the user.
@@ -46,14 +44,13 @@ to quickly create a Cobra application.`,
}
// Adds the passed organization to the network.
// If multiple organizations, part of the network then it only endorses the transaction.

// fmt.Printf("\n\n Adding the '%s' for user '%s' has been Successfully created.\n", createPlatformManager.Enablers[0].NetworkName, userId)

if err := invitePlatformManager.AddOrganization(useVolume, file); err != nil {
if err := invitePlatformManager.AddOrganization(useVolume, file, userLogging); err != nil {
return err
}



return nil
},
}
4 changes: 2 additions & 2 deletions BlockchainEnabler/cmd/create.go
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ var createCmd = &cobra.Command{
4. Running the containers for the whole -> orderer, ca, peer and other if needed.`,

RunE: func(cmd *cobra.Command, args []string) error {
fmt.Println("create called")
fmt.Println("Running create command")
if err := docker.CheckDockerConfig(); err != nil {
return err
}
@@ -48,7 +48,7 @@ var createCmd = &cobra.Command{
return err
}
// Creates the network for the given User
if err := createPlatformManager.CreateNetwork(useVolume); err != nil {
if err := createPlatformManager.CreateNetwork(useVolume,userLogging); err != nil {
return err
}

18 changes: 8 additions & 10 deletions BlockchainEnabler/cmd/delete.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
Copyright © 2022 Kinshuk Kislay <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -27,22 +27,20 @@ var deletePlatformManager *enablerplatform.EnablerPlatformManager
// deleteCmd represents the delete command
var deleteCmd = &cobra.Command{
Use: "delete",
Short: "A brief description of your command",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Short: "Delete command removes the resources used by the network and deletes the network and the organization.",
Long: `Delete command performs the following steps:
1. Stops the running containers.
2. Removes the resources acquired during this phase.
3. Clear the folders which were used by the organization.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("delete called")
fmt.Println("Running delete command")

deletePlatformManager = enablerplatform.GetInstance(&logger)
// steps to follow the user specifies the name of the platform and then we run its containers.
// it needs to load in the basic file from the directory and initialize it with the values for the network.
// We need to then check which kind of network it is and then we would call the network functions(objects).
deletePlatformManager.LoadUser(networkId, userId)
deletePlatformManager.DeleteNetwork()
deletePlatformManager.DeleteNetwork(userLogging)
},
}

9 changes: 6 additions & 3 deletions BlockchainEnabler/cmd/init.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021 NAME HERE <EMAIL ADDRESS>
Copyright © 2021 Kinshuk Kislay <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -44,7 +44,9 @@ var initCmd = &cobra.Command{
Use: "init",
Short: "This command is for initializing the network",
Long: `The user has to provide the initialization parameters for the network to be initialized
In Initialization Phase these things are taken care o9 1. Creating the yaml and the json files for running the setup.
In Initialization Phase these things are taken care of
1. Creating the yaml and the json files for running the setup.
2. Verification and addition of the identities.
3. Creation of the channel and the basic Block for the Blockchain.
4. The configuration file will be provided at the end of the setup.`,
@@ -100,14 +102,15 @@ var initCmd = &cobra.Command{
}
}
initOptions.BlockchainType, _ = types.BlockchainProviderSelection(selectedBlockchain)
initOptions.UserLogging = userLogging
platformManager = enablerplatform.GetInstance(&logger)
// Initialization of the User Network.
// Initilization of all the components needed to run, which involves the creation of the docker yaml file and other stuff.
// this will only create the docker yaml file wont be responsible for running the network.
if err := platformManager.InitEnablerPlatform(userId, memberCount, &initOptions, localSetup); err != nil {
return nil
}
fmt.Printf("\n\nThe user '%s' has been Successfully initialized. To create the network, run:\n\n go run main.go create -u %s\n\n", userId, userId)
// fmt.Printf("\n\nThe user '%s' has been Successfully initialized. To create the network, run:\n\n go run main.go create -u %s\n\n", userId, userId)
return nil
},
}
17 changes: 8 additions & 9 deletions BlockchainEnabler/cmd/join.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
Copyright © 2022 Kinshuk Kislay <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -32,14 +32,13 @@ var basic bool
var joinCmd = &cobra.Command{
Use: "join",
Short: "Join command adds another organization to the created network.",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Long: `Join command is run by the organization which wants to join the network hosted and created by another organization.
The join command performs the following steps:
1. Uses the zip file containing the network configuration to to join the network.
2. Updates the network to be joined by this new organization.
3. Adds the peers belonging to the organization running join, to become part of the network.`,
RunE: func(cmd *cobra.Command, args []string) error {
fmt.Println("join called")
fmt.Println("Running join command")
// since we now have the name of the org we want to create, first step would be to generate the org file, and then create the definition file for the org.
// Files currently needed
// 1. crypto file to generate the cryptographic files for the org
@@ -54,7 +53,7 @@ to quickly create a Cobra application.`,
return err
}
// logger.Printf(invitePlatformManager.UserId)
if err := joinPlatformManager.JoinNetwork(useVolume, zipFile, basic); err != nil {
if err := joinPlatformManager.JoinNetwork(useVolume, zipFile, basic,userLogging); err != nil {
return err
}
return nil
4 changes: 2 additions & 2 deletions BlockchainEnabler/cmd/leave.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
Copyright © 2022 Kinshuk Kislay <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -33,7 +33,7 @@ var leaveCmd = &cobra.Command{
Use: "leave",
Short: "This command is for leaving the network ",
Long: `This command is used to leave the network.
The user needs to provide the user_name and then the `,
The user needs to provide the user_name and then the other details to leave the existing network. `,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("leave called")
leavePlatformEnabler = enablerplatform.GetInstance(&logger)
5 changes: 4 additions & 1 deletion BlockchainEnabler/cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021 NAME HERE <EMAIL ADDRESS>
Copyright © 2022 Kinshuk Kislay <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@ import (
var cfgFile string
var logger zerolog.Logger = log.Logger
var useVolume bool
var userLogging bool

// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
@@ -61,6 +62,8 @@ func init() {

rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.BlockchainEnabler.yaml)")
rootCmd.PersistentFlags().BoolVarP(&useVolume, "useVolume", "v", false, "Function to enable or disable the use of Volume default: false")
rootCmd.PersistentFlags().BoolVarP(&userLogging, "logging", "l", false, "Function to enable or disable the use of debug Logging")

// Cobra also supports local flags, which will only run
// when this action is called directly.
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
16 changes: 7 additions & 9 deletions BlockchainEnabler/cmd/sign.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
Copyright © 2022 Kinshuk Kislay <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -28,20 +28,18 @@ var update bool
// signCmd represents the sign command
var signCmd = &cobra.Command{
Use: "sign",
Short: "A brief description of your command",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Short: "Sign command is used to sign the transaction by the members of the network to reach consensus.",
Long: `Sign command is run by organization or its peers to endorse a transaction or a change.
There are two options with the sign command,
1. Without update : The peer just endorses the transaction, but does not update the network.
2. With update: The peer endorses the transaction and updates the network, usually done by the last organization to sign a transaction to reach majority of endorsements.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("sign called")

signPlatformManager = enablerplatform.GetInstance(&logger)
signPlatformManager.LoadUser("", userId)
// logger.Printf(invitePlatformManager.UserId)
signPlatformManager.SignOrganization(useVolume, file,update)
signPlatformManager.SignOrganization(useVolume, file,update,userLogging)
},
}

12 changes: 6 additions & 6 deletions BlockchainEnabler/internal/blockchain/blockchainenabler.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package blockchain

type IProvider interface {
Init(string, bool, bool, bool) error
Create(string, bool, bool) error
Join(string, bool, string, bool) error
Init(string, bool, bool, bool, bool) error
Create(string, bool, bool, bool) error
Join(string, bool, string, bool, bool) error
Leave(string, string, string, bool, bool) error
Sign(string, bool, string, bool) error
Add(string, bool, string) error
Delete(string) error
Sign(string, bool, string, bool, bool) error
Add(string, bool, string,bool) error
Delete(string,bool) error

// WriteConfigs() error
// GetDockerServiceDefinitions() []*docker.ServiceDefinition
Loading

0 comments on commit d41770d

Please sign in to comment.