Documentation ¶
Index ¶
- Variables
- func ConvertFromBytes(bb []byte, config ...interface{}) (interface{}, error)
- func ConvertToBytes(v interface{}, config ...interface{}) ([]byte, error)
- func InvokeChaincode(stub shim.ChaincodeStubInterface, chaincodeName string, args []interface{}, ...) (interface{}, error)
- func KeyAsIs(key []string) ([]string, error)
- func KeyError(strKey string) error
- func NameAsIs(name string) (string, error)
- func NormalizeEventName(name interface{}) (string, error)
- func StringKey(stub shim.ChaincodeStubInterface, key Key) (string, error)
- func StringsIdFromStr(idString string) []string
- func StringsIdToStr(idSlice []string) string
- type Event
- type EventImpl
- func (e *EventImpl) ArgNameValue(arg interface{}, values []interface{}) (name string, value interface{}, err error)
- func (e *EventImpl) Set(entry interface{}, values ...interface{}) error
- func (e *EventImpl) UseNameTransformer(nt StringTransformer) Event
- func (e *EventImpl) UseSetTransformer(tb ToBytesTransformer) Event
- type FromBytesTransformer
- type HistoryEntry
- type HistoryEntryList
- type Key
- type KeyFunc
- type KeyTransformer
- type KeyValue
- type Keyer
- type NameValue
- type Namer
- type State
- type StateImpl
- func (s *StateImpl) Delete(key interface{}) (err error)
- func (s *StateImpl) Exists(entry interface{}) (exists bool, err error)
- func (s *StateImpl) Get(key interface{}, config ...interface{}) (result interface{}, err error)
- func (s *StateImpl) GetHistory(key interface{}, target interface{}) (result HistoryEntryList, err error)
- func (s *StateImpl) GetInt(key interface{}, defaultValue int) (result int, err error)
- func (s *StateImpl) Insert(entry interface{}, values ...interface{}) (err error)
- func (s *StateImpl) Key(key interface{}) (string, error)
- func (s *StateImpl) List(namespace interface{}, target ...interface{}) (result interface{}, err error)
- func (s *StateImpl) Logger() *shim.ChaincodeLogger
- func (s *StateImpl) Put(entry interface{}, values ...interface{}) (err error)
- func (s *StateImpl) StringKey(key Key) (string, error)
- func (s *StateImpl) UseKeyTransformer(kt KeyTransformer) State
- func (s *StateImpl) UseStateGetTransformer(fb FromBytesTransformer) State
- func (s *StateImpl) UseStatePutTransformer(tb ToBytesTransformer) State
- type StateList
- type StringTransformer
- type StringsKeyer
- type ToBytesTransformer
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnableToCreateKey can occurs while creating composite key for entry ErrUnableToCreateStateKey = errors.New(`unable to create state key`) // ErrUnableToCreateEventName can occurs while creating composite key for entry ErrUnableToCreateEventName = errors.New(`unable to create event name`) // ErrKeyAlreadyExists can occurs when trying to insert entry with existing key ErrKeyAlreadyExists = errors.New(`state key already exists`) // ErrKeyNotFound 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 ErrStateEntryNotSupportKeyerInterface = errors.New(`state entry not support keyer interface`) ErrEventEntryNotSupportNamerInterface = errors.New(`event entry not support name interface`) // ErrKeyPartsLength can occurs when trying to create key consisting of zero parts ErrKeyPartsLength = errors.New(`key parts length must be greater than zero`) )
var (
ErrEmptyChaincodeResponsePayload = errors.New(`empty chaincode response payload`)
)
Functions ¶
func ConvertFromBytes ¶ added in v0.3.0
func ConvertToBytes ¶ added in v0.3.0
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 NormalizeEventName ¶ added in v0.4.1
func StringKey ¶ added in v0.4.1
func StringKey(stub shim.ChaincodeStubInterface, key Key) (string, error)
func StringsIdFromStr ¶ added in v0.4.3
StringsIdFromStr helper for restoring []string key
func StringsIdToStr ¶ added in v0.4.3
StringsIdToStr helper for passing []string key
Types ¶
type Event ¶ added in v0.4.1
type Event interface { Set(entry interface{}, value ...interface{}) error UseSetTransformer(ToBytesTransformer) Event UseNameTransformer(StringTransformer) Event }
Event interface for working with events in chaincode
type EventImpl ¶ added in v0.4.1
type EventImpl struct { NameTransformer StringTransformer SetTransformer ToBytesTransformer // contains filtered or unexported fields }
func NewEvent ¶ added in v0.4.1
func NewEvent(stub shim.ChaincodeStubInterface) *EventImpl
NewEvent creates wrapper on shim.ChaincodeStubInterface for working with events
func (*EventImpl) ArgNameValue ¶ added in v0.4.1
func (*EventImpl) UseNameTransformer ¶ added in v0.4.1
func (e *EventImpl) UseNameTransformer(nt StringTransformer) Event
func (*EventImpl) UseSetTransformer ¶ added in v0.4.1
func (e *EventImpl) UseSetTransformer(tb ToBytesTransformer) Event
type FromBytesTransformer ¶ added in v0.3.0
ToBytesTransformer is used after getState operation for convert value
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
type KeyTransformer ¶ added in v0.4.1
KeyTransformer is used before putState operation for convert key
type KeyValue ¶ added in v0.4.1
KeyValue interface combines Keyer as ToByter methods - state entry representation
type NameValue ¶ added in v0.4.1
NameValue interface combines Name() as ToByter methods - event representation
type State ¶ added in v0.3.0
type State interface { // Get returns value from state, converted to target type // entry can be Key (string or []string) or type implementing Keyer interface Get(entry interface{}, target ...interface{}) (result interface{}, err error) // Get returns value from state, converted to int // entry can be Key (string or []string) or type implementing Keyer interface GetInt(entry interface{}, defaultValue int) (result int, err error) // GetHistory returns slice of history records for entry, with values converted to target type // entry can be Key (string or []string) or type implementing Keyer interface GetHistory(entry interface{}, target interface{}) (result HistoryEntryList, err error) // Exists returns entry existence in state // entry can be Key (string or []string) or type implementing Keyer interface Exists(entry interface{}) (exists bool, err error) // Put returns result of putting entry to state // entry can be Key (string or []string) or type implementing Keyer interface // if entry is implements Keyer interface and it's struct or type implementing // ToByter interface value can be omitted Put(entry interface{}, value ...interface{}) (err error) // Insert returns result of inserting entry to state // If same key exists in state error wil be returned // entry can be Key (string or []string) or type implementing Keyer interface // if entry is implements Keyer interface and it's struct or type implementing // ToByter interface value can be omitted Insert(entry interface{}, value ...interface{}) (err error) // List returns slice of target type // namespace can be part of key (string or []string) or entity with defined mapping List(namespace interface{}, target ...interface{}) (result interface{}, err error) // Delete returns result of deleting entry from state // entry can be Key (string or []string) or type implementing Keyer interface Delete(entry interface{}) (err error) Logger() *shim.ChaincodeLogger UseKeyTransformer(KeyTransformer) State UseStateGetTransformer(FromBytesTransformer) State UseStatePutTransformer(ToBytesTransformer) State }
State interface for chain code CRUD operations
type StateImpl ¶ added in v0.3.0
type StateImpl struct { StateKeyTransformer KeyTransformer StateGetTransformer FromBytesTransformer StatePutTransformer ToBytesTransformer // contains filtered or unexported fields }
func NewState ¶ added in v0.4.1
func NewState(stub shim.ChaincodeStubInterface, logger *shim.ChaincodeLogger) *StateImpl
NewState creates wrapper on shim.ChaincodeStubInterface for working with state
func (*StateImpl) Get ¶ added in v0.3.0
Get data by key from state, trying to convert to target interface
func (*StateImpl) GetHistory ¶ added in v0.3.0
func (s *StateImpl) GetHistory(key interface{}, target interface{}) (result HistoryEntryList, err error)
GetHistory by key from state, trying to convert to target interface
func (*StateImpl) Insert ¶ added in v0.3.0
Insert value into chaincode state, returns error if key already exists
func (*StateImpl) List ¶ added in v0.3.0
func (s *StateImpl) List(namespace interface{}, target ...interface{}) (result interface{}, err error)
List data from state using objectType prefix in composite key, trying to conver to target interface. Keys - additional components of composite key
func (*StateImpl) Logger ¶ added in v0.4.1
func (s *StateImpl) Logger() *shim.ChaincodeLogger
func (*StateImpl) Put ¶ added in v0.3.0
Put data value in state with key, trying convert data to []byte
func (*StateImpl) UseKeyTransformer ¶ added in v0.4.1
func (s *StateImpl) UseKeyTransformer(kt KeyTransformer) State
func (*StateImpl) UseStateGetTransformer ¶ added in v0.4.1
func (s *StateImpl) UseStateGetTransformer(fb FromBytesTransformer) State
func (*StateImpl) UseStatePutTransformer ¶ added in v0.4.1
func (s *StateImpl) UseStatePutTransformer(tb ToBytesTransformer) State
type StateList ¶ added in v0.4.2
type StateList struct {
// contains filtered or unexported fields
}
func NewStateList ¶ added in v0.4.2
func (*StateList) Fill ¶ added in v0.4.2
func (sl *StateList) Fill(iter shim.StateQueryIteratorInterface, fromBytes FromBytesTransformer) (list interface{}, err error)
type StringTransformer ¶ added in v0.4.1
NameTransformer is used before setEvent operation for convert name
type StringsKeyer ¶ added in v0.4.1
StringsKeys interface for entity containing logic of its key creation - backward compatibility
type ToBytesTransformer ¶ added in v0.3.0
ToBytesTransformer is used before putState operation for convert payload