utils

package
v0.0.0-...-d315ddc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2022 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertBytestoString

func ConvertBytestoString(data [][]byte) []string

ConvertBytestoString converts [][]byte to []string

func GetArgs

func GetArgs(args []string) [][]byte

GetArgs get [][]byte args from string array

func GetRegisteredUser

func GetRegisteredUser(username, orgName, secret, identityTypeUser string, sdk *fabsdk.FabricSDK) (string, bool)

GetRegisteredUser get registered user. If user is not enrolled, enroll new user

func Prettyprint

func Prettyprint(b []byte) ([]byte, error)

Prettyprint print json

Types

type Block

type Block struct {
	Header                *cb.BlockHeader     `json:"header,omitempty"`
	Transactions          []*Transaction      `json:"transactions,omitempty"`
	BlockCreatorSignature *SignatureMetadata  `json:"block_creator_signature,omitempty"`
	LastConfigBlockNumber *LastConfigMetadata `json:"last_config_block_number,omitempty"`
	TransactionFilter     []uint8             `json:"transaction_filter,omitempty"`
	OrdererKafkaMetadata  *OrdererMetadata    `json:"orderer_kafka_metadata,omitempty"`
}

Block Block in json format

type ChaincodeInput

type ChaincodeInput struct {
	Args []string
}

ChaincodeInput ChaincodeInput in json format

type ChaincodeSpec

type ChaincodeSpec struct {
	Type        pb.ChaincodeSpec_Type `json:"type,omitempty"`
	ChaincodeID *pb.ChaincodeID       `json:"chaincode_id,omitempty"`
	Input       *ChaincodeInput       `json:"input,omitempty"`
	Timeout     int32                 `json:"timeout,omitempty"`
}

ChaincodeSpec ChaincodeSpec in json format

type ChannelHeader

type ChannelHeader struct {
	Type        int32                      `json:"type,omitempty"`
	Version     int32                      `json:"version,omitempty"`
	Timestamp   *google_protobuf.Timestamp `json:"timestamp,omitempty"`
	ChannelID   string                     `json:"channel_id,omitempty"`
	TxID        string                     `json:"tx_id,omitempty"`
	Epoch       uint64                     `json:"epoch,omitempty"`
	ChaincodeID *pb.ChaincodeID            `json:"chaincode_id,omitempty"`
}

ChannelHeader ChannelHeader in json format

type Endorsement

type Endorsement struct {
	SignatureHeader *SignatureHeader `json:"signature_header,omitempty"`
	Signature       []byte           `json:"signature,omitempty"`
}

Endorsement Endorsement in json format

type FabricSetup

type FabricSetup struct {
	AdminUser         string
	OrdererOrgName    string
	ConfigFileName    string
	Secret            []byte
	IdentityTypeUser  string
	Sdk               *fabsdk.FabricSDK
	RegistrarUsername string
	RegistrarPassword string
	ChannelID         string
	Identity          msp.Identity
	Targets           []string
}

FabricSetup struct

func (*FabricSetup) CreateChannel

func (hfc *FabricSetup) CreateChannel(user string, orgname string, channel string, filepath string) []byte

CreateChannel creates the channel

func (*FabricSetup) Init

func (hfc *FabricSetup) Init()

Init reads config file, setup client, CA

func (*FabricSetup) InstallChainCode

func (hfc *FabricSetup) InstallChainCode(peers string, chainCodeName string, chainCodePath string, chainCodeType string, chainCodeVersion string, orgname string, goPath string) []byte

InstallChainCode install chain codes on peers with the called Organization

func (*FabricSetup) InstantiateChainCode

func (hfc *FabricSetup) InstantiateChainCode(user string, orgName string, channelName string, chainCodeName string, chainCodePath string, chainCodeVersion string, args [][]byte) []byte

InstantiateChainCode instantiates the installed chaincode on the network

func (*FabricSetup) InvokeChainCode

func (hfc *FabricSetup) InvokeChainCode(channelName, chainCodeID, username string, orgName string, fcn string, args [][]byte, endpoints []string) []byte

InvokeChainCode invokes add, delete operations on the chaincode for transactions

func (*FabricSetup) JoinChannel

func (hfc *FabricSetup) JoinChannel(channelName string, peer string, orgname string) []byte

JoinChannel joins peer(s) to a channel

func (*FabricSetup) QueryBlockByID

func (hfc *FabricSetup) QueryBlockByID(channelName string, username string, orgName string, endpoint string, blockID uint64) []byte

QueryBlockByID queries blocks based on input ID

func (*FabricSetup) QueryBlockHeight

func (hfc *FabricSetup) QueryBlockHeight(channelName string, username string, orgName string, endpoint string) []byte

QueryBlockHeight queries the blocks on ledger

func (*FabricSetup) QueryChainCode

func (hfc *FabricSetup) QueryChainCode(channelName string, chainCodeID string, username string, orgName string, fcn string, args [][]byte, endpoint string) []byte

QueryChainCode queries the chaincode for current balances

type LastConfigMetadata

type LastConfigMetadata struct {
	LastConfigBlockNum uint64             `json:"last_config_block_num,omitempty"`
	SignatureData      *SignatureMetadata `json:"signature_data,omitempty"`
}

LastConfigMetadata LastConfigMetadata in json format

type NsReadWriteSet

type NsReadWriteSet struct {
	Namespace string           `json: "namespace,omitempty"`
	KVRWSet   *kvrwset.KVRWSet `json: "kVRWSet,omitempty"`
}

NsReadWriteSet NsReadWriteSet in json format

type OrdererMetadata

type OrdererMetadata struct {
	LastOffsetPersisted uint64             `json:"last_offset_persisted,omitempty"`
	SignatureData       *SignatureMetadata `json:"signature_data,omitempty"`
}

OrdererMetadata OrdererMetadata in json format

type SignatureHeader

type SignatureHeader struct {
	Certificate *x509.Certificate
	Nonce       []byte `json:"nonce,omitempty"`
}

SignatureHeader SignatureHeader in json format

type SignatureMetadata

type SignatureMetadata struct {
	SignatureHeader *SignatureHeader `json:"signature_header,omitempty"`
	Signature       []byte           `json:"signature,omitempty"`
}

SignatureMetadata SignatureMetadata in json format

type Transaction

type Transaction struct {
	Signature               []byte             `json:"signature,omitempty"`
	ChannelHeader           *ChannelHeader     `json:"channel_header,omitempty"`
	SignatureHeader         *SignatureHeader   `json:"signature_header,omitempty"`
	TxActionSignatureHeader *SignatureHeader   `json:"tx_action_signature_header,omitempty"`
	ChaincodeSpec           *ChaincodeSpec     `json:"chaincode_spec,omitempty"`
	Endorsements            []*Endorsement     `json:"endorsements,omitempty"`
	ProposalHash            []byte             `json:"proposal_hash,omitempty"`
	Events                  *pb.ChaincodeEvent `json:"events,omitempty"`
	Response                *pb.Response       `json:"response,omitempty"`
	NsRwset                 []*NsReadWriteSet  `json:"ns_read_write_Set,omitempty"`
	// Capture transaction validation code
	ValidationCode     uint8  `json:"validation_code"`
	ValidationCodeName string `json:"validation_code_name,omitempty"`
}

Transaction Transaction in json format

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL