transaction

package module
v0.1.5-0...-4a489c3 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2021 License: BSD-3-Clause Imports: 15 Imported by: 0

README

Fabric Transaction trigger

This Flogo trigger contribution is the shim for Hyperledger Fabric chaincode. Its use is demonstrated in the contract example.

Each Fabric transaction in the chaincode is configured as a handler of this Transaction trigger, e.g.,

    "ref": "#transaction",
    "settings": {
        "cid": "alias,role,email"
    },
    "handlers": [{
        "settings": {
            "name": "createMarble",
            "parameters": "name,color,size:0,owner"
        },
        "action: { ... }
    }]

It must specify a transaction name, e.g., createMarble in the above example, and a list of parameters for the transaction. The parameter names are configuted as a comma-delimited list, and the parameter data type is string by default, but other data types can be specified by a suffix of number or boolean value after a delimiter :. The supported JSON types are 0 for integer, 0.0 for number, and false for boolean.

The above example defines a Fabric transaction of name createMarble that accepts 4 parameters of names name, color, size, and owner, where the size is an integer, while other parameters are strings.

The Transaction trigger also extracts user info from the requestor's CA certificates, which includes the attributes of id, mspid, and cn. If the user certificates contain more custom attributes for the application, you can list the custom attrinute names in the cid configuration, and so they can be used by the chaincode for authorization purposes. In the above example, it lists 3 custom attribute names from the CA, i.e., alias, role, and email, which can be verified by the chainode to control the access of some operations.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Invoke

func Invoke(stub shim.ChaincodeStubInterface, fn string, args []string) (int, []byte)

Invoke starts the singleton trigger and invokes the action registered in the handler, and returns status code and result as JSON string

Types

type Attribute

type Attribute struct {
	Name string `md:"name"`
	Type string `md:"type"`
}

Attribute describes a name and data type

func (*Attribute) String

func (p *Attribute) String() string

type Factory

type Factory struct {
}

Factory for trigger

func (*Factory) Metadata

func (*Factory) Metadata() *trigger.Metadata

Metadata implements trigger.Factory.Metadata

func (*Factory) New

func (t *Factory) New(config *trigger.Config) (trigger.Trigger, error)

New implements trigger.Factory.New

type HandlerSettings

type HandlerSettings struct {
	Name      string       `md:"name,required"`
	Arguments []*Attribute `md:"arguments"`
}

HandlerSettings for the trigger arguments are of parameter names and associated JSON data type type is any valid JSON type, i.e., string, number, integer, boolean, array, object.

func (*HandlerSettings) FromMap

func (h *HandlerSettings) FromMap(values map[string]interface{}) error

FromMap sets handling settings from a map

type Output

type Output struct {
	Parameters map[string]interface{} `md:"parameters"`
	Transient  map[string]interface{} `md:"transient"`
	TxID       string                 `md:"txID"`
	TxTime     string                 `md:"txTime"`
	CID        map[string]string      `md:"cid"`
}

Output of the trigger

func (*Output) FromMap

func (o *Output) FromMap(values map[string]interface{}) error

FromMap sets trigger output values from a map

func (*Output) ToMap

func (o *Output) ToMap() map[string]interface{}

ToMap converts trigger output to a map

type Reply

type Reply struct {
	Status  int         `md:"status"`
	Message string      `md:"message"`
	Returns interface{} `md:"returns"`
}

Reply from the trigger

func (*Reply) FromMap

func (r *Reply) FromMap(values map[string]interface{}) error

FromMap sets trigger reply values from a map

func (*Reply) ToMap

func (r *Reply) ToMap() map[string]interface{}

ToMap converts trigger reply to a map

type Settings

type Settings struct {
	CIDAttrs []string `md:"cidattrs"`
}

Settings for the trigger

func (*Settings) FromMap

func (s *Settings) FromMap(values map[string]interface{}) error

FromMap sets settings from a map

type Trigger

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

Trigger is the Fabric transaction Trigger implementation

func (*Trigger) Initialize

func (t *Trigger) Initialize(ctx trigger.InitContext) error

Initialize implements trigger.Init.Initialize

func (*Trigger) Start

func (t *Trigger) Start() error

Start implements trigger.Trigger.Start

func (*Trigger) Stop

func (t *Trigger) Stop() error

Stop implements trigger.Trigger.Start

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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