Skip to content
main.go 1.26 KiB
Newer Older
Nikolay Teslya's avatar
Nikolay Teslya committed
package main
import (
	"fmt"
	"github.com/chainHero/heroes-service/blockchain"
	"github.com/chainHero/heroes-service/web"
	"github.com/chainHero/heroes-service/web/controllers"
	"os"
)
func main() {
	// Definition of the fabric SDK properties.
	fSetup := blockchain.FabricSetup{
		// Network parameters
		OrdererID:		"orderer.hf.chainhero.io",
		// Channel parameters
		ChannelID:		"chainhero",
		ChannelConfig:		os.Getenv("GOPATH") + "/src/github.com/chainHero/heroes-service/fixtures/artifacts/chainhero.channel.tx",
		// Chaincode parameters
		ChainCodeID:		"heroes-service",
		ChaincodeGoPath:	os.Getenv("GOPATH"),
		ChaincodePath:		"github.com/chainHero/heroes-service/chaincode/",
		OrgAdmin:		"Admin",
		OrgName:		"org1",
		ConfigFile:		"config.yaml",
		// User parameters
		UserName:		"User1",
	}
	// Initializaton of the Fabric SDK from the previously set properties
	err := fSetup.Initialize()
	if err != nil {
		fmt.Printf("Unable to initialize the Fabric SDK: %v\n", err)
		return
	}
	err = fSetup.InstallAndInstantiateCC()
	if err != nil {
		fmt.Printf("Unable to install and instantiate the chaincode: %v\n", err)
		return
	}
	// Close SDK
	defer fSetup.CloseSDK()
	// Launch the web application listening
	app := &controllers.Application{
		Fabric: &fSetup,
	}
	web.Serve(app)
}