endorsement

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2021 License: BSD-3-Clause Imports: 14 Imported by: 0

README

Fabric Endorsement activity

This Flogo activity contribution can be configured to update or list state-based endorsement policies.

List the state-based endorsement policy for one or more ledger state

This operation requires to configure the operation name as LIST, and specify one or more state keys in the input data, e.g.,

    "activity": {
        "ref": "#endorsement",
        "settings": {
            "operation": "LIST"
        },
        "input": {
            "keys": ["key1", "key2"]
        }
    }

This example will return the state-based endorsement policies for the specified state keys, e.g.,

[
  {
    "key": "key1",
    "policy": {
      "orgs": ["org1.MEMBER", "org2.MEMBER"],
      "rule": {
        "outOf": 2,
        "rules": [
          {
            "signedBy": 0
          },
          {
            "signedBy": 1
          }
        ]
      }
    }
  },
  {
    "key": "key2",
    "policy": {
      "orgs": ["org1.MEMBER", "org2.MEMBER"],
      "rule": {
        "outOf": 2,
        "rules": [
          {
            "signedBy": 0
          },
          {
            "signedBy": 1
          }
        ]
      }
    }
  }
]

Set state-based endorsement policy for one or more ledger states

This operation requires to configure the operation name as SET, and specify one or more state keys in the input data, as well as the endorsement policy, e.g.,

    "activity": {
        "ref": "#endorsement",
        "settings": {
            "operation": "SET"
        },
        "input": {
            "keys": "key1",
            "policy": "OutOf(2, 'org1.peer', 'org2.peer', 'org3.peer')"
        }
    }

This sample will set the state key key1 to require 2 of the 3 organizations to endorse the transaction.

Add one or more organizations to the endorsement policy of one or more ledger states

This operation requires to configure the operation name as ADD, and specify one or more state keys in the input data, as well as a list of organizations to add, e.g.,

    "activity": {
        "ref": "#endorsement",
        "settings": {
            "operation": "ADD",
            "role": "PEER"
        },
        "input": {
            "keys": "key1",
            "organizations": ["org1", "org2"]
        }
    }

This sample will add org1.PEER and org2.PEER to the endorsement policy for state key key1. Note that it also makes all the original organizations required for endorsement. Even if originally, it requires only some participants to endorse the transaction, after the ADD operation, all old and new organizations are required to endorse the transaction.

Remove one or more organizations from the endorsement policy of one or more ledger states

This operation requires to configure the operation name as DELETE, and specify one or more state keys in the input data, as well as a list of organizations to remove, e.g.,

    "activity": {
        "ref": "#endorsement",
        "settings": {
            "operation": "DELETE"
        },
        "input": {
            "keys": "key1",
            "organizations": "org1"
        }
    }

This sample will remove org1 from the endorsement policy for state key key1. Note that it also makes all the remaining organizations required for endorsement. Even if originally, it requires only some participants to endorse the transaction, after the DELETE operation, all the remaining organizations are required to endorse the transaction.

Set endorsement policy for one or more keys of a private data collection

This operation requires to specify the name of a private data collection, e.g.,

    "activity": {
        "ref": "#endorsement",
        "settings": {
            "operation": "SET"
        },
        "input": {
            "keys": "key1",
            "policy": "OutOf(2, 'org1.peer', 'org2.peer', 'org3.peer')",
            "privateCollection": "_implicit"
        }
    }

This sample will set the endorsement policy for a key in th client's implicit private collection, i.e., _implicit_org_<mspid>. All the above examples apply to private data collections, too.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

New creates a new Activity

Types

type Activity

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

Activity is a stub for executing Hyperledger Fabric get operations

func (*Activity) Eval

func (a *Activity) Eval(ctx activity.Context) (done bool, err error)

Eval implements activity.Activity.Eval

func (*Activity) Metadata

func (a *Activity) Metadata() *activity.Metadata

Metadata implements activity.Activity.Metadata

type Input

type Input struct {
	StateKeys         []string `md:"keys,required"`
	Organizations     []string `md:"organizations"`
	Policy            string   `md:"policy"`
	PrivateCollection string   `md:"privateCollection"`
}

Input of the activity

func (*Input) FromMap

func (i *Input) FromMap(values map[string]interface{}) error

FromMap sets activity input values from a map

func (*Input) ToMap

func (i *Input) ToMap() map[string]interface{}

ToMap converts activity input to a map

type Output

type Output struct {
	Code    int           `md:"code"`
	Message string        `md:"message"`
	Result  []interface{} `md:"result"`
}

Output of the activity

func (*Output) FromMap

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

FromMap sets activity output values from a map

func (*Output) ToMap

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

ToMap converts activity output to a map

type Settings

type Settings struct {
	Operation string `md:"operation,required,allowed(ADD,DELETE,LIST,SET)"`
	Role      string `md:"role,allowed(MEMBER,ADMIN,CLIENT,PEER)"`
}

Settings of the activity

func (*Settings) FromMap

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

FromMap sets settings from a map

Jump to

Keyboard shortcuts

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