chaincode

package
v0.0.0-...-667e438 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2019 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultChain is the name of the default chain.
	DefaultChain ChainName = "default"
	SystemChain  ChainName = "syscc"
	// DevModeUserRunsChaincode property allows user to run chaincode in development environment
	DevModeUserRunsChaincode string = "dev"
	NetworkModeChaincode     string = "net"
)

Variables

View Source
var CCHandlingErr_RCMain = fmt.Errorf("Chaincode handling have a racing condiction")
View Source
var CCHandlingErr_RCWrite = fmt.Errorf("Chaincode handling have a racing condiction in writting states")
View Source
var ReservedCCName = map[string]bool{/* contains filtered or unexported fields */}

used to filter some chaincode name from external accessing

Functions

func Execute

func Execute(ctxt context.Context, chain *ChaincodeSupport, t *pb.Transaction) ([]byte, []*pb.ChaincodeEvent, error)

Execute - execute transaction or a query This method has been deprecated: chaincode being executed could not obtain an repeatable execution timestamp, which may lead to the generated state being unstable

func ExecuteTransactions

func ExecuteTransactions(ctxt context.Context, cname ChainName, xacts []*pb.Transaction) (succeededTXs []*pb.Transaction, stateHash []byte, ccevents []*pb.ChaincodeEvent, txerrs []error, err error)

ExecuteTransactions - will execute transactions on the array one by one will return an array of errors one for each transaction. If the execution succeeded, array element will be nil. returns []byte of state hash or error YA-fabric: ExecuteTransactions is badly designed, the events has been truncated to first one and should be deprecated later

func ExecuteTransactions2

func ExecuteTransactions2(ctxt context.Context, cname ChainName,
	xacts []*pb.TransactionHandlingContext, execTime time.Time,
	agent *ledger.TxEvaluateAndCommit) (succeededTXs []*pb.Transaction, err error)

The new exec entry for YA-fabric, which evaluating a series of txs (with handling context) in sequence and prepare for a TxEvaluateAndCommit, it also mutate the incoming transacion handling context, with an execution timestamp being specified the success tx will be returned, respecting the expected behavior in ledger's commitTxBatch

func GetChaincodePackageBytes

func GetChaincodePackageBytes(spec *pb.ChaincodeSpec) ([]byte, error)

GetChaincodePackageBytes creates bytes for docker container generation using the supplied chaincode specification

func RemoveChaincodeSupport

func RemoveChaincodeSupport(cName ChainName)

func SetChaincodeSupport

func SetChaincodeSupport(cName ChainName, ccsp *ChaincodeSupport)

func ValidateDeploymentSpec

func ValidateDeploymentSpec(txe *pb.TransactionHandlingContext, st ledger.TxExecStates, ledger *ledger.Ledger) error

func WriteRuntimePackage

func WriteRuntimePackage(cds *pb.ChaincodeDeploymentSpec, clispec *config.ClientSpec) (*runtimeReader, error)

Generate a package (in Writer) for (docker) controller

Types

type ChainName

type ChainName string

ChainName is the name of the chain to which this chaincode support belongs to.

type ChaincodeSupport

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

ChaincodeSupport responsible for providing interfacing with chaincodes from the Peer.

func GetChain

func GetChain(name ChainName) *ChaincodeSupport

GetChain returns the chaincode support for a given chain

func GetDefaultChain

func GetDefaultChain() *ChaincodeSupport

func GetSystemChain

func GetSystemChain() *ChaincodeSupport

func NewChaincodeSupport

func NewChaincodeSupport(chainname ChainName, nodeName string, srvSpec *config.ServerSpec, userrunsCC bool) *ChaincodeSupport

NewChaincodeSupport creates a new ChaincodeSupport instance

func NewSystemChaincodeSupport

func NewSystemChaincodeSupport(nodeName string, chainName ...ChainName) *ChaincodeSupport

func (*ChaincodeSupport) DeployLaunch

func (chaincodeSupport *ChaincodeSupport) DeployLaunch(ctx context.Context, ledger *ledger.Ledger,
	chaincode string, cds *pb.ChaincodeDeploymentSpec) (error, *chaincodeRTEnv)

func (*ChaincodeSupport) Execute

func (chaincodeSupport *ChaincodeSupport) Execute(ctxt context.Context, chrte *chaincodeRTEnv, txe *pb.TransactionHandlingContext, outstate ledger.TxExecStates) (*pb.ChaincodeMessage, error)

Execute executes a transaction and waits for it to complete until a timeout value.

func (*ChaincodeSupport) ExecuteLite

func (chaincodeSupport *ChaincodeSupport) ExecuteLite(ctxt context.Context, chrte *chaincodeRTEnv,
	ttype pb.Transaction_Type, input *pb.ChaincodeInput, outstate ledger.TxExecStates) (*pb.ChaincodeMessage, error)

Executelite executes with minimal data requirement, can used for internal testing, syscc and some other cases this method also omit the limit of exectimeout, and CAN NOT be run concurrently

func (*ChaincodeSupport) FinalDeploy

func (chaincodeSupport *ChaincodeSupport) FinalDeploy(chrte *chaincodeRTEnv, txe *pb.TransactionHandlingContext, outstate ledger.TxExecStates) error

func (*ChaincodeSupport) HandleChaincodeStream

func (chaincodeSupport *ChaincodeSupport) HandleChaincodeStream(ctx context.Context, stream ccintf.ChaincodeStream) error

func (*ChaincodeSupport) Launch

func (chaincodeSupport *ChaincodeSupport) Launch(ctx context.Context, ledger *ledger.Ledger,
	st ledger.TxExecStates, chaincode string) (error, *chaincodeRTEnv)

func (*ChaincodeSupport) Launch2

func (chaincodeSupport *ChaincodeSupport) Launch2(ctx context.Context, ledger *ledger.Ledger,
	chaincode string, getcds func() (*pb.ChaincodeDeploymentSpec, *pb.Transaction, error)) (error, *chaincodeRTEnv)

Launch will launch the chaincode if not running (if running return nil) and will wait for handler of the chaincode to get into FSM ready state.

func (*ChaincodeSupport) Name

func (chaincodeSupport *ChaincodeSupport) Name() string

func (*ChaincodeSupport) Register

func (chaincodeSupport *ChaincodeSupport) Register(stream pb.ChaincodeSupport_RegisterServer) error

Register the bidi stream entry point called by chaincode to register with the Peer. registerHandler implements ccintf.HandleChaincodeStream for all vms to call with appropriate stream It call the main loop in handler for handling the associated Chaincode stream

func (*ChaincodeSupport) ReleaseLedger

func (chaincodeSupport *ChaincodeSupport) ReleaseLedger(l *ledger.Ledger) error

func (*ChaincodeSupport) Stop

func (chaincodeSupport *ChaincodeSupport) Stop(context context.Context, netTag string, cds *pb.ChaincodeDeploymentSpec) error

Stop stops a chaincode if running

func (*ChaincodeSupport) UserRunsCC

func (chaincodeSupport *ChaincodeSupport) UserRunsCC() bool

type ExecuteResult

type ExecuteResult struct {
	State  ledger.TxExecStates
	Events []*pb.ChaincodeEvent
	Resp   []byte
}

func Execute2

Execute2 - like legacy execute, but not relay the global ledger object and supposed the transaction has be make pre-exec

type Handler

type Handler struct {
	sync.RWMutex

	FSM         *fsm.FSM
	ChaincodeID *pb.ChaincodeID
	Ledger      *ledger.Ledger
	ShimVersion int
	// contains filtered or unexported fields
}

Handler responsbile for management of Peer's side of chaincode stream

type MessageHandler

type MessageHandler interface {
	HandleMessage(msg *pb.ChaincodeMessage) error
	SendMessage(msg *pb.ChaincodeMessage) error
}

MessageHandler interface for handling chaincode messages (common between Peer chaincode support and chaincode)

Directories

Path Synopsis
car
Package shim provides APIs for the chaincode to access its state variables, transaction context and call other chaincodes.
Package shim provides APIs for the chaincode to access its state variables, transaction context and call other chaincodes.

Jump to

Keyboard shortcuts

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