LiangZhaoSongsandcu
Created March 3, 2022

The Raft Consensus Algorithm on C1100

An RTL kernel to accelerate the Hyperledger fabric. FPGA parallelized implementation of the blockchain's consensus algorithm RAFT.

26
The Raft Consensus Algorithm on C1100

Things used in this project

Story

Read more

Schematics

RTL schematic

RAFT RTL kernel

Code

RTL KENEL

Verilog
RAFT
No preview (download only).

Fabric

Go
hyperledger fabric
package main

import (
	"fmt"
	"fabric-go-sdk/sdkInit"
	"os"
)

const (
	cc_name = "simplecc"
	cc_version = "1.0.0"
)

var App sdkInit.Application
func main() {
	// init orgs information

	orgs := []*sdkInit.OrgInfo{
		{
			OrgAdminUser:  "Admin",
			OrgName:       "Org1",
			OrgMspId:      "Org1MSP",
			OrgUser:       "User1",
			OrgPeerNum:    2,
			OrgAnchorFile: "/root/go/src/fabric-go-sdk/fixtures/channel-artifacts/Org1MSPanchors.tx",
		},
	}

	// init sdk env info
	info := sdkInit.SdkEnvInfo{
		ChannelID:        "mychannel",
		ChannelConfig:    "/root/go/src/fabric-go-sdk/fixtures/channel-artifacts/channel.tx",
		Orgs:             orgs,
		OrdererAdminUser: "Admin",
		OrdererOrgName:   "OrdererOrg",
		OrdererEndpoint:  "orderer.example.com",
		ChaincodeID:      cc_name,
		ChaincodePath:    "/root/go/src/fabric-go-sdk/chaincode/",
		ChaincodeVersion: cc_version,
	}

	// sdk setup
	sdk, err := sdkInit.Setup("config.yaml", &info)
	if err != nil {
		fmt.Println(">> SDK setup error:", err)
		os.Exit(-1)
	}

	// create channel and join
	if err := sdkInit.CreateAndJoinChannel(&info); err != nil {
		fmt.Println(">> Create channel and join error:", err)
		os.Exit(-1)
	}

	// create chaincode lifecycle
	if err := sdkInit.CreateCCLifecycle(&info, 1, false, sdk); err != nil {
		fmt.Println(">> create chaincode lifecycle error: %v", err)
		os.Exit(-1)
	}

	// invoke chaincode set status
	fmt.Println(">> ......")

	if err := info.InitService(info.ChaincodeID, info.ChannelID, info.Orgs[0], sdk);err != nil{

		fmt.Println("InitService successful")
		os.Exit(-1)
	}

	App=sdkInit.Application{
		SdkEnvInfo: &info,
	}
	fmt.Println(">> ")

	a:=[]string{"set","ID","123"}
	ret, err := App.Set(a)
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println("<--- --->", ret)


	b := []string{"get","ID"}
	response, err := App.Get(b)
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println("<--- --->", response)

}

Credits

Liang

Liang

1 project • 1 follower
ZhaoSong

ZhaoSong

0 projects • 2 followers
sandcu

sandcu

0 projects • 1 follower

Comments