Skip to content

Instantly share code, notes, and snippets.

View Deeptiman's full-sized avatar
:octocat:
Open Source

Deeptiman Pattnaik Deeptiman

:octocat:
Open Source
View GitHub Profile
type User struct {
ID string `json:"id"`
Email string `json:"email"`
Name string `json:"name"`
Mobile string `json:"mobile"`
Age string `json:"age"`
}
syntax="proto3";
package main;
message Financial {
string bankName = 1;
string ifscCode = 2;
string accNumber = 3;
string createdDate = 4;
}
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: financial.proto
package main
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
math "math"
)
type User struct {
ID string `json:"id"`
Email string `json:"email"`
Name string `json:"name"`
Mobile string `json:"mobile"`
Age string `json:"age"`
Financial string `json:"financial"`
}
financialByteData, err := proto.Marshal(financialData)
if err != nil {
log.Fatal("marshaling error: ", err)
}
//Parsing the financial byte data
financial := &Financial{}
err = proto.Unmarshal(financialByteData, financial)
if err != nil {
log.Fatal("unmarshaling error: ", err)
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: financial.proto
package main
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
math "math"
)
financial := &Financial {
ID: "F1",
BankName: "Hellenic Bank",
IFSCCode: "1234",
AccNumber: "8765",
CreatedDate : "12/12/08,
}
req := resmgmt.SaveChannelRequest{
ChannelID: "multiorgledger",
ChannelConfigPath: os.os.Getenv("GOPATH")+"/multiorgledger.channel.tx",
SigningIdentities: []msp.SigningIdentity{Org1SignIdentity, Org2SignIdentity, Org3SignIdentity, Org4SignIdentity},
}
txID, err := s.Resmgmt.SaveChannel(
req, resmgmt.WithOrdererEndpoint(Orderer.OrdererID))
if err != nil || txID.TransactionID == "" {
return errors.WithMessage(err, "failed to save anchor channel for - "+s.OrgName)
}
if err := s.Resmgmt.JoinChannel(s.ChannelID,resmgmt.WithRetry(retry.DefaultResMgmtOpts), resmgmt.WithOrdererEndpoint(Orderer.OrdererID)); err != nil {
return errors.WithMessage(err, "failed to make admin join channel")
}
ccPolicy, _ := cauthdsl.FromString(policy) // cauthdsl will convert the policy string to Policy object
resp, err := s.Resmgmt.InstantiateCC(
s.ChannelID,
resmgmt.InstantiateCCRequest{
Name: s.ChaincodeId,
Path: s.ChaincodePath,
Version: s.ChainCodeVersion,
Args: [][]byte{[]byte("init")},
Policy: ccPolicy,