fabric-sdk-go: github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/protoutil Index | Files

package protoutil

import "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/protoutil"

Index

Package Files

blockutils.go commonutils.go configtxutils.go proputils.go signeddata.go txutils.go unmarshalers.go

func BlockDataHash Uses

func BlockDataHash(b *cb.BlockData) []byte

func BlockHeaderBytes Uses

func BlockHeaderBytes(b *cb.BlockHeader) []byte

func BlockHeaderHash Uses

func BlockHeaderHash(b *cb.BlockHeader) []byte

func ChannelHeader Uses

func ChannelHeader(env *cb.Envelope) (*cb.ChannelHeader, error)

ChannelHeader returns the *cb.ChannelHeader for a given *cb.Envelope.

func ChannelID Uses

func ChannelID(env *cb.Envelope) (string, error)

ChannelID returns the Channel ID for a given *cb.Envelope.

func CheckTxID Uses

func CheckTxID(txid string, nonce, creator []byte) error

CheckTxID checks that txid is equal to the Hash computed over the concatenation of nonce and creator.

func ComputeTxID Uses

func ComputeTxID(nonce, creator []byte) string

ComputeTxID computes TxID as the Hash computed over the concatenation of nonce and creator.

func CopyBlockMetadata Uses

func CopyBlockMetadata(src *cb.Block, dst *cb.Block)

CopyBlockMetadata copies metadata from one block into another

func CreateChaincodeProposal Uses

func CreateChaincodeProposal(typ common.HeaderType, chainID string, cis *peer.ChaincodeInvocationSpec, creator []byte) (*peer.Proposal, string, error)

CreateChaincodeProposal creates a proposal from given input. It returns the proposal and the transaction id associated to the proposal

func CreateChaincodeProposalWithTransient Uses

func CreateChaincodeProposalWithTransient(typ common.HeaderType, chainID string, cis *peer.ChaincodeInvocationSpec, creator []byte, transientMap map[string][]byte) (*peer.Proposal, string, error)

CreateChaincodeProposalWithTransient creates a proposal from given input It returns the proposal and the transaction id associated to the proposal

func CreateChaincodeProposalWithTxIDAndTransient Uses

func CreateChaincodeProposalWithTxIDAndTransient(typ common.HeaderType, chainID string, cis *peer.ChaincodeInvocationSpec, creator []byte, txid string, transientMap map[string][]byte) (*peer.Proposal, string, error)

CreateChaincodeProposalWithTxIDAndTransient creates a proposal from given input. It returns the proposal and the transaction id associated with the proposal

func CreateChaincodeProposalWithTxIDNonceAndTransient Uses

func CreateChaincodeProposalWithTxIDNonceAndTransient(txid string, typ common.HeaderType, chainID string, cis *peer.ChaincodeInvocationSpec, nonce, creator []byte, transientMap map[string][]byte) (*peer.Proposal, string, error)

CreateChaincodeProposalWithTxIDNonceAndTransient creates a proposal from given input

func CreateDeployProposalFromCDS Uses

func CreateDeployProposalFromCDS(
    chainID string,
    cds *peer.ChaincodeDeploymentSpec,
    creator []byte,
    policy []byte,
    escc []byte,
    vscc []byte,
    collectionConfig []byte) (*peer.Proposal, string, error)

CreateDeployProposalFromCDS returns a deploy proposal given a serialized identity and a ChaincodeDeploymentSpec

func CreateGetChaincodesProposal Uses

func CreateGetChaincodesProposal(chainID string, creator []byte) (*peer.Proposal, string, error)

CreateGetChaincodesProposal returns a GETCHAINCODES proposal given a serialized identity

func CreateGetInstalledChaincodesProposal Uses

func CreateGetInstalledChaincodesProposal(creator []byte) (*peer.Proposal, string, error)

CreateGetInstalledChaincodesProposal returns a GETINSTALLEDCHAINCODES proposal given a serialized identity

func CreateInstallProposalFromCDS Uses

func CreateInstallProposalFromCDS(ccpack proto.Message, creator []byte) (*peer.Proposal, string, error)

CreateInstallProposalFromCDS returns a install proposal given a serialized identity and a ChaincodeDeploymentSpec

func CreateNonce Uses

func CreateNonce() ([]byte, error)

CreateNonce generates a nonce using the common/crypto package.

func CreateNonceOrPanic Uses

func CreateNonceOrPanic() []byte

CreateNonceOrPanic generates a nonce using the common/crypto package and panics if this operation fails.

func CreateProposalFromCIS Uses

func CreateProposalFromCIS(typ common.HeaderType, chainID string, cis *peer.ChaincodeInvocationSpec, creator []byte) (*peer.Proposal, string, error)

CreateProposalFromCIS returns a proposal given a serialized identity and a ChaincodeInvocationSpec

func CreateProposalFromCISAndTxid Uses

func CreateProposalFromCISAndTxid(txid string, typ common.HeaderType, chainID string, cis *peer.ChaincodeInvocationSpec, creator []byte) (*peer.Proposal, string, error)

CreateProposalFromCISAndTxid returns a proposal given a serialized identity and a ChaincodeInvocationSpec

func CreateProposalResponse Uses

func CreateProposalResponse(
    hdrbytes []byte,
    payl []byte,
    response *peer.Response,
    results []byte,
    events []byte,
    ccid *peer.ChaincodeID,
    signingEndorser identity.SignerSerializer,
) (*peer.ProposalResponse, error)

CreateProposalResponse creates a proposal response.

func CreateProposalResponseFailure Uses

func CreateProposalResponseFailure(
    hdrbytes []byte,
    payl []byte,
    response *peer.Response,
    results []byte,
    events []byte,
    chaincodeName string,
) (*peer.ProposalResponse, error)

CreateProposalResponseFailure creates a proposal response for cases where endorsement proposal fails either due to a endorsement failure or a chaincode failure (chaincode response status >= shim.ERRORTHRESHOLD)

func CreateSignedEnvelope Uses

func CreateSignedEnvelope(
    txType common.HeaderType,
    channelID string,
    signer identity.SignerSerializer,
    dataMsg proto.Message,
    msgVersion int32,
    epoch uint64,
) (*common.Envelope, error)

CreateSignedEnvelope creates a signed envelope of the desired type, with marshaled dataMsg and signs it

func CreateSignedEnvelopeWithTLSBinding Uses

func CreateSignedEnvelopeWithTLSBinding(
    txType common.HeaderType,
    channelID string,
    signer identity.SignerSerializer,
    dataMsg proto.Message,
    msgVersion int32,
    epoch uint64,
    tlsCertHash []byte,
) (*common.Envelope, error)

CreateSignedEnvelopeWithTLSBinding creates a signed envelope of the desired type, with marshaled dataMsg and signs it. It also includes a TLS cert hash into the channel header

func CreateSignedTx Uses

func CreateSignedTx(
    proposal *peer.Proposal,
    signer Signer,
    resps ...*peer.ProposalResponse,
) (*common.Envelope, error)

CreateSignedTx assembles an Envelope message from proposal, endorsements, and a signer. This function should be called by a client when it has collected enough endorsements for a proposal to create a transaction and submit it to peers for ordering

func CreateUpgradeProposalFromCDS Uses

func CreateUpgradeProposalFromCDS(
    chainID string,
    cds *peer.ChaincodeDeploymentSpec,
    creator []byte,
    policy []byte,
    escc []byte,
    vscc []byte,
    collectionConfig []byte) (*peer.Proposal, string, error)

CreateUpgradeProposalFromCDS returns a upgrade proposal given a serialized identity and a ChaincodeDeploymentSpec

func EnvelopeToConfigUpdate Uses

func EnvelopeToConfigUpdate(configtx *cb.Envelope) (*cb.ConfigUpdateEnvelope, error)

EnvelopeToConfigUpdate is used to extract a ConfigUpdateEnvelope from an envelope of type CONFIG_UPDATE

func ExtractEnvelope Uses

func ExtractEnvelope(block *cb.Block, index int) (*cb.Envelope, error)

ExtractEnvelope retrieves the requested envelope from a given block and unmarshals it

func ExtractEnvelopeOrPanic Uses

func ExtractEnvelopeOrPanic(block *cb.Block, index int) *cb.Envelope

ExtractEnvelopeOrPanic retrieves the requested envelope from a given block and unmarshals it -- it panics if either of these operations fail

func GetActionFromEnvelope Uses

func GetActionFromEnvelope(envBytes []byte) (*peer.ChaincodeAction, error)

GetActionFromEnvelope extracts a ChaincodeAction message from a serialized Envelope TODO: fix function name as per FAB-11831

func GetActionFromEnvelopeMsg Uses

func GetActionFromEnvelopeMsg(env *common.Envelope) (*peer.ChaincodeAction, error)

func GetBytesChaincodeActionPayload Uses

func GetBytesChaincodeActionPayload(cap *peer.ChaincodeActionPayload) ([]byte, error)

GetBytesChaincodeActionPayload get the bytes of ChaincodeActionPayload from the message

func GetBytesChaincodeEvent Uses

func GetBytesChaincodeEvent(event *peer.ChaincodeEvent) ([]byte, error)

GetBytesChaincodeEvent gets the bytes of ChaincodeEvent

func GetBytesChaincodeProposalPayload Uses

func GetBytesChaincodeProposalPayload(cpp *peer.ChaincodeProposalPayload) ([]byte, error)

GetBytesChaincodeProposalPayload gets the chaincode proposal payload

func GetBytesEnvelope Uses

func GetBytesEnvelope(env *common.Envelope) ([]byte, error)

GetBytesEnvelope get the bytes of Envelope from the message

func GetBytesHeader Uses

func GetBytesHeader(hdr *common.Header) ([]byte, error)

GetBytesHeader get the bytes of Header from the message

func GetBytesPayload Uses

func GetBytesPayload(payl *common.Payload) ([]byte, error)

GetBytesPayload get the bytes of Payload from the message

func GetBytesProposalPayloadForTx Uses

func GetBytesProposalPayloadForTx(
    payload *peer.ChaincodeProposalPayload,
) ([]byte, error)

GetBytesProposalPayloadForTx takes a ChaincodeProposalPayload and returns its serialized version according to the visibility field

func GetBytesProposalResponse Uses

func GetBytesProposalResponse(pr *peer.ProposalResponse) ([]byte, error)

GetBytesProposalResponse gets proposal bytes response

func GetBytesProposalResponsePayload Uses

func GetBytesProposalResponsePayload(hash []byte, response *peer.Response, result []byte, event []byte, ccid *peer.ChaincodeID) ([]byte, error)

GetBytesProposalResponsePayload gets proposal response payload

func GetBytesResponse Uses

func GetBytesResponse(res *peer.Response) ([]byte, error)

GetBytesResponse gets the bytes of Response

func GetBytesSignatureHeader Uses

func GetBytesSignatureHeader(hdr *common.SignatureHeader) ([]byte, error)

GetBytesSignatureHeader get the bytes of SignatureHeader from the message

func GetBytesTransaction Uses

func GetBytesTransaction(tx *peer.Transaction) ([]byte, error)

GetBytesTransaction get the bytes of Transaction from the message

func GetChainIDFromBlock Uses

func GetChainIDFromBlock(block *cb.Block) (string, error)

GetChainIDFromBlock returns chain ID in the block

func GetChainIDFromBlockBytes Uses

func GetChainIDFromBlockBytes(bytes []byte) (string, error)

GetChainIDFromBlockBytes returns chain ID given byte array which represents the block

func GetConsenterMetadataFromBlock Uses

func GetConsenterMetadataFromBlock(block *cb.Block) (*cb.Metadata, error)

GetConsenterMetadataFromBlock attempts to retrieve consenter metadata from the value stored in block metadata at index SIGNATURES (first field). If no consenter metadata is found there, it falls back to index ORDERER (third field).

func GetEnvelopeFromBlock Uses

func GetEnvelopeFromBlock(data []byte) (*common.Envelope, error)

GetEnvelopeFromBlock gets an envelope from a block's Data field.

func GetLastConfigIndexFromBlock Uses

func GetLastConfigIndexFromBlock(block *cb.Block) (uint64, error)

GetLastConfigIndexFromBlock retrieves the index of the last config block as encoded in the block metadata

func GetLastConfigIndexFromBlockOrPanic Uses

func GetLastConfigIndexFromBlockOrPanic(block *cb.Block) uint64

GetLastConfigIndexFromBlockOrPanic retrieves the index of the last config block as encoded in the block metadata, or panics on error

func GetMetadataFromBlock Uses

func GetMetadataFromBlock(block *cb.Block, index cb.BlockMetadataIndex) (*cb.Metadata, error)

GetMetadataFromBlock retrieves metadata at the specified index.

func GetMetadataFromBlockOrPanic Uses

func GetMetadataFromBlockOrPanic(block *cb.Block, index cb.BlockMetadataIndex) *cb.Metadata

GetMetadataFromBlockOrPanic retrieves metadata at the specified index, or panics on error

func GetOrComputeTxIDFromEnvelope Uses

func GetOrComputeTxIDFromEnvelope(txEnvelopBytes []byte) (string, error)

GetOrComputeTxIDFromEnvelope gets the txID present in a given transaction envelope. If the txID is empty, it constructs the txID from nonce and creator fields in the envelope.

func GetPayloads Uses

func GetPayloads(txActions *peer.TransactionAction) (*peer.ChaincodeActionPayload, *peer.ChaincodeAction, error)

GetPayloads gets the underlying payload objects in a TransactionAction

func GetProposalHash1 Uses

func GetProposalHash1(header *common.Header, ccPropPayl []byte) ([]byte, error)

GetProposalHash1 gets the proposal hash bytes after sanitizing the chaincode proposal payload according to the rules of visibility

func GetProposalHash2 Uses

func GetProposalHash2(header *common.Header, ccPropPayl []byte) ([]byte, error)

GetProposalHash2 gets the proposal hash - this version is called by the committer where the visibility policy has already been enforced and so we already get what we have to get in ccPropPayl

func GetSignedProposal Uses

func GetSignedProposal(prop *peer.Proposal, signer identity.SignerSerializer) (*peer.SignedProposal, error)

GetSignedProposal returns a signed proposal given a Proposal message and a signing identity

func InitBlockMetadata Uses

func InitBlockMetadata(block *cb.Block)

InitBlockMetadata initializes metadata structure

func IsConfigBlock Uses

func IsConfigBlock(block *cb.Block) bool

IsConfigBlock validates whenever given block contains configuration update transaction

func MakeChannelHeader Uses

func MakeChannelHeader(headerType cb.HeaderType, version int32, chainID string, epoch uint64) *cb.ChannelHeader

MakeChannelHeader creates a ChannelHeader.

func MakePayloadHeader Uses

func MakePayloadHeader(ch *cb.ChannelHeader, sh *cb.SignatureHeader) *cb.Header

MakePayloadHeader creates a Payload Header.

func MakeSignatureHeader Uses

func MakeSignatureHeader(serializedCreatorCertChain []byte, nonce []byte) *cb.SignatureHeader

MakeSignatureHeader creates a SignatureHeader.

func Marshal Uses

func Marshal(pb proto.Message) ([]byte, error)

Marshal serializes a protobuf message.

func MarshalOrPanic Uses

func MarshalOrPanic(pb proto.Message) []byte

MarshalOrPanic serializes a protobuf message and panics if this operation fails

func MockSignedEndorserProposal2OrPanic Uses

func MockSignedEndorserProposal2OrPanic(
    chainID string,
    cs *peer.ChaincodeSpec,
    signer identity.SignerSerializer,
) (*peer.SignedProposal, *peer.Proposal)

func MockSignedEndorserProposalOrPanic Uses

func MockSignedEndorserProposalOrPanic(
    chainID string,
    cs *peer.ChaincodeSpec,
    creator,
    signature []byte,
) (*peer.SignedProposal, *peer.Proposal)

MockSignedEndorserProposalOrPanic creates a SignedProposal with the passed arguments

func NewBlock Uses

func NewBlock(seqNum uint64, previousHash []byte) *cb.Block

NewBlock constructs a block with no data and no metadata.

func NewConfigGroup Uses

func NewConfigGroup() *common.ConfigGroup

func NewSignatureHeader Uses

func NewSignatureHeader(id identity.Serializer) (*cb.SignatureHeader, error)

NewSignatureHeader returns a SignatureHeader with a valid nonce.

func NewSignatureHeaderOrPanic Uses

func NewSignatureHeaderOrPanic(id identity.Serializer) *cb.SignatureHeader

NewSignatureHeaderOrPanic returns a signature header and panics on error.

func SetTxID Uses

func SetTxID(channelHeader *cb.ChannelHeader, signatureHeader *cb.SignatureHeader)

SetTxID generates a transaction id based on the provided signature header and sets the TxId field in the channel header

func SignOrPanic Uses

func SignOrPanic(signer identity.Signer, msg []byte) []byte

SignOrPanic signs a message and panics on error.

func UnmarshalBlock Uses

func UnmarshalBlock(encoded []byte) (*cb.Block, error)

UnmarshalBlock unmarshals bytes to a Block

func UnmarshalBlockOrPanic Uses

func UnmarshalBlockOrPanic(encoded []byte) *cb.Block

UnmarshalBlockOrPanic unmarshals bytes to an Block or panics on error

func UnmarshalChaincodeAction Uses

func UnmarshalChaincodeAction(caBytes []byte) (*peer.ChaincodeAction, error)

UnmarshalChaincodeAction unmarshals bytes to a ChaincodeAction

func UnmarshalChaincodeActionPayload Uses

func UnmarshalChaincodeActionPayload(capBytes []byte) (*peer.ChaincodeActionPayload, error)

UnmarshalChaincodeActionPayload unmarshals bytes to a ChaincodeActionPayload

func UnmarshalChaincodeDeploymentSpec Uses

func UnmarshalChaincodeDeploymentSpec(code []byte) (*peer.ChaincodeDeploymentSpec, error)

UnmarshalChaincodeDeploymentSpec unmarshals bytes to a ChaincodeDeploymentSpec

func UnmarshalChaincodeEvents Uses

func UnmarshalChaincodeEvents(eBytes []byte) (*peer.ChaincodeEvent, error)

UnmarshalChaincodeEvents unmarshals bytes to a ChaincodeEvent

func UnmarshalChaincodeHeaderExtension Uses

func UnmarshalChaincodeHeaderExtension(hdrExtension []byte) (*peer.ChaincodeHeaderExtension, error)

UnmarshalChaincodeHeaderExtension unmarshals bytes to a ChaincodeHeaderExtension

func UnmarshalChaincodeID Uses

func UnmarshalChaincodeID(bytes []byte) (*peer.ChaincodeID, error)

UnmarshalChaincodeID unmarshals bytes to a ChaincodeID

func UnmarshalChaincodeInvocationSpec Uses

func UnmarshalChaincodeInvocationSpec(encoded []byte) (*peer.ChaincodeInvocationSpec, error)

UnmarshalChaincodeInvocationSpec unmarshals bytes to a ChaincodeInvocationSpec

func UnmarshalChaincodeProposalPayload Uses

func UnmarshalChaincodeProposalPayload(bytes []byte) (*peer.ChaincodeProposalPayload, error)

UnmarshalChaincodeProposalPayload unmarshals bytes to a ChaincodeProposalPayload

func UnmarshalChannelHeader Uses

func UnmarshalChannelHeader(bytes []byte) (*cb.ChannelHeader, error)

UnmarshalChannelHeader unmarshals bytes to a ChannelHeader

func UnmarshalChannelHeaderOrPanic Uses

func UnmarshalChannelHeaderOrPanic(bytes []byte) *cb.ChannelHeader

UnmarshalChannelHeaderOrPanic unmarshals bytes to a ChannelHeader or panics on error

func UnmarshalEnvelope Uses

func UnmarshalEnvelope(encoded []byte) (*cb.Envelope, error)

UnmarshalEnvelope unmarshals bytes to a Envelope

func UnmarshalEnvelopeOfType Uses

func UnmarshalEnvelopeOfType(envelope *cb.Envelope, headerType cb.HeaderType, message proto.Message) (*cb.ChannelHeader, error)

UnmarshalEnvelopeOfType unmarshals an envelope of the specified type, including unmarshaling the payload data

func UnmarshalEnvelopeOrPanic Uses

func UnmarshalEnvelopeOrPanic(encoded []byte) *cb.Envelope

UnmarshalEnvelopeOrPanic unmarshals bytes to an Envelope structure or panics on error

func UnmarshalHeader Uses

func UnmarshalHeader(bytes []byte) (*common.Header, error)

UnmarshalHeader unmarshals bytes to a Header

func UnmarshalPayload Uses

func UnmarshalPayload(encoded []byte) (*cb.Payload, error)

UnmarshalPayload unmarshals bytes to a Payload

func UnmarshalPayloadOrPanic Uses

func UnmarshalPayloadOrPanic(encoded []byte) *cb.Payload

UnmarshalPayloadOrPanic unmarshals bytes to a Payload structure or panics on error

func UnmarshalProposal Uses

func UnmarshalProposal(propBytes []byte) (*peer.Proposal, error)

UnmarshalProposal unmarshals bytes to a Proposal

func UnmarshalProposalResponse Uses

func UnmarshalProposalResponse(prBytes []byte) (*peer.ProposalResponse, error)

UnmarshalProposalResponse unmarshals bytes to a ProposalResponse

func UnmarshalProposalResponsePayload Uses

func UnmarshalProposalResponsePayload(prpBytes []byte) (*peer.ProposalResponsePayload, error)

UnmarshalProposalResponsePayload unmarshals bytes to a ProposalResponsePayload

func UnmarshalResponse Uses

func UnmarshalResponse(resBytes []byte) (*peer.Response, error)

UnmarshalResponse unmarshals bytes to a Response

func UnmarshalSerializedIdentity Uses

func UnmarshalSerializedIdentity(bytes []byte) (*msp.SerializedIdentity, error)

func UnmarshalSignatureHeader Uses

func UnmarshalSignatureHeader(bytes []byte) (*cb.SignatureHeader, error)

UnmarshalSignatureHeader unmarshals bytes to a SignatureHeader

func UnmarshalSignatureHeaderOrPanic Uses

func UnmarshalSignatureHeaderOrPanic(bytes []byte) *cb.SignatureHeader

UnmarshalSignatureHeaderOrPanic unmarshals bytes to a SignatureHeader or panics on error

func UnmarshalTransaction Uses

func UnmarshalTransaction(txBytes []byte) (*peer.Transaction, error)

UnmarshalTransaction unmarshals bytes to a Transaction

type SignedData Uses

type SignedData struct {
    Data      []byte
    Identity  []byte
    Signature []byte
}

SignedData is used to represent the general triplet required to verify a signature This is intended to be generic across crypto schemes, while most crypto schemes will include the signing identity and a nonce within the Data, this is left to the crypto implementation.

func ConfigUpdateEnvelopeAsSignedData Uses

func ConfigUpdateEnvelopeAsSignedData(ce *common.ConfigUpdateEnvelope) ([]*SignedData, error)

ConfigUpdateEnvelopeAsSignedData returns the set of signatures for the ConfigUpdateEnvelope as SignedData or an error indicating why this was not possible.

func EnvelopeAsSignedData Uses

func EnvelopeAsSignedData(env *common.Envelope) ([]*SignedData, error)

EnvelopeAsSignedData returns the signatures for the Envelope as SignedData slice of length 1 or an error indicating why this was not possible.

type Signer Uses

type Signer interface {
    Sign(msg []byte) ([]byte, error)
    Serialize() ([]byte, error)
}

Signer is the interface needed to sign a transaction

Package protoutil imports 17 packages (graph) and is imported by 15 packages. Updated 2019-09-06. Refresh now. Tools for package owners.