txn

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package txn enables creating, endorsing and sending transactions to Fabric peers and orderers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BroadcastEnvelope

func BroadcastEnvelope(envelope *fab.SignedEnvelope, orderers []fab.Orderer) (*fab.TransactionResponse, error)

BroadcastEnvelope will send the given envelope to some orderer, picking random endpoints until all are exhausted

func CreateChannelHeader

func CreateChannelHeader(headerType common.HeaderType, opts ChannelHeaderOpts) (*common.ChannelHeader, error)

CreateChannelHeader is a utility method to build a common chain header (TODO refactor)

TODO: Determine if this function should be exported after refactoring is completed.

func CreateHeader

func CreateHeader(ctx fab.IdentityContext, channelHeader *common.ChannelHeader, txnID fab.TransactionID) (*common.Header, error)

CreateHeader creates a Header from a ChannelHeader.

func New

New create a transaction with proposal response, following the endorsement policy.

func NewID

func NewID(signingIdentity fab.IdentityContext) (fab.TransactionID, error)

NewID computes a TransactionID for the current user context

TODO: Determine if this function should be exported after refactoring is completed.

func NewProposal

func NewProposal(ctx context, channelID string, request fab.ChaincodeInvokeRequest) (*fab.TransactionProposal, error)

NewProposal creates a proposal for transaction. This involves assembling the proposal with the data (chaincodeName, function to call, arguments, transient data, etc.) and signing it using identity in the current context.

func RegisterStatus

func RegisterStatus(txID fab.TransactionID, eventHub fab.EventHub) chan Status

RegisterStatus registers on the given eventhub for the given transaction id returns a TxValidationCode channel which receives the validation code when the transaction completes. If the code is TxValidationCode_VALID then the transaction committed successfully, otherwise the code indicates the error that occurred.

func Send

func Send(ctx context, tx *fab.Transaction, orderers []fab.Orderer) (*fab.TransactionResponse, error)

Send send a transaction to the chain’s orderer service (one or more orderer endpoints) for consensus and committing to the ledger.

func SendEnvelope

func SendEnvelope(ctx context, envelope *fab.SignedEnvelope, orderers []fab.Orderer) (*common.Block, error)

SendEnvelope sends the given envelope to each orderer and returns a block response

func SendProposal

func SendProposal(proposal *fab.TransactionProposal, targets []fab.ProposalProcessor) ([]*fab.TransactionProposalResponse, error)

SendProposal sends a TransactionProposal to ProposalProcessor.

func SignPayload

func SignPayload(ctx context, payload []byte) (*fab.SignedEnvelope, error)

SignPayload signs payload

TODO: Determine if this function should be exported after refactoring is completed.

func SignProposal

func SignProposal(ctx context, proposal *pb.Proposal) (*pb.SignedProposal, error)

SignProposal creates a SignedProposal based on the current context.

Types

type CCProposalType

type CCProposalType int

CCProposalType reflects transitions in the chaincode lifecycle

const (
	Instantiate CCProposalType = iota
	Upgrade
)

Define chaincode proposal types

type ChannelHeaderOpts

type ChannelHeaderOpts struct {
	ChannelID   string
	TxnID       fab.TransactionID
	Epoch       uint64
	ChaincodeID string
	Timestamp   time.Time
	TLSCertHash []byte
}

ChannelHeaderOpts holds the parameters to create a ChannelHeader.

type Status

type Status struct {
	Code  pb.TxValidationCode
	Error error
}

Status is the transaction status returned from eventhub tx events

Jump to

Keyboard shortcuts

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