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(key *TransformedKey) error
- func KeyToString(stub shim.ChaincodeStubInterface, key Key) (string, error)
- func NameAsIs(name string) (string, error)
- func NormalizeEventName(name interface{}) (string, error)
- func StringsIdFromStr(idString string) []string
- func StringsIdToStr(idSlice []string) string
- type Combination
- type CombinationType
- type EqualCondition
- 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 ExistCondition
- type Filter
- type FromBytesTransformer
- type GreaterThanCondition
- type GreaterThanOrEqualCondition
- type HistoryEntry
- type HistoryEntryList
- type Impl
- func (s *Impl) Delete(entry interface{}) error
- func (s *Impl) DeletePrivate(collection string, entry interface{}) error
- func (s *Impl) Exists(entry interface{}) (bool, error)
- func (s *Impl) ExistsPrivate(collection string, entry interface{}) (bool, error)
- func (s *Impl) Get(entry interface{}, config ...interface{}) (interface{}, error)
- func (s *Impl) GetHistory(entry interface{}, target interface{}) (HistoryEntryList, error)
- func (s *Impl) GetInt(key interface{}, defaultValue int) (int, error)
- func (s *Impl) GetPrivate(collection string, entry interface{}, config ...interface{}) (interface{}, error)
- func (s *Impl) Insert(entry interface{}, values ...interface{}) error
- func (s *Impl) InsertPrivate(collection string, entry interface{}, values ...interface{}) (err error)
- func (s *Impl) Key(key interface{}) (*TransformedKey, error)
- func (s *Impl) List(namespace interface{}, target ...interface{}) (interface{}, error)
- func (s *Impl) ListPrivate(collection string, usePrivateDataIterator bool, namespace interface{}, ...) (interface{}, error)
- func (s *Impl) Logger() *shim.ChaincodeLogger
- func (s *Impl) PaginateList(objectType interface{}, target interface{}, limit int32, start string) (result []interface{}, end string, err error)
- func (s *Impl) Put(entry interface{}, values ...interface{}) error
- func (s *Impl) PutPrivate(collection string, entry interface{}, values ...interface{}) (err error)
- func (s *Impl) RichListQuery(query string, target interface{}, pageSize int32, bookmark string) (result []interface{}, newBookmark string, err error)
- func (s *Impl) RichQuery(query string, target interface{}, pageSize int) ([]interface{}, int, error)
- func (s *Impl) UseKeyTransformer(kt KeyTransformer) State
- func (s *Impl) UseStateGetTransformer(fb FromBytesTransformer) State
- func (s *Impl) UseStatePutTransformer(tb ToBytesTransformer) State
- type InCondition
- type Key
- type KeyFunc
- type KeyTransformer
- type KeyValue
- type Keyer
- type KeyerFunc
- type LessThanCondition
- type LessThanOrEqualCondition
- type ModCondition
- type NameValue
- type Namer
- type NotEqualCondition
- type QueryBuilder
- func (builder *QueryBuilder) AddCombination(combinationType CombinationType, filters ...interface{}) *Combination
- func (builder *QueryBuilder) AddCondition(field string, condition interface{}) *QueryBuilder
- func (builder *QueryBuilder) AddField(fields ...string) *QueryBuilder
- func (builder *QueryBuilder) AddFilter(field string, value interface{}) *QueryBuilder
- func (builder *QueryBuilder) AddManySorts(sortRequest []string) error
- func (builder *QueryBuilder) AddSort(field string, sortOrder string) *QueryBuilder
- func (builder *QueryBuilder) AddUseIndex(index string) *QueryBuilder
- func (builder *QueryBuilder) Build() (string, error)
- func (builder *QueryBuilder) SetDocType(docType string) *QueryBuilder
- func (builder *QueryBuilder) SetLimit(limit int) *QueryBuilder
- func (builder *QueryBuilder) SetSkip(skip int) *QueryBuilder
- type RegExCondition
- type SizeCondition
- type State
- type StateList
- type StringTransformer
- type StringsKeyer
- type ToBytesTransformer
- type TransformedKey
- type TypeCondition
Constants ¶
This section is empty.
Variables ¶
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 KeyToString ¶ added in v0.6.3
func KeyToString(stub shim.ChaincodeStubInterface, key Key) (string, error)
func NormalizeEventName ¶ added in v0.4.1
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 Combination ¶ added in v0.3.11
type Combination struct { Type CombinationType Value []interface{} Filters []Filter Conditions []interface{} Combinations []*Combination Builder *QueryBuilder }
Combination used for and,or,nor,all operators
func (*Combination) AddCombination ¶ added in v0.3.11
func (c *Combination) AddCombination(combinationType CombinationType, filters ...interface{}) *Combination
AddCombination adds a combination to an existing one for nesting
type CombinationType ¶ added in v0.3.11
type CombinationType string
CombinationType type of combination
const ( // Matches if all the selectors in the array match. AND CombinationType = "$and" // Matches if any of the selectors in the array match. All selectors must use the same index. OR CombinationType = "$or" // Matches an array value if it contains all the elements of the argument array. ALL CombinationType = "$all" // Matches if none of the selectors in the array match. NOR CombinationType = "$nor" )
type EqualCondition ¶ added in v0.3.12
type EqualCondition struct {
Value interface{} `json:"$eq"`
}
EqualCondition The field is equal to the argument
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 ExistCondition ¶ added in v0.3.12
type ExistCondition struct {
Value bool `json:"$exists"`
}
ExistCondition Check whether the field exists or not, regardless of its value.
type Filter ¶ added in v0.3.11
type Filter struct { Field string Value interface{} }
Filter used to filter on a single field
type FromBytesTransformer ¶ added in v0.3.0
ToBytesTransformer is used after getState operation for convert value
type GreaterThanCondition ¶ added in v0.3.12
type GreaterThanCondition struct {
Value interface{} `json:"$gt"`
}
GreaterThanCondition The field is greater than to the argument.
type GreaterThanOrEqualCondition ¶ added in v0.3.12
type GreaterThanOrEqualCondition struct {
Value interface{} `json:"$gte"`
}
GreaterThanCondition The field is greater than or equal to the argument.
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 Impl ¶ added in v0.6.3
type Impl 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) *Impl
NewState creates wrapper on shim.ChaincodeStubInterface for working with state
func (*Impl) DeletePrivate ¶ added in v0.6.3
Delete entry from private state
func (*Impl) ExistsPrivate ¶ added in v0.6.3
PrivateExists check entry with key exists in chaincode private state
func (*Impl) Get ¶ added in v0.6.3
Get data by key from state, trying to convert to target interface
func (*Impl) GetHistory ¶ added in v0.6.3
func (s *Impl) GetHistory(entry interface{}, target interface{}) (HistoryEntryList, error)
GetHistory by key from state, trying to convert to target interface
func (*Impl) GetPrivate ¶ added in v0.6.3
func (s *Impl) GetPrivate(collection string, entry interface{}, config ...interface{}) (interface{}, error)
Get data by key from private state, trying to convert to target interface
func (*Impl) Insert ¶ added in v0.6.3
Insert value into chaincode state, returns error if key already exists
func (*Impl) InsertPrivate ¶ added in v0.6.3
func (s *Impl) InsertPrivate(collection string, entry interface{}, values ...interface{}) (err error)
Insert value into chaincode private state, returns error if key already exists
func (*Impl) Key ¶ added in v0.6.3
func (s *Impl) Key(key interface{}) (*TransformedKey, error)
func (*Impl) List ¶ added in v0.6.3
List data from state using objectType prefix in composite key, trying to convert to target interface. Keys - additional components of composite key
func (*Impl) ListPrivate ¶ added in v0.6.3
func (s *Impl) ListPrivate(collection string, usePrivateDataIterator bool, namespace interface{}, target ...interface{}) (interface{}, error)
List data from private state using objectType prefix in composite key, trying to convert to target interface. Keys - additional components of composite key If usePrivateDataIterator is true, used private state for iterate over objects if false, used public state for iterate over keys and GetPrivateData for each key
func (*Impl) Logger ¶ added in v0.6.3
func (s *Impl) Logger() *shim.ChaincodeLogger
func (*Impl) PaginateList ¶ added in v0.6.3
func (*Impl) PutPrivate ¶ added in v0.6.3
Put data value in private state with key, trying convert data to []byte
func (*Impl) RichListQuery ¶ added in v0.6.3
func (*Impl) UseKeyTransformer ¶ added in v0.6.3
func (s *Impl) UseKeyTransformer(kt KeyTransformer) State
func (*Impl) UseStateGetTransformer ¶ added in v0.6.3
func (s *Impl) UseStateGetTransformer(fb FromBytesTransformer) State
func (*Impl) UseStatePutTransformer ¶ added in v0.6.3
func (s *Impl) UseStatePutTransformer(tb ToBytesTransformer) State
type InCondition ¶ added in v0.3.12
type InCondition struct {
Value []interface{} `json:"$in"`
}
InCondition The document field must exist in the list provided.
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 Keyer ¶
Keyer interface for entity containing logic of its key creation
func StringKeyer ¶
StringKeyer constructor for struct implementing Keyer interface
type LessThanCondition ¶ added in v0.3.12
type LessThanCondition struct {
Value interface{} `json:"$lt"`
}
LessThanCondition The field is less than the argument
type LessThanOrEqualCondition ¶ added in v0.3.12
type LessThanOrEqualCondition struct {
Value interface{} `json:"$lte"`
}
LessThanOrEqualCondition The field is less than or equal to the argument.
type ModCondition ¶ added in v0.3.12
type ModCondition struct {
Value [2]int `json:"$mod"`
}
ModCondition [Divisor, Remainder] Divisor and Remainder are both positive or negative integers. Non-integer values result in a 404. Matches documents where field % Divisor == Remainder is true, and only when the document field is an integer.
type NameValue ¶ added in v0.4.1
NameValue interface combines Name() as ToByter methods - event representation
type NotEqualCondition ¶ added in v0.3.12
type NotEqualCondition struct {
Value interface{} `json:"$neq"`
}
NotEqualCondition The field is not equal to the argument
type QueryBuilder ¶ added in v0.3.11
type QueryBuilder struct {
// contains filtered or unexported fields
}
QueryBuilder used to generate couchDB queries
func NewQB ¶ added in v0.3.11
func NewQB() *QueryBuilder
NewQB create a new instance of the QueryBuilder
func (*QueryBuilder) AddCombination ¶ added in v0.3.11
func (builder *QueryBuilder) AddCombination(combinationType CombinationType, filters ...interface{}) *Combination
AddCombination adds a combination to the builder query
func (*QueryBuilder) AddCondition ¶ added in v0.3.11
func (builder *QueryBuilder) AddCondition(field string, condition interface{}) *QueryBuilder
AddCondition adds a pre-defined CouchDB condition filter to the CouchDB query
func (*QueryBuilder) AddField ¶ added in v0.3.11
func (builder *QueryBuilder) AddField(fields ...string) *QueryBuilder
AddField adds a field to the couchDB query
func (*QueryBuilder) AddFilter ¶ added in v0.3.11
func (builder *QueryBuilder) AddFilter(field string, value interface{}) *QueryBuilder
AddFilter adds a filter to filter on in the couchDB query
func (*QueryBuilder) AddManySorts ¶ added in v0.3.11
func (builder *QueryBuilder) AddManySorts(sortRequest []string) error
func (*QueryBuilder) AddSort ¶ added in v0.3.11
func (builder *QueryBuilder) AddSort(field string, sortOrder string) *QueryBuilder
AddSort adds a field to sort on in the couchDB query
func (*QueryBuilder) AddUseIndex ¶ added in v0.3.11
func (builder *QueryBuilder) AddUseIndex(index string) *QueryBuilder
func (*QueryBuilder) Build ¶ added in v0.3.11
func (builder *QueryBuilder) Build() (string, error)
Build constructs the query and outputs the final result
func (*QueryBuilder) SetDocType ¶ added in v0.3.11
func (builder *QueryBuilder) SetDocType(docType string) *QueryBuilder
SetDocType set the main doc type for the couchDB query
func (*QueryBuilder) SetLimit ¶ added in v0.3.11
func (builder *QueryBuilder) SetLimit(limit int) *QueryBuilder
SetLimit sets the limit for paging
func (*QueryBuilder) SetSkip ¶ added in v0.3.11
func (builder *QueryBuilder) SetSkip(skip int) *QueryBuilder
SetSkip sets the skip value for paging
type RegExCondition ¶ added in v0.3.12
type RegExCondition struct {
Value string `json:"$regex"`
}
RegExCondition A regular expression pattern to match against the document field. Only matches when the field is a string value and matches the supplied regular expression. The matching algorithms are based on the Perl Compatible Regular Expression (PCRE) library. For more information about what is implemented, see the see the Erlang Regular Expressio
type SizeCondition ¶ added in v0.3.12
type SizeCondition struct {
Value uint `json:"$size"`
}
SizeCondition Special condition to match the length of an array field in a document. Non-array fields cannot match this condition.
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 // GetPrivate returns value from private state, converted to target type // entry can be Key (string or []string) or type implementing Keyer interface GetPrivate(collection string, entry interface{}, target ...interface{}) (result interface{}, err error) // PutPrivate returns result of putting entry to private 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 PutPrivate(collection string, entry interface{}, value ...interface{}) (err error) // InsertPrivate returns result of inserting entry to private 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 InsertPrivate(collection string, entry interface{}, value ...interface{}) (err error) // ListPrivate returns slice of target type from private state // namespace can be part of key (string or []string) or entity with defined mapping // If usePrivateDataIterator is true, used private state for iterate over objects // if false, used public state for iterate over keys and GetPrivateData for each key ListPrivate(collection string, usePrivateDataIterator bool, namespace interface{}, target ...interface{}) (result interface{}, err error) // DeletePrivate returns result of deleting entry from private state // entry can be Key (string or []string) or type implementing Keyer interface DeletePrivate(collection string, entry interface{}) (err error) // ExistsPrivate returns entry existence in private state // entry can be Key (string or []string) or type implementing Keyer interface ExistsPrivate(collection string, entry interface{}) (exists bool, err error) // PaginateList allows to list keys by prefix with pagination PaginateList(objectType interface{}, target interface{}, pageSize int32, start string) (result []interface{}, end string, err error) // RichListQuery allows to perform rich state DB query using state DB syntax with bookmark pagination RichListQuery(query string, target interface{}, pageSize int32, bookmark string) (result []interface{}, newBookmark string, err error) // RichQuery allows to perform rich state DB query using state DB syntax RichQuery(query string, target interface{}, pageSize int) ([]interface{}, int, error) }
State interface for chain code CRUD operations
type StateList ¶ added in v0.4.2
type StateList struct {
// contains filtered or unexported fields
}
func NewStateList ¶ added in v0.4.2
func NewStateList(config ...interface{}) *StateList
func (*StateList) AddElementToList ¶ added in v0.6.3
func (sl *StateList) AddElementToList(elem interface{})
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
type TransformedKey ¶ added in v0.6.3
StateKey stores origin and transformed state key
type TypeCondition ¶ added in v0.3.12
type TypeCondition struct {
Value string `json:"$type"`
}
TypeCondition Check the document field’s type. Valid values are "null", "boolean", "number", "string", "array", and "object".