Help us shape the future of Go! Take the 2026 Go Developer Survey

state

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 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`)

	// ErrrKeyNotFound key not found in chaincode state
	ErrKeyNotFound = errors.New(`state entry not found`)

	// 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 Delete

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

Delete entry from state

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{}, config ...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 KeyError

func KeyError(strKey string) error

KeyError error with key

func KeyFromParts

func KeyFromParts(stub shim.ChaincodeStubInterface, keyParts []string) (string, error)

KeyFromParts creates composite key by string slice

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 HistoryEntry

type HistoryEntry struct {
	TxId      string      `json:"txId"`
	Timestamp int64       `json:"timestamp"`
	IsDeleted bool        `json:"isDeleted"`
	Value     interface{} `json:"value"`
}

HistoryEntry struct containing history information of a single entry

type HistoryEntryList

type HistoryEntryList []HistoryEntry

HistoryEntryList list of history entries

func GetHistory

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

GetHistory by key from state, trying to convert to target interface

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