chaincode

package
v0.0.0-...-95b87ed Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2019 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const DevModeUserRunsChaincode string = "dev"
View Source
const (
	InitializedKeyName = "\x00" + string(utf8.MaxRune) + "initialized"
)

Variables

This section is empty.

Functions

func IsDevMode

func IsDevMode() bool

func NewTxKey

func NewTxKey(channelID, txID string) string

func ParseName

func ParseName(ccName string) *sysccprovider.ChaincodeInstance

Types

type ACLProvider

type ACLProvider interface {
	CheckACL(resName string, channelID string, idinfo interface{}) error
}

type ActiveTransactions

type ActiveTransactions struct {
	// contains filtered or unexported fields
}

func NewActiveTransactions

func NewActiveTransactions() *ActiveTransactions

func (*ActiveTransactions) Add

func (a *ActiveTransactions) Add(channelID, txID string) bool

func (*ActiveTransactions) Remove

func (a *ActiveTransactions) Remove(channelID, txID string)

type ApplicationConfigRetriever

type ApplicationConfigRetriever interface {
	GetApplicationConfig(cid string) (channelconfig.Application, bool)
}

type CCProviderImpl

type CCProviderImpl struct {
	// contains filtered or unexported fields
}

func NewProvider

func NewProvider(cs *ChaincodeSupport) *CCProviderImpl

func (*CCProviderImpl) ExecuteLegacyInit

func (*CCProviderImpl) Stop

type CertGenerator

type CertGenerator interface {
	Generate(ccName string) (*accesscontrol.CertAndPrivKeyPair, error)
}

type ChaincodeSupport

type ChaincodeSupport struct {
	ACLProvider            ACLProvider
	AppConfig              ApplicationConfigRetriever
	BuiltinSCCs            scc.BuiltinSCCs
	DeployedCCInfoProvider ledger.DeployedChaincodeInfoProvider
	ExecuteTimeout         time.Duration
	HandlerMetrics         *HandlerMetrics
	HandlerRegistry        *HandlerRegistry
	Keepalive              time.Duration
	Launcher               Launcher
	Lifecycle              Lifecycle
	Peer                   *peer.Peer
	Runtime                Runtime
	TotalQueryLimit        int
	UserRunsCC             bool
}

func (*ChaincodeSupport) CheckInvocation

func (cs *ChaincodeSupport) CheckInvocation(txParams *ccprovider.TransactionParams, chaincodeName string, input *pb.ChaincodeInput) (ccid string, cctype pb.ChaincodeMessage_Type, err error)

func (*ChaincodeSupport) Execute

func (cs *ChaincodeSupport) Execute(txParams *ccprovider.TransactionParams, chaincodeName string, input *pb.ChaincodeInput) (*pb.Response, *pb.ChaincodeEvent, error)

func (*ChaincodeSupport) ExecuteLegacyInit

func (cs *ChaincodeSupport) ExecuteLegacyInit(txParams *ccprovider.TransactionParams, ccName, ccVersion string, input *pb.ChaincodeInput) (*pb.Response, *pb.ChaincodeEvent, error)

func (*ChaincodeSupport) HandleChaincodeStream

func (cs *ChaincodeSupport) HandleChaincodeStream(stream ccintf.ChaincodeStream) error

func (*ChaincodeSupport) Invoke

func (cs *ChaincodeSupport) Invoke(txParams *ccprovider.TransactionParams, chaincodeName string, input *pb.ChaincodeInput) (*pb.ChaincodeMessage, error)

func (*ChaincodeSupport) Launch

func (cs *ChaincodeSupport) Launch(ccid string) (*Handler, error)

func (*ChaincodeSupport) LaunchInProc

func (cs *ChaincodeSupport) LaunchInProc(ccid string) <-chan struct{}

func (*ChaincodeSupport) Register

type CollectionACLCache

type CollectionACLCache map[string]*readWritePermission

type Config

type Config struct {
	TotalQueryLimit int
	TLSEnabled      bool
	Keepalive       time.Duration
	ExecuteTimeout  time.Duration
	StartupTimeout  time.Duration
	LogFormat       string
	LogLevel        string
	ShimLogLevel    string
	SCCWhitelist    map[string]bool
}

func GlobalConfig

func GlobalConfig() *Config

type ContainerRouter

type ContainerRouter interface {
	Build(ccid string) error
	Start(ccid string, peerConnection *ccintf.PeerConnection) error
	Stop(ccid string) error
	Wait(ccid string) (int, error)
}

type ContainerRuntime

type ContainerRuntime struct {
	CertGenerator   CertGenerator
	ContainerRouter ContainerRouter
	CACert          []byte
	PeerAddress     string
}

func (*ContainerRuntime) Start

func (c *ContainerRuntime) Start(ccid string) error

func (*ContainerRuntime) Stop

func (c *ContainerRuntime) Stop(ccid string) error

func (*ContainerRuntime) Wait

func (c *ContainerRuntime) Wait(ccid string) (int, error)

type ContextRegistry

type ContextRegistry interface {
	Create(txParams *ccprovider.TransactionParams) (*TransactionContext, error)
	Get(chainID, txID string) *TransactionContext
	Delete(chainID, txID string)
	Close()
}

type Executor

type Executor interface {
	Execute(ctxt context.Context, cccid *ccprovider.CCContext, cis ccprovider.ChaincodeSpecGetter) (*pb.Response, *pb.ChaincodeEvent, error)
}

type Handler

type Handler struct {
	Keepalive time.Duration

	TotalQueryLimit int

	Invoker Invoker

	Registry Registry

	ACLProvider ACLProvider

	TXContexts ContextRegistry

	ActiveTransactions TransactionRegistry

	BuiltinSCCs scc.BuiltinSCCs

	QueryResponseBuilder QueryResponseBuilder

	LedgerGetter LedgerGetter

	DeployedCCInfoProvider ledger.DeployedChaincodeInfoProvider

	UUIDGenerator UUIDGenerator

	AppConfig ApplicationConfigRetriever

	Metrics *HandlerMetrics
	// contains filtered or unexported fields
}

func (*Handler) Close

func (h *Handler) Close()

func (*Handler) Execute

func (h *Handler) Execute(txParams *ccprovider.TransactionParams, namespace string, msg *pb.ChaincodeMessage, timeout time.Duration) (*pb.ChaincodeMessage, error)

func (*Handler) HandleDelState

func (h *Handler) HandleDelState(msg *pb.ChaincodeMessage, txContext *TransactionContext) (*pb.ChaincodeMessage, error)

func (*Handler) HandleGetHistoryForKey

func (h *Handler) HandleGetHistoryForKey(msg *pb.ChaincodeMessage, txContext *TransactionContext) (*pb.ChaincodeMessage, error)

func (*Handler) HandleGetPrivateDataHash

func (h *Handler) HandleGetPrivateDataHash(msg *pb.ChaincodeMessage, txContext *TransactionContext) (*pb.ChaincodeMessage, error)

func (*Handler) HandleGetQueryResult

func (h *Handler) HandleGetQueryResult(msg *pb.ChaincodeMessage, txContext *TransactionContext) (*pb.ChaincodeMessage, error)

func (*Handler) HandleGetState

func (h *Handler) HandleGetState(msg *pb.ChaincodeMessage, txContext *TransactionContext) (*pb.ChaincodeMessage, error)

func (*Handler) HandleGetStateByRange

func (h *Handler) HandleGetStateByRange(msg *pb.ChaincodeMessage, txContext *TransactionContext) (*pb.ChaincodeMessage, error)

func (*Handler) HandleGetStateMetadata

func (h *Handler) HandleGetStateMetadata(msg *pb.ChaincodeMessage, txContext *TransactionContext) (*pb.ChaincodeMessage, error)

func (*Handler) HandleInvokeChaincode

func (h *Handler) HandleInvokeChaincode(msg *pb.ChaincodeMessage, txContext *TransactionContext) (*pb.ChaincodeMessage, error)

func (*Handler) HandlePutState

func (h *Handler) HandlePutState(msg *pb.ChaincodeMessage, txContext *TransactionContext) (*pb.ChaincodeMessage, error)

func (*Handler) HandlePutStateMetadata

func (h *Handler) HandlePutStateMetadata(msg *pb.ChaincodeMessage, txContext *TransactionContext) (*pb.ChaincodeMessage, error)

func (*Handler) HandleQueryStateClose

func (h *Handler) HandleQueryStateClose(msg *pb.ChaincodeMessage, txContext *TransactionContext) (*pb.ChaincodeMessage, error)

func (*Handler) HandleQueryStateNext

func (h *Handler) HandleQueryStateNext(msg *pb.ChaincodeMessage, txContext *TransactionContext) (*pb.ChaincodeMessage, error)

func (*Handler) HandleRegister

func (h *Handler) HandleRegister(msg *pb.ChaincodeMessage)

func (*Handler) HandleTransaction

func (h *Handler) HandleTransaction(msg *pb.ChaincodeMessage, delegate handleFunc)

func (*Handler) Notify

func (h *Handler) Notify(msg *pb.ChaincodeMessage)

func (*Handler) ProcessStream

func (h *Handler) ProcessStream(stream ccintf.ChaincodeStream) error

func (*Handler) State

func (h *Handler) State() State

type HandlerMetrics

type HandlerMetrics struct {
	ShimRequestsReceived  metrics.Counter
	ShimRequestsCompleted metrics.Counter
	ShimRequestDuration   metrics.Histogram
	ExecuteTimeouts       metrics.Counter
}

func NewHandlerMetrics

func NewHandlerMetrics(p metrics.Provider) *HandlerMetrics

type HandlerRegistry

type HandlerRegistry struct {
	// contains filtered or unexported fields
}

func NewHandlerRegistry

func NewHandlerRegistry(allowUnsolicitedRegistration bool) *HandlerRegistry

func (*HandlerRegistry) Deregister

func (r *HandlerRegistry) Deregister(ccid string) error

func (*HandlerRegistry) Failed

func (r *HandlerRegistry) Failed(ccid string, err error)

func (*HandlerRegistry) Handler

func (r *HandlerRegistry) Handler(ccid string) *Handler

func (*HandlerRegistry) Launching

func (r *HandlerRegistry) Launching(ccid string) (*LaunchState, bool)

func (*HandlerRegistry) Ready

func (r *HandlerRegistry) Ready(ccid string)

func (*HandlerRegistry) Register

func (r *HandlerRegistry) Register(h *Handler) error

type Invoker

type Invoker interface {
	Invoke(txParams *ccprovider.TransactionParams, chaincodeName string, spec *pb.ChaincodeInput) (*pb.ChaincodeMessage, error)
}

type LaunchMetrics

type LaunchMetrics struct {
	LaunchDuration metrics.Histogram
	LaunchFailures metrics.Counter
	LaunchTimeouts metrics.Counter
}

func NewLaunchMetrics

func NewLaunchMetrics(p metrics.Provider) *LaunchMetrics

type LaunchRegistry

type LaunchRegistry interface {
	Launching(ccid string) (launchState *LaunchState, started bool)
	Deregister(ccid string) error
}

type LaunchState

type LaunchState struct {
	// contains filtered or unexported fields
}

func NewLaunchState

func NewLaunchState() *LaunchState

func (*LaunchState) Done

func (l *LaunchState) Done() <-chan struct{}

func (*LaunchState) Err

func (l *LaunchState) Err() error

func (*LaunchState) Notify

func (l *LaunchState) Notify(err error)

type Launcher

type Launcher interface {
	Launch(ccid string) error
}

type LedgerGetter

type LedgerGetter interface {
	GetLedger(cid string) ledger.PeerLedger
}

type Lifecycle

type Lifecycle struct {
	Executor Executor
}

func (*Lifecycle) GetChaincodeDefinition

func (l *Lifecycle) GetChaincodeDefinition(
	ctx context.Context,
	txid string,
	signedProp *pb.SignedProposal,
	prop *pb.Proposal,
	chainID string,
	chaincodeID string,
) (ccprovider.ChaincodeDefinition, error)

func (*Lifecycle) GetChaincodeDeploymentSpec

func (l *Lifecycle) GetChaincodeDeploymentSpec(
	ctx context.Context,
	txid string,
	signedProp *pb.SignedProposal,
	prop *pb.Proposal,
	chainID string,
	chaincodeID string,
) (*pb.ChaincodeDeploymentSpec, error)

type MessageHandler

type MessageHandler interface {
	Handle(*pb.ChaincodeMessage, *TransactionContext) (*pb.ChaincodeMessage, error)
}

type PendingQueryResult

type PendingQueryResult struct {
	// contains filtered or unexported fields
}

func (*PendingQueryResult) Add

func (p *PendingQueryResult) Add(queryResult commonledger.QueryResult) error

func (*PendingQueryResult) Cut

func (*PendingQueryResult) Size

func (p *PendingQueryResult) Size() int

type QueryResponseBuilder

type QueryResponseBuilder interface {
	BuildQueryResponse(txContext *TransactionContext, iter commonledger.ResultsIterator,
		iterID string, isPaginated bool, totalReturnLimit int32) (*pb.QueryResponse, error)
}

type QueryResponseGenerator

type QueryResponseGenerator struct {
	MaxResultLimit int
}

func (*QueryResponseGenerator) BuildQueryResponse

func (q *QueryResponseGenerator) BuildQueryResponse(txContext *TransactionContext, iter commonledger.ResultsIterator,
	iterID string, isPaginated bool, totalReturnLimit int32) (*pb.QueryResponse, error)

type Registry

type Registry interface {
	Register(*Handler) error
	Ready(string)
	Failed(string, error)
	Deregister(string) error
}

type Runtime

type Runtime interface {
	Start(ccid string) error
	Stop(ccid string) error
	Wait(ccid string) (int, error)
}

type RuntimeLauncher

type RuntimeLauncher struct {
	Runtime        Runtime
	Registry       LaunchRegistry
	StartupTimeout time.Duration
	Metrics        *LaunchMetrics
}

func (*RuntimeLauncher) Launch

func (r *RuntimeLauncher) Launch(ccid string) error

type State

type State int
const (
	Created State = iota
	Established
	Ready
)

func (State) String

func (s State) String() string

type TransactionContext

type TransactionContext struct {
	ChannelID            string
	NamespaceID          string
	SignedProp           *pb.SignedProposal
	Proposal             *pb.Proposal
	ResponseNotifier     chan *pb.ChaincodeMessage
	TXSimulator          ledger.TxSimulator
	HistoryQueryExecutor ledger.HistoryQueryExecutor
	CollectionStore      privdata.CollectionStore
	IsInitTransaction    bool

	CollectionACLCache CollectionACLCache
	// contains filtered or unexported fields
}

func (*TransactionContext) CleanupQueryContext

func (t *TransactionContext) CleanupQueryContext(queryID string)

func (*TransactionContext) CleanupQueryContextWithBookmark

func (t *TransactionContext) CleanupQueryContextWithBookmark(queryID string) string

func (*TransactionContext) CloseQueryIterators

func (t *TransactionContext) CloseQueryIterators()

func (*TransactionContext) GetPendingQueryResult

func (t *TransactionContext) GetPendingQueryResult(queryID string) *PendingQueryResult

func (*TransactionContext) GetQueryIterator

func (t *TransactionContext) GetQueryIterator(queryID string) commonledger.ResultsIterator

func (*TransactionContext) GetTotalReturnCount

func (t *TransactionContext) GetTotalReturnCount(queryID string) *int32

func (*TransactionContext) InitializeCollectionACLCache

func (t *TransactionContext) InitializeCollectionACLCache()

func (*TransactionContext) InitializeQueryContext

func (t *TransactionContext) InitializeQueryContext(queryID string, iter commonledger.ResultsIterator)

type TransactionContexts

type TransactionContexts struct {
	// contains filtered or unexported fields
}

func NewTransactionContexts

func NewTransactionContexts() *TransactionContexts

func (*TransactionContexts) Close

func (c *TransactionContexts) Close()

func (*TransactionContexts) Create

func (*TransactionContexts) Delete

func (c *TransactionContexts) Delete(channelID, txID string)

func (*TransactionContexts) Get

func (c *TransactionContexts) Get(channelID, txID string) *TransactionContext

type TransactionRegistry

type TransactionRegistry interface {
	Add(channelID, txID string) bool
	Remove(channelID, txID string)
}

type TxQueryExecutorGetter

type TxQueryExecutorGetter struct {
	HandlerRegistry *HandlerRegistry
	CCID            string
}

func (*TxQueryExecutorGetter) TxQueryExecutor

func (g *TxQueryExecutorGetter) TxQueryExecutor(chainID, txID string) ledger.SimpleQueryExecutor

type UUIDGenerator

type UUIDGenerator interface {
	New() string
}

type UUIDGeneratorFunc

type UUIDGeneratorFunc func() string

func (UUIDGeneratorFunc) New

func (u UUIDGeneratorFunc) New() string

Jump to

Keyboard shortcuts

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