protoutil

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChannelHeader

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

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

func ChannelID

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

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

func ComputeTxID

func ComputeTxID(nonce, creator []byte) string

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

func CreateChaincodeProposal

func CreateChaincodeProposal(typ common.HeaderType, channelID 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

func CreateChaincodeProposalWithTransient(typ common.HeaderType, channelID 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 CreateChaincodeProposalWithTxIDNonceAndTransient

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

CreateChaincodeProposalWithTxIDNonceAndTransient creates a proposal from given input

func CreateNonce

func CreateNonce() ([]byte, error)

CreateNonce generates a nonce using the common/crypto package.

func CreateProposalFromCIS

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

CreateProposalFromCIS returns a proposal given a serialized identity and a ChaincodeInvocationSpec

func CreateProposalResponse

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

CreateProposalResponse creates a proposal response.

func CreateSignedEnvelope

func CreateSignedEnvelope(
	txType common.HeaderType,
	channelID string,
	signer Signer,
	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

func CreateSignedEnvelopeWithTLSBinding(
	txType common.HeaderType,
	channelID string,
	signer Signer,
	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

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 ExtractEnvelope

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

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

func GetBytesChaincodeActionPayload

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

GetBytesChaincodeActionPayload get the bytes of ChaincodeActionPayload from the message

func GetBytesChaincodeProposalPayload

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

GetBytesChaincodeProposalPayload gets the chaincode proposal payload

func GetBytesPayload

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

GetBytesPayload get the bytes of Payload from the message

func GetBytesProposalPayloadForTx

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

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

func GetBytesProposalResponsePayload

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

GetBytesProposalResponsePayload gets proposal response payload

func GetBytesTransaction

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

GetBytesTransaction get the bytes of Transaction from the message

func GetEnvelopeFromBlock

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

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

func GetProposalHash1

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 GetSignedProposal

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

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

func MakeChannelHeader

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

MakeChannelHeader creates a ChannelHeader.

func MakePayloadHeader

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

MakePayloadHeader creates a Payload Header.

func Marshal

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

Marshal serializes a protobuf message.

func MarshalOrPanic

func MarshalOrPanic(pb proto.Message) []byte

MarshalOrPanic serializes a protobuf message and panics if this operation fails

func NewSignatureHeader

func NewSignatureHeader(id Signer) (*cb.SignatureHeader, error)

NewSignatureHeader returns a SignatureHeader with a valid nonce.

func UnmarshalChaincodeAction

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

UnmarshalChaincodeAction unmarshals bytes to a ChaincodeAction

func UnmarshalChaincodeActionPayload

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

UnmarshalChaincodeActionPayload unmarshals bytes to a ChaincodeActionPayload

func UnmarshalChaincodeProposalPayload

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

UnmarshalChaincodeProposalPayload unmarshals bytes to a ChaincodeProposalPayload

func UnmarshalChannelHeader

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

UnmarshalChannelHeader unmarshals bytes to a ChannelHeader

func UnmarshalEnvelope

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

UnmarshalEnvelope unmarshals bytes to a Envelope

func UnmarshalHeader

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

UnmarshalHeader unmarshals bytes to a Header

func UnmarshalPayload

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

UnmarshalPayload unmarshals bytes to a Payload

func UnmarshalProposalResponsePayload

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

UnmarshalProposalResponsePayload unmarshals bytes to a ProposalResponsePayload

func UnmarshalSignatureHeader

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

UnmarshalSignatureHeader unmarshals bytes to a SignatureHeader

func UnmarshalTransaction

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

UnmarshalTransaction unmarshals bytes to a Transaction

Types

type Signer

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

Signer is the interface needed to sign a transaction

Jump to

Keyboard shortcuts

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