common

package module
v0.1.2-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: 13 Imported by: 10

Documentation

Index

Constants

View Source
const (
	// KeyField attribute used in query response of key-value pairs
	KeyField = "key"
	// ValueField attribute used in query response of key-value pairs
	ValueField = "value"
	// ValueDeleted marks a deleted Fabric state
	ValueDeleted = "isDeleted"
	// FabricStub is the name of flow property for passing chaincode stub to activities
	FabricStub = "_chaincode_stub"
	// FabricTxID is the name of flow property for passing auto-generated transaction ID to activities
	FabricTxID = "txID"
	// FabricTxTime is the name of flow property for passing auto-generated transaction Time to activities
	FabricTxTime = "txTime"
	// FabricCID is the name of flow property for passing client ID to activities
	FabricCID = "cid"
)

Variables

This section is empty.

Functions

func DeleteData

func DeleteData(stub shim.ChaincodeStubInterface, store string, key string) error

DeleteData deletes a state or a composite key from the ledger if 'store' is not specified, or a private data collection specified by 'store'

func ExtractCompositeKeys

func ExtractCompositeKeys(stub shim.ChaincodeStubInterface, compositeKeyDefs map[string][]string, keyValue string, value interface{}) []string

ExtractCompositeKeys collects all valid composite-keys matching composite-key definitions using fields of a value object

func ExtractDataAttributes

func ExtractDataAttributes(attrs []string, data interface{}) []string

ExtractDataAttributes collects values of specified attributes from a data object for constructing a partial composite key

func GetActivityInputSchema

func GetActivityInputSchema(ctx activity.Context, name string) (string, error)

GetActivityInputSchema returns schema of an activity input attribute

func GetActivityOutputSchema

func GetActivityOutputSchema(ctx activity.Context, name string) (string, error)

GetActivityOutputSchema returns schema of an activity output attribute

func GetChaincodeStub

func GetChaincodeStub(ctx activity.Context) (shim.ChaincodeStubInterface, error)

GetChaincodeStub returns Fabric chaincode stub from the activity context

func GetCompositeKeys

func GetCompositeKeys(stub shim.ChaincodeStubInterface, store string, name string, values []string, pageSize int32, bookmark string) (shim.StateQueryIteratorInterface, *pb.QueryResponseMetadata, error)

GetCompositeKeys retrieves iterator for composite keys from from the ledger if 'store' is not specified, or a private data collection specified by 'store'

func GetData

func GetData(stub shim.ChaincodeStubInterface, store string, key string, privateHash bool) (string, []byte, error)

GetData retrieves data by state key from the ledger if 'store' is not specified, or a private data collection specified by 'store'

func GetDataByQuery

func GetDataByQuery(stub shim.ChaincodeStubInterface, store, query string, pageSize int32, bookmark string) (shim.StateQueryIteratorInterface, *pb.QueryResponseMetadata, error)

GetDataByQuery retrieves iterator for rich query from from the ledger if 'store' is not specified, or a private data collection specified by 'store'

func GetDataByRange

func GetDataByRange(stub shim.ChaincodeStubInterface, store, startKey, endKey string, pageSize int32, bookmark string) (shim.StateQueryIteratorInterface, *pb.QueryResponseMetadata, error)

GetDataByRange retrieves iterator for range of state keys from from the ledger if 'store' is not specified, or a private data collection specified by 'store'

func IsCompositeKey

func IsCompositeKey(key string) bool

IsCompositeKey returns true if a key belongs to composite key namespace

func MakeCompositeKey

func MakeCompositeKey(stub shim.ChaincodeStubInterface, keyName string, attributes []string, keyValue string, value interface{}) (string, bool)

MakeCompositeKey constructs composite key if all specified attributes exist in the value object

attributes contain JsonPath for fields in value objects

returns key, false if key does not include all fields defined in the attributes

func MapToObject

func MapToObject(data interface{}) (map[string]interface{}, error)

MapToObject strips extra nesting of mapping in config setting of activities exported by OSS Web UI

func PutData

func PutData(stub shim.ChaincodeStubInterface, store string, key string, value []byte) error

PutData writes key and value to the ledger if 'store' is not specified, or a private data collection specified by 'store'

func ResolveFlowData

func ResolveFlowData(toResolve string, context activity.Context) (value interface{}, err error)

ResolveFlowData resolves and returns data from the flow's context, unmarshals JSON string to map[string]interface{}. The name to Resolve is a valid output attribute of a flogo activity, e.g., `activity[app_16].value` or `$.content`, which is shown in normal flogo mapper as, e.g., "$.content"

Types

type CompositeKey

type CompositeKey struct {
	Name   string   `json:"name,omitempty"`
	Fields []string `json:"fields"`
	Key    string   `json:"key"`
}

CompositeKey holds components in a composite key

func SplitCompositeKey

func SplitCompositeKey(stub shim.ChaincodeStubInterface, key string) (*CompositeKey, error)

SplitCompositeKey returns components of a composite key

type CompositeKeyBag

type CompositeKeyBag struct {
	Name       string          `json:"name"`
	Attributes []string        `json:"attributes"`
	Keys       []*CompositeKey `json:"keys"`
}

CompositeKeyBag holds components in composite keys of the same name

func (*CompositeKeyBag) AddCompositeKey

func (b *CompositeKeyBag) AddCompositeKey(k *CompositeKey) (*CompositeKeyBag, error)

AddCompositeKey adds a new key to the bag

func (*CompositeKeyBag) ToMap

func (b *CompositeKeyBag) ToMap() (map[string]interface{}, error)

ToMap converts CompositeKeyBag to map[string]interface{}

Jump to

Keyboard shortcuts

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