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 KeyError(strKey string) error
- func KeyFromParts(stub shim.ChaincodeStubInterface, keyParts []string) (string, error)
- func KeyParts(key interface{}) ([]string, error)
- type FromBytesTransformer
- type HistoryEntry
- type HistoryEntryList
- type KeyPartsTransformer
- type Keyer
- type KeyerFunc
- type State
- type StateImpl
- func (s *StateImpl) Delete(key interface{}) (err error)
- func (s *StateImpl) Exists(key 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(key interface{}, values ...interface{}) (err error)
- func (s *StateImpl) Key(key interface{}) (string, error)
- func (s *StateImpl) List(objectType interface{}, target ...interface{}) (result []interface{}, err error)
- func (s *StateImpl) Put(key interface{}, values ...interface{}) (err error)
- type ToBytesTransformer
Constants ¶
This section is empty.
Variables ¶
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`) )
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 KeyFromParts ¶
func KeyFromParts(stub shim.ChaincodeStubInterface, keyParts []string) (string, error)
KeyFromParts creates composite key by string slice
Types ¶
type FromBytesTransformer ¶ added in v0.3.0
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 KeyPartsTransformer ¶ added in v0.3.0
type Keyer ¶
Keyer interface for entity containing logic of its key creation
func StringKeyer ¶
StringKeyer constructor for struct implementing Keyer interface
type State ¶ added in v0.3.0
type State interface { Get(key interface{}, target ...interface{}) (result interface{}, err error) GetInt(key interface{}, defaultValue int) (result int, err error) GetHistory(key interface{}, target interface{}) (result HistoryEntryList, err error) Exists(key interface{}) (exists bool, err error) Put(key interface{}, value ...interface{}) (err error) Insert(key interface{}, value ...interface{}) (err error) List(objectType interface{}, target ...interface{}) (result []interface{}, err error) Delete(key interface{}) (err error) }
State interface for chain code CRUD operations
type StateImpl ¶ added in v0.3.0
type StateImpl struct { KeyParts KeyPartsTransformer StateGetTransformer FromBytesTransformer StatePutTransformer ToBytesTransformer // contains filtered or unexported fields }
func New ¶ added in v0.3.0
func New(stub shim.ChaincodeStubInterface) *StateImpl
New creates wrapper on shim.ChaincodeStubInterface 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