Documentation ¶
Index ¶
- Constants
- func Changeinfo(stub shim.ChaincodeStubInterface, TableModel string, row_key []string, ...) error
- func CheckChaincodeFunctionCallWellFormedness(args []string, expected_arg_count int) error
- func Createdata(stub shim.ChaincodeStubInterface, TableModel string, row_key []string, ...) error
- func DeleteTableRow(stub shim.ChaincodeStubInterface, table_name string, row_keys []string, ...) (rowWasFound bool, err error)
- func GetAllData(stub shim.ChaincodeStubInterface, data interface{}, ModelTable string) pb.Response
- func GetDataByID(stub shim.ChaincodeStubInterface, DataID string, data interface{}, ...) pb.Response
- func GetDataByRowKeys(stub shim.ChaincodeStubInterface, rowKeys []string, data interface{}, ...) pb.Response
- func GetTableRow(stub shim.ChaincodeStubInterface, table_name string, row_keys []string, ...) (rowWasFound bool, err error)
- func GetTableRows(stub shim.ChaincodeStubInterface, table_name string, row_keys []string) (chan []byte, error)
- func Getalldata(stub shim.ChaincodeStubInterface, MODELTABLE string) (chan []byte, error)
- func Getdatabyid(stub shim.ChaincodeStubInterface, ID string, MODELTABLE string) (interface{}, error)
- func Getdatabyrowkeys(stub shim.ChaincodeStubInterface, rowKeys []string, MODELTABLE string) (interface{}, error)
- func InsertTableRow(stub shim.ChaincodeStubInterface, table_name string, row_keys []string, ...) (rowWasFound bool, err error)
- func InterfaceIsNilOrIsZeroOfUnderlyingType(x interface{}) bool
- func MakeErrorRetval(error_message string, args ...interface{}) ([]byte, error)
- func MockInitTransaction(t *testing.T, stub *MockStubExtend, args [][]byte) string
- func MockInvokeTransaction(t *testing.T, stub *MockStubExtend, args [][]byte) string
- func MockQueryTransaction(t *testing.T, stub *MockStubExtend, args [][]byte) string
- func UpdateExistingData(stub shim.ChaincodeStubInterface, TableModel string, row_key []string, ...) error
- func UpdateTableRow(stub shim.ChaincodeStubInterface, table_name string, row_keys []string, ...) (err error)
- type AkcQueryIterator
- type CouchDBHandler
- func (handler *CouchDBHandler) QueryDocument(query string) (statedb.ResultsIterator, error)
- func (handler *CouchDBHandler) QueryDocumentByRange(startKey, endKey string) (statedb.ResultsIterator, error)
- func (handler *CouchDBHandler) QueryDocumentWithPagination(query string, limit int32, bookmark string) (statedb.ResultsIterator, error)
- func (handler *CouchDBHandler) ReadDocument(id string) ([]byte, error)
- func (handler *CouchDBHandler) SaveDocument(key string, value []byte) error
- type GetTableRow_FailureOption
- type InsertTableRow_FailureOption
- type MockStubExtend
- func (stub *MockStubExtend) GetFunctionAndParameters() (function string, params []string)
- func (stub *MockStubExtend) GetQueryResult(query string) (StateQueryIteratorInterface, error)
- func (stub *MockStubExtend) GetQueryResultWithPagination(query string, pageSize int32, bookmark string) (StateQueryIteratorInterface, *pb.QueryResponseMetadata, error)
- func (stub *MockStubExtend) GetState(key string) ([]byte, error)
- func (stub *MockStubExtend) GetStateByPartialCompositeKey(objectType string, attributes []string) (StateQueryIteratorInterface, error)
- func (stub *MockStubExtend) GetStateOriginal(key string) ([]byte, error)
- func (stub *MockStubExtend) GetStringArgs() []string
- func (stub *MockStubExtend) MockInit(uuid string, args [][]byte) pb.Response
- func (stub *MockStubExtend) MockInvoke(uuid string, args [][]byte) pb.Response
- func (stub *MockStubExtend) PutState(key string, value []byte) error
- func (stub *MockStubExtend) SetCouchDBConfiguration(handler *CouchDBHandler)
Constants ¶
const ( // DefaultBaseURL is the default address of CouchDB server. DefaultBaseURL = "localhost:5984" // The couchDB test will have this name: DefaultChannelName_DefaultNamespace DefaultChannelName = "channel" // Fabric channel DefaultChaincodeName = "chaincode" // Fabric chaincode )
Variables ¶
This section is empty.
Functions ¶
func Changeinfo ¶
func Changeinfo(stub shim.ChaincodeStubInterface, TableModel string, row_key []string, data interface{}) error
Update Infomation
func Createdata ¶
func Createdata(stub shim.ChaincodeStubInterface, TableModel string, row_key []string, data interface{}) error
create data
func DeleteTableRow ¶
func DeleteTableRow( stub shim.ChaincodeStubInterface, table_name string, row_keys []string, old_row_value interface{}, failure_option GetTableRow_FailureOption, ) (rowWasFound bool, err error)
If old_row_value is not nil, then the table row will be unmarshaled into old_row_value before being deleted.
func GetAllData ¶
func GetAllData(stub shim.ChaincodeStubInterface, data interface{}, ModelTable string) pb.Response
GetAllData
func GetDataByID ¶
func GetDataByID(stub shim.ChaincodeStubInterface, DataID string, data interface{}, ModelTable string) pb.Response
GetDataByID
func GetDataByRowKeys ¶
func GetDataByRowKeys(stub shim.ChaincodeStubInterface, rowKeys []string, data interface{}, ModelTable string) pb.Response
GetDataByKey
func GetTableRow ¶
func GetTableRow( stub shim.ChaincodeStubInterface, table_name string, row_keys []string, row_value interface{}, failure_option GetTableRow_FailureOption, ) (rowWasFound bool, err error)
If row_value is nil, then don't bother unmarshaling the data. Thus a check for the presence of a particular table row can be done by specifying nil for row_value.
func GetTableRows ¶
func GetTableRows( stub shim.ChaincodeStubInterface, table_name string, row_keys []string, ) (chan []byte, error)
If row_value is nil, then don't bother unmarshaling the data. Thus a check for the presence of a particular table row can be done by specifying nil for row_value.
func Getalldata ¶
func Getalldata(stub shim.ChaincodeStubInterface, MODELTABLE string) (chan []byte, error)
get all data
func Getdatabyid ¶
func Getdatabyid(stub shim.ChaincodeStubInterface, ID string, MODELTABLE string) (interface{}, error)
get information of data by ID
func Getdatabyrowkeys ¶
func Getdatabyrowkeys(stub shim.ChaincodeStubInterface, rowKeys []string, MODELTABLE string) (interface{}, error)
get information of data by row keys
func InsertTableRow ¶
func InsertTableRow( stub shim.ChaincodeStubInterface, table_name string, row_keys []string, new_row_value interface{}, failure_option InsertTableRow_FailureOption, old_row_value interface{}, ) (rowWasFound bool, err error)
NOTE: This is the current abstraction to port old v0.6 style tables to current non-tables style ledger. Note that row_value must be json.Marshal-able. If old_row_value is not nil and the requested row is present, then the row will be unmarshaled into old_row_value before the new value (specified by row_value). Note that if FAIL_BEFORE_OVERWRITE is triggered, then old_row_value will contain the row that existed already that triggered the failure. If an error is returned, then the table will not have been modified (TODO: Probably need to verify this).
func InterfaceIsNilOrIsZeroOfUnderlyingType ¶
func InterfaceIsNilOrIsZeroOfUnderlyingType(x interface{}) bool
Taken from https://stackoverflow.com/questions/13901819/quick-way-to-detect-empty-values-via-reflection-in-go
func MakeErrorRetval ¶
Pass through to Sprintf
func MockInitTransaction ¶
func MockInitTransaction(t *testing.T, stub *MockStubExtend, args [][]byte) string
MockIInit creates a mock invoke transaction using MockStubExtend
func MockInvokeTransaction ¶
func MockInvokeTransaction(t *testing.T, stub *MockStubExtend, args [][]byte) string
MockInvokeTransaction creates a mock invoke transaction using MockStubExtend
func MockQueryTransaction ¶
func MockQueryTransaction(t *testing.T, stub *MockStubExtend, args [][]byte) string
MockQueryTransaction creates a mock query transaction using MockStubExtend
func UpdateExistingData ¶ added in v1.0.9
func UpdateExistingData(stub shim.ChaincodeStubInterface, TableModel string, row_key []string, data interface{}) error
UpdateExistingData works similar to Changeinfo. However, it does not check if the document is already existed This is useful if we already query out the row before and do not want to query again.
func UpdateTableRow ¶ added in v1.0.9
func UpdateTableRow( stub shim.ChaincodeStubInterface, table_name string, row_keys []string, new_row_value interface{}, ) (err error)
UpdateTableRow is similar to InsertTableRow without re-checking if the row is already exist
Types ¶
type AkcQueryIterator ¶ added in v1.0.9
type AkcQueryIterator struct { *StateQueryIterator // contains filtered or unexported fields }
AkcQueryIterator inherits StateQueryIterator to simulate how the peer handle query string response
func FromResultsIterator ¶ added in v1.0.9
func FromResultsIterator(rit statedb.ResultsIterator) (*AkcQueryIterator, error)
FromResultsIterator provides a way of converting ResultsIterator into StateQueryIterator
func (*AkcQueryIterator) Close ¶ added in v1.0.9
func (it *AkcQueryIterator) Close() error
func (*AkcQueryIterator) HasNext ¶ added in v1.0.9
func (it *AkcQueryIterator) HasNext() bool
func (*AkcQueryIterator) Length ¶ added in v1.0.9
func (it *AkcQueryIterator) Length() int
func (*AkcQueryIterator) Next ¶ added in v1.0.9
func (it *AkcQueryIterator) Next() (*queryresult.KV, error)
type CouchDBHandler ¶
type CouchDBHandler struct {
// contains filtered or unexported fields
}
CouchDBHandler holds 1 parameter: dbEngine: a VersionedDB object that is used by the chaincode to query. This is to guarantee that the test uses the same logic in interaction with stateDB as the chaincode. This also includes how chaincode builds its query to interact with the stateDB.
func NewCouchDBHandler ¶
func NewCouchDBHandler(dbName string, isDrop bool) (*CouchDBHandler, error)
NewCouchDBHandler that is compatibles with previous release
func NewCouchDBHandlerWithConnection ¶ added in v1.0.5
func NewCouchDBHandlerWithConnection(dbName string, isDrop bool, connectionString string) (*CouchDBHandler, error)
NewCouchDBHandlerWithConnection that is compatibles with previous release
func NewCouchDBHandlerWithConnectionAuthentication ¶ added in v1.0.9
func NewCouchDBHandlerWithConnectionAuthentication(isDrop bool) (*CouchDBHandler, error)
NewCouchDBHandlerWithConnectionAuthentication returns a new CouchDBHandler and setup database for testing
func (*CouchDBHandler) QueryDocument ¶
func (handler *CouchDBHandler) QueryDocument(query string) (statedb.ResultsIterator, error)
QueryDocument executes a query string and return results
func (*CouchDBHandler) QueryDocumentByRange ¶ added in v1.0.9
func (handler *CouchDBHandler) QueryDocumentByRange(startKey, endKey string) (statedb.ResultsIterator, error)
QueryDocumentByRange get a list of documents from couchDB by key range
func (*CouchDBHandler) QueryDocumentWithPagination ¶ added in v1.0.9
func (handler *CouchDBHandler) QueryDocumentWithPagination(query string, limit int32, bookmark string) (statedb.ResultsIterator, error)
QueryDocumentWithPagination executes a query string and return results
func (*CouchDBHandler) ReadDocument ¶ added in v1.0.9
func (handler *CouchDBHandler) ReadDocument(id string) ([]byte, error)
ReadDocument executes a query string and return results
func (*CouchDBHandler) SaveDocument ¶
func (handler *CouchDBHandler) SaveDocument(key string, value []byte) error
SaveDocument stores a value in couchDB
type GetTableRow_FailureOption ¶
type GetTableRow_FailureOption bool
This is effectively a strongly typed enum declaration.
const ( DONT_FAIL_IF_MISSING GetTableRow_FailureOption = false FAIL_IF_MISSING GetTableRow_FailureOption = true )
type InsertTableRow_FailureOption ¶
type InsertTableRow_FailureOption uint8
This is effectively a strongly typed enum declaration.
const ( DONT_FAIL_UPON_OVERWRITE InsertTableRow_FailureOption = 0 FAIL_BEFORE_OVERWRITE InsertTableRow_FailureOption = 1 FAIL_UNLESS_OVERWRITE InsertTableRow_FailureOption = 2 )
type MockStubExtend ¶
type MockStubExtend struct { CouchDB bool // if we use couchDB DbHandler *CouchDBHandler // if we use couchDB *MockStub // contains filtered or unexported fields }
MockStubExtend provides composition class for MockStub as some of the mockstub methods are not implemented
func NewMockStubExtend ¶
func NewMockStubExtend(stub *MockStub, c Chaincode) *MockStubExtend
NewMockStubExtend constructor
func (*MockStubExtend) GetFunctionAndParameters ¶
func (stub *MockStubExtend) GetFunctionAndParameters() (function string, params []string)
GetFunctionAndParameters Override this function from MockStub
func (*MockStubExtend) GetQueryResult ¶
func (stub *MockStubExtend) GetQueryResult(query string) (StateQueryIteratorInterface, error)
GetQueryResult overrides the same function in MockStub that did not implement anything.
func (*MockStubExtend) GetQueryResultWithPagination ¶ added in v1.0.9
func (stub *MockStubExtend) GetQueryResultWithPagination(query string, pageSize int32, bookmark string) (StateQueryIteratorInterface, *pb.QueryResponseMetadata, error)
GetQueryResultWithPagination overrides the same function in MockStub that did not implement anything.
func (*MockStubExtend) GetState ¶ added in v1.0.9
func (stub *MockStubExtend) GetState(key string) ([]byte, error)
GetState retrieves the value for a given key from the ledger
func (*MockStubExtend) GetStateByPartialCompositeKey ¶ added in v1.0.9
func (stub *MockStubExtend) GetStateByPartialCompositeKey(objectType string, attributes []string) (StateQueryIteratorInterface, error)
GetStateByPartialCompositeKey queries couchdb by range
func (*MockStubExtend) GetStateOriginal ¶ added in v1.0.9
func (stub *MockStubExtend) GetStateOriginal(key string) ([]byte, error)
GetStateOriginal is copied from mockstub as we still need to carry on normal GetState operation with the mock ledger map
func (*MockStubExtend) GetStringArgs ¶
func (stub *MockStubExtend) GetStringArgs() []string
GetStringArgs override this function from MockStub
func (*MockStubExtend) MockInit ¶
func (stub *MockStubExtend) MockInit(uuid string, args [][]byte) pb.Response
MockInit Override this function from MockStub
func (*MockStubExtend) MockInvoke ¶
func (stub *MockStubExtend) MockInvoke(uuid string, args [][]byte) pb.Response
MockInvoke Override this function from MockStub
func (*MockStubExtend) PutState ¶
func (stub *MockStubExtend) PutState(key string, value []byte) error
PutState writes the specified `value` and `key` into the ledger.
func (*MockStubExtend) SetCouchDBConfiguration ¶
func (stub *MockStubExtend) SetCouchDBConfiguration(handler *CouchDBHandler)
SetCouchDBConfiguration sets the couchdb configuration with appropriate database handler