endorser

package
v2.1.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2020 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssemblePvtRWSet

func AssemblePvtRWSet(channelName string,
	privData *rwset.TxPvtReadWriteSet,
	txsim ledger.SimpleQueryExecutor,
	deployedCCInfoProvider ledger.DeployedChaincodeInfoProvider) (
	*transientstore.TxPvtReadWriteSetWithConfigInfo, error,
)

AssemblePvtRWSet prepares TxPvtReadWriteSet for distribution augmenting it into TxPvtReadWriteSetWithConfigInfo adding information about collections config available related to private read-write set

func CreateCCEventBytes

func CreateCCEventBytes(ccevent *pb.ChaincodeEvent) ([]byte, error)

Types

type Channel

type Channel struct {
	IdentityDeserializer msp.IdentityDeserializer
}

type ChannelFetcher

type ChannelFetcher interface {
	Channel(channelID string) *Channel
}

ChannelFetcher fetches the channel context for a given channel ID.

type ChannelState added in v1.2.0

type ChannelState struct {
	*transientstore.Store
	QueryCreator
}

ChannelState defines state operations

func (*ChannelState) FetchState added in v1.2.0

func (cs *ChannelState) FetchState() (endorsement.State, error)

FetchState fetches state

type ChannelStateRetriever added in v1.2.0

type ChannelStateRetriever interface {
	// NewQueryCreator returns a QueryCreator for the given Channel
	NewQueryCreator(channel string) (QueryCreator, error)
}

ChannelStateRetriever retrieves Channel state

type CollectionConfigRetriever added in v1.2.0

type CollectionConfigRetriever interface {
	// GetState gets the value for given namespace and key. For a chaincode, the namespace corresponds to the chaincodeId
	GetState(namespace string, key string) ([]byte, error)
}

CollectionConfigRetriever encapsulates sub-functionality of ledger.TxSimulator to abstract minimum required functions set

type Context added in v1.2.0

type Context struct {
	PluginName     string
	Channel        string
	TxID           string
	Proposal       *pb.Proposal
	SignedProposal *pb.SignedProposal
	Visibility     []byte
	Response       *pb.Response
	Event          []byte
	ChaincodeID    *pb.ChaincodeID
	SimRes         []byte
}

Context defines the data that is related to an in-flight endorsement

func (Context) String added in v1.2.0

func (c Context) String() string

String returns a text representation of this context

type Endorser

type Endorser struct {
	ChannelFetcher         ChannelFetcher
	LocalMSP               msp.IdentityDeserializer
	PrivateDataDistributor PrivateDataDistributor
	Support                Support
	PvtRWSetAssembler      PvtRWSetAssembler
	Metrics                *Metrics
}

Endorser provides the Endorser service ProcessProposal

func (*Endorser) ProcessProposal

func (e *Endorser) ProcessProposal(ctx context.Context, signedProp *pb.SignedProposal) (*pb.ProposalResponse, error)

ProcessProposal process the Proposal

func (*Endorser) ProcessProposalSuccessfullyOrError

func (e *Endorser) ProcessProposalSuccessfullyOrError(up *UnpackedProposal) (*pb.ProposalResponse, error)

func (*Endorser) SimulateProposal added in v1.2.0

func (e *Endorser) SimulateProposal(txParams *ccprovider.TransactionParams, chaincodeName string, chaincodeInput *pb.ChaincodeInput) (*pb.Response, []byte, *pb.ChaincodeEvent, error)

SimulateProposal simulates the proposal by calling the chaincode

type MapBasedPluginMapper added in v1.2.0

type MapBasedPluginMapper map[string]endorsement.PluginFactory

MapBasedPluginMapper maps plugin names to their corresponding factories

func (MapBasedPluginMapper) PluginFactoryByName added in v1.2.0

func (m MapBasedPluginMapper) PluginFactoryByName(name PluginName) endorsement.PluginFactory

PluginFactoryByName returns a plugin factory for the given plugin name, or nil if not found

type Metrics

type Metrics struct {
	ProposalDuration         metrics.Histogram
	ProposalsReceived        metrics.Counter
	SuccessfulProposals      metrics.Counter
	ProposalValidationFailed metrics.Counter
	ProposalACLCheckFailed   metrics.Counter
	InitFailed               metrics.Counter
	EndorsementsFailed       metrics.Counter
	DuplicateTxsFailure      metrics.Counter
	SimulationFailure        metrics.Counter
}

func NewMetrics

func NewMetrics(p metrics.Provider) *Metrics

type PeerOperations

type PeerOperations interface {
	GetApplicationConfig(cid string) (channelconfig.Application, bool)
	GetLedger(cid string) ledger.PeerLedger
}

PeerOperations contains the peer operatiosn required to support the endorser.

type PluginEndorser added in v1.2.0

type PluginEndorser struct {
	sync.Mutex
	PluginMapper

	ChannelStateRetriever
	endorsement3.SigningIdentityFetcher
	TransientStoreRetriever
	// contains filtered or unexported fields
}

PluginEndorser endorsers proposal responses using plugins

func NewPluginEndorser added in v1.2.0

func NewPluginEndorser(ps *PluginSupport) *PluginEndorser

NewPluginEndorser endorses with using a plugin

func (*PluginEndorser) EndorseWithPlugin added in v1.2.0

func (pe *PluginEndorser) EndorseWithPlugin(pluginName, channelID string, prpBytes []byte, signedProposal *pb.SignedProposal) (*pb.Endorsement, []byte, error)

EndorseWithPlugin endorses the response with a plugin

type PluginMapper added in v1.2.0

type PluginMapper interface {
	PluginFactoryByName(name PluginName) endorsement.PluginFactory
}

PluginMapper maps plugin names to their corresponding factories

type PluginName added in v1.2.0

type PluginName string

PluginName defines the name of the plugin as it appears in the configuration

type PluginSupport added in v1.2.0

PluginSupport aggregates the support interfaces needed for the operation of the plugin endorser

type PrivateDataDistributor

type PrivateDataDistributor interface {
	DistributePrivateData(channel string, txID string, privateData *transientstore.TxPvtReadWriteSetWithConfigInfo, blkHt uint64) error
}

type PvtRWSetAssembler added in v1.2.0

type PvtRWSetAssembler interface {
	// AssemblePvtRWSet prepares TxPvtReadWriteSet for distribution
	// augmenting it into TxPvtReadWriteSetWithConfigInfo adding
	// information about collections config available related
	// to private read-write set
	AssemblePvtRWSet(channelName string,
		privData *rwset.TxPvtReadWriteSet,
		txsim ledger.SimpleQueryExecutor,
		deployedCCInfoProvider ledger.DeployedChaincodeInfoProvider) (
		*transientstore.TxPvtReadWriteSetWithConfigInfo, error,
	)
}

PvtRWSetAssembler assembles private read write set for distribution augments with additional information if needed

type QueryCreator added in v1.2.0

type QueryCreator interface {
	NewQueryExecutor() (ledger.QueryExecutor, error)
}

QueryCreator creates new QueryExecutors

type StateContext added in v1.2.0

type StateContext struct {
	*transientstore.Store
	ledger.QueryExecutor
}

StateContext defines an execution context that interacts with the state

func (*StateContext) GetTransientByTXID added in v1.2.0

func (sc *StateContext) GetTransientByTXID(txID string) ([]*rwset.TxPvtReadWriteSet, error)

GetTransientByTXID returns the private data associated with this transaction ID.

type Support added in v1.1.0

type Support interface {
	identity.SignerSerializer
	// GetTxSimulator returns the transaction simulator for the specified ledger
	// a client may obtain more than one such simulator; they are made unique
	// by way of the supplied txid
	GetTxSimulator(ledgername string, txid string) (ledger.TxSimulator, error)

	// GetHistoryQueryExecutor gives handle to a history query executor for the
	// specified ledger
	GetHistoryQueryExecutor(ledgername string) (ledger.HistoryQueryExecutor, error)

	// GetTransactionByID retrieves a transaction by id
	GetTransactionByID(chid, txID string) (*pb.ProcessedTransaction, error)

	// IsSysCC returns true if the name matches a system chaincode's
	// system chaincode names are system, chain wide
	IsSysCC(name string) bool

	// Execute - execute proposal, return original response of chaincode
	Execute(txParams *ccprovider.TransactionParams, name string, input *pb.ChaincodeInput) (*pb.Response, *pb.ChaincodeEvent, error)

	// ExecuteLegacyInit - executes a deployment proposal, return original response of chaincode
	ExecuteLegacyInit(txParams *ccprovider.TransactionParams, name, version string, spec *pb.ChaincodeInput) (*pb.Response, *pb.ChaincodeEvent, error)

	// ChaincodeEndorsementInfo returns the information from lifecycle required to endorse the chaincode.
	ChaincodeEndorsementInfo(channelID, chaincodeID string, txsim ledger.QueryExecutor) (*lifecycle.ChaincodeEndorsementInfo, error)

	// CheckACL checks the ACL for the resource for the channel using the
	// SignedProposal from which an id can be extracted for testing against a policy
	CheckACL(channelID string, signedProp *pb.SignedProposal) error

	// EndorseWithPlugin endorses the response with a plugin
	EndorseWithPlugin(pluginName, channnelID string, prpBytes []byte, signedProposal *pb.SignedProposal) (*pb.Endorsement, []byte, error)

	// GetLedgerHeight returns ledger height for given channelID
	GetLedgerHeight(channelID string) (uint64, error)

	// GetDeployedCCInfoProvider returns ledger.DeployedChaincodeInfoProvider
	GetDeployedCCInfoProvider() ledger.DeployedChaincodeInfoProvider
}

Support contains functions that the endorser requires to execute its tasks

type SupportImpl added in v1.1.0

type SupportImpl struct {
	*PluginEndorser
	identity.SignerSerializer
	Peer             PeerOperations
	ChaincodeSupport *chaincode.ChaincodeSupport
	ACLProvider      aclmgmt.ACLProvider
	BuiltinSCCs      scc.BuiltinSCCs
}

SupportImpl provides an implementation of the endorser.Support interface issuing calls to various static methods of the peer

func (*SupportImpl) ChaincodeEndorsementInfo

func (s *SupportImpl) ChaincodeEndorsementInfo(channelID, chaincodeName string, txsim ledger.QueryExecutor) (*lifecycle.ChaincodeEndorsementInfo, error)

ChaincodeEndorsementInfo returns info needed to endorse a tx for the chaincode with the supplied name.

func (*SupportImpl) CheckACL added in v1.1.0

func (s *SupportImpl) CheckACL(channelID string, signedProp *pb.SignedProposal) error

CheckACL checks the ACL for the resource for the Channel using the SignedProposal from which an id can be extracted for testing against a policy

func (*SupportImpl) Execute added in v1.1.0

func (s *SupportImpl) Execute(txParams *ccprovider.TransactionParams, name string, input *pb.ChaincodeInput) (*pb.Response, *pb.ChaincodeEvent, error)

Execute a proposal and return the chaincode response

func (*SupportImpl) ExecuteLegacyInit added in v1.3.0

func (s *SupportImpl) ExecuteLegacyInit(txParams *ccprovider.TransactionParams, name, version string, input *pb.ChaincodeInput) (*pb.Response, *pb.ChaincodeEvent, error)

ExecuteInit a deployment proposal and return the chaincode response

func (*SupportImpl) GetApplicationConfig added in v1.1.0

func (s *SupportImpl) GetApplicationConfig(cid string) (channelconfig.Application, bool)

GetApplicationConfig returns the configtxapplication.SharedConfig for the Channel and whether the Application config exists

func (*SupportImpl) GetDeployedCCInfoProvider

func (s *SupportImpl) GetDeployedCCInfoProvider() ledger.DeployedChaincodeInfoProvider

GetDeployedCCInfoProvider returns ledger.DeployedChaincodeInfoProvider

func (*SupportImpl) GetHistoryQueryExecutor added in v1.1.0

func (s *SupportImpl) GetHistoryQueryExecutor(ledgername string) (ledger.HistoryQueryExecutor, error)

GetHistoryQueryExecutor gives handle to a history query executor for the specified ledger

func (*SupportImpl) GetLedgerHeight added in v1.2.0

func (s *SupportImpl) GetLedgerHeight(channelID string) (uint64, error)

GetLedgerHeight returns ledger height for given channelID

func (*SupportImpl) GetTransactionByID added in v1.1.0

func (s *SupportImpl) GetTransactionByID(chid, txID string) (*pb.ProcessedTransaction, error)

GetTransactionByID retrieves a transaction by id

func (*SupportImpl) GetTxSimulator added in v1.1.0

func (s *SupportImpl) GetTxSimulator(ledgername string, txid string) (ledger.TxSimulator, error)

GetTxSimulator returns the transaction simulator for the specified ledger a client may obtain more than one such simulator; they are made unique by way of the supplied txid

func (*SupportImpl) IsSysCC added in v1.1.0

func (s *SupportImpl) IsSysCC(name string) bool

IsSysCC returns true if the name matches a system chaincode's system chaincode names are system, chain wide

func (*SupportImpl) NewQueryCreator added in v1.2.0

func (s *SupportImpl) NewQueryCreator(channel string) (QueryCreator, error)

func (*SupportImpl) SigningIdentityForRequest added in v1.2.0

func (s *SupportImpl) SigningIdentityForRequest(*pb.SignedProposal) (endorsement.SigningIdentity, error)

type TransientStoreRetriever added in v1.2.0

type TransientStoreRetriever interface {
	// StoreForChannel returns the transient store for the given channel
	StoreForChannel(channel string) *transientstore.Store
}

TransientStoreRetriever retrieves transient stores

type UnpackedProposal

type UnpackedProposal struct {
	ChaincodeName   string
	ChannelHeader   *cb.ChannelHeader
	Input           *pb.ChaincodeInput
	Proposal        *pb.Proposal
	SignatureHeader *cb.SignatureHeader
	SignedProposal  *pb.SignedProposal
	ProposalHash    []byte
}

UnpackedProposal contains the interesting artifacts from inside the proposal.

func UnpackProposal

func UnpackProposal(signedProp *pb.SignedProposal) (*UnpackedProposal, error)

UnpackProposal creates an an *UnpackedProposal which is guaranteed to have no zero-ed fields or it returns an error.

func (*UnpackedProposal) ChannelID

func (up *UnpackedProposal) ChannelID() string

func (*UnpackedProposal) TxID

func (up *UnpackedProposal) TxID() string

func (*UnpackedProposal) Validate

func (up *UnpackedProposal) Validate(idDeserializer msp.IdentityDeserializer) error

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.
Code generated by mockery v1.0.0 Code generated by mockery v1.0.0 Code generated by mockery v1.0.0
Code generated by mockery v1.0.0 Code generated by mockery v1.0.0 Code generated by mockery v1.0.0

Jump to

Keyboard shortcuts

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