state

package
v0.0.0-...-8fe6f98 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnableToCreateKey can occurs while creating composite key for entry
	ErrUnableToCreateKey = errors.New(`unable to create state key`)

	// ErrKeyAlreadyExists can occurs when trying to insert entry with existing key
	ErrKeyAlreadyExists = errors.New(`state key already exists`)

	// ErrAllowOnlyOneValue can occurs when trying to call Insert or Put with more than 2 arguments
	ErrAllowOnlyOneValue = errors.New(`allow only one value`)

	// ErrKeyNotSupportKeyerInterface can occurs when trying to Insert or Put struct without providing key and struct not support Keyer interface
	ErrKeyNotSupportKeyerInterface = errors.New(`key not support keyer interface`)

	// ErrKeyPartsLength can occurs when trying to create key consisting of zero parts
	ErrKeyPartsLength = errors.New(`key parts length must be greater than zero`)
)
View Source
var (
	ErrEmptyChaincodeResponsePayload = errors.New(`empty chaincode response payload`)
)

Functions

func Exists

func Exists(stub shim.ChaincodeStubInterface, key interface{}) (exists bool, err error)

Exists check entry with key exists in chaincode state

func Get

func Get(stub shim.ChaincodeStubInterface, key interface{}, target ...interface{}) (result interface{}, err error)

Get data by key from state, trying to convert to target interface

func Insert

func Insert(stub shim.ChaincodeStubInterface, key interface{}, values ...interface{}) (err error)

Insert value into chaincode state, returns error if key already exists

func InvokeChaincode

func InvokeChaincode(
	stub shim.ChaincodeStubInterface, chaincodeName string, args []interface{}, channel string, target interface{}) (interface{}, error)

InvokeChaincode locally calls the specified chaincode and converts result into target data type

func Key

func Key(stub shim.ChaincodeStubInterface, key interface{}) (string, error)

Key transforms interface{} to string key

func KeyParts

func KeyParts(key interface{}) ([]string, error)

KeyParts returns string parts of composite key

func Put

func Put(stub shim.ChaincodeStubInterface, key interface{}, values ...interface{}) (err error)

Put data value in state with key, trying convert data to []byte

Types

type EntryList

type EntryList []interface{}

EntryList list of entries from state, gotten by part of composite key

func List

func List(stub shim.ChaincodeStubInterface, objectType interface{}, target interface{}) (result EntryList, err error)

List data from state using objectType prefix in composite key, trying to conver to target interface. Keys - additional components of composite key

type Keyer

type Keyer interface {
	Key() ([]string, error)
}

Keyer interface for entity containing logic of its key creation

func StringKeyer

func StringKeyer(str string, keyer KeyerFunc) Keyer

StringKeyer constructor for struct implementing Keyer interface

type KeyerFunc

type KeyerFunc func(string) ([]string, error)

Jump to

Keyboard shortcuts

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