util

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2019 License: GPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultBaseURL is the default address of CouchDB server.
	DefaultBaseURL = "localhost:5984"
)

Variables

This section is empty.

Functions

func Changeinfo

func Changeinfo(stub shim.ChaincodeStubInterface, TableModel string, row_key []string, data interface{}) error

Update Infomation

func CheckChaincodeFunctionCallWellFormedness

func CheckChaincodeFunctionCallWellFormedness(args []string, expected_arg_count int) error

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 MakeErrorRetval

func MakeErrorRetval(error_message string, args ...interface{}) ([]byte, error)

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 NewMockFilterQueryIterator

func NewMockFilterQueryIterator(stub *MockStubExtend, keys *list.List) *mockFilterQueryIterator

Types

type CouchDBHandler

type CouchDBHandler struct {
	CouchDatabase *couchdb.CouchDatabase
}

func NewCouchDBHandler

func NewCouchDBHandler(dbName string, isDrop bool) (*CouchDBHandler, error)

NewCouchDBHandler returns a new CouchDBHandler and setup database for testing

func (*CouchDBHandler) QueryDocument

func (handler *CouchDBHandler) QueryDocument(query string) ([]*couchdb.QueryResult, error)

QueryDocument executes a query string and return results

func (*CouchDBHandler) SaveDocument

func (handler *CouchDBHandler) SaveDocument(key string, value []byte) (string, error)

SaveDocument stores a value in couchDB

func (*CouchDBHandler) UpdateDocument

func (handler *CouchDBHandler) UpdateDocument(key string, value []byte) error

UpdateDocument update 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 MockStateQueryIterator

type MockStateQueryIterator struct {
	Closed  bool
	Data    *map[string][]byte
	Current *list.Element
}

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

func (*MockStubExtend) GetFunctionAndParameters

func (stub *MockStubExtend) GetFunctionAndParameters() (function string, params []string)

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) GetStringArgs

func (stub *MockStubExtend) GetStringArgs() []string

Override this function from MockStub

func (*MockStubExtend) MockInit

func (stub *MockStubExtend) MockInit(uuid string, args [][]byte) pb.Response

Override this function from MockStub

func (*MockStubExtend) MockInvoke

func (stub *MockStubExtend) MockInvoke(uuid string, args [][]byte) pb.Response

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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL