protoutil

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlockDataHash

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

func ComputeTxID

func ComputeTxID(nonce, creator []byte) string

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

func CreateNonce

func CreateNonce() ([]byte, error)

CreateNonce generates a nonce using the common/crypto package.

func CreateNonceOrPanic

func CreateNonceOrPanic() []byte

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

func CreateSignedEnvelope

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

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

GetBytesTransaction get the bytes of Transaction from the message

func GetRandomNonce

func GetRandomNonce() ([]byte, error)

func MakeChannelHeader

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

MakeChannelHeader creates a ChannelHeader.

func MakePayloadHeader

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

MakePayloadHeader creates a Payload Header.

func MakeSignatureHeader

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

MakeSignatureHeader creates a SignatureHeader.

func MarshalOrPanic

func MarshalOrPanic(pb proto.Message) []byte

MarshalOrPanic serializes a protobuf message and panics if this operation fails

func NewBlock

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

NewBlock constructs a block with no data and no metadata.

func NewSignatureHeader

func NewSignatureHeader(id identity.Identity) (*common.SignatureHeader, error)

NewSignatureHeader returns a SignatureHeader with a valid nonce.

func SetTxID

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

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

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 UnmarshalConfigUpdateEnvelope

func UnmarshalConfigUpdateEnvelope(data []byte) (*cb.ConfigUpdateEnvelope, error)

UnmarshalConfigUpdateEnvelope attempts to unmarshal bytes to a *cb.ConfigUpdate

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 UnmarshalSignatureHeader

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

UnmarshalSignatureHeader unmarshals bytes to a SignatureHeader

Types

This section is empty.

Jump to

Keyboard shortcuts

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