shim

package
v0.6.1-preview Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2016 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package shim provides APIs for the chaincode to access its state variables, transaction context and call other chaincodes.

Interfaces to allow testing of chaincode apps with mocked up stubs

Package shim provides APIs for the chaincode to access its state variables, transaction context and call other chaincodes.

Package shim is a generated protocol buffer package.

It is generated from these files:

table.proto

It has these top-level messages:

ColumnDefinition
Table
Column
Row

Index

Constants

View Source
const (
	LogDebug    = LoggingLevel(logging.DEBUG)
	LogInfo     = LoggingLevel(logging.INFO)
	LogNotice   = LoggingLevel(logging.NOTICE)
	LogWarning  = LoggingLevel(logging.WARNING)
	LogError    = LoggingLevel(logging.ERROR)
	LogCritical = LoggingLevel(logging.CRITICAL)
)

These constants comprise the LoggingLevel enumeration

Variables

View Source
var ColumnDefinition_Type_name = map[int32]string{
	0: "STRING",
	1: "INT32",
	2: "INT64",
	3: "UINT32",
	4: "UINT64",
	5: "BYTES",
	6: "BOOL",
}
View Source
var ColumnDefinition_Type_value = map[string]int32{
	"STRING": 0,
	"INT32":  1,
	"INT64":  2,
	"UINT32": 3,
	"UINT64": 4,
	"BYTES":  5,
	"BOOL":   6,
}
View Source
var (
	// ErrTableNotFound if the specified table cannot be found
	ErrTableNotFound = errors.New("chaincode: Table not found")
)

Table Errors

Functions

func SetLoggingLevel

func SetLoggingLevel(level LoggingLevel)

SetLoggingLevel allows a Go language chaincode to set the logging level of its shim.

func Start

func Start(cc Chaincode) error

Start is the entry point for chaincodes bootstrap. It is not an API for chaincodes.

func StartInProc

func StartInProc(env []string, args []string, cc Chaincode, recv <-chan *pb.ChaincodeMessage, send chan<- *pb.ChaincodeMessage) error

StartInProc is an entry point for system chaincodes bootstrap. It is not an API for chaincodes.

Types

type Chaincode

type Chaincode interface {
	// Init is called during Deploy transaction after the container has been
	// established, allowing the chaincode to initialize its internal data
	Init(stub ChaincodeStubInterface, function string, args []string) ([]byte, error)

	// Invoke is called for every Invoke transactions. The chaincode may change
	// its state variables
	Invoke(stub ChaincodeStubInterface, function string, args []string) ([]byte, error)

	// Query is called for Query transactions. The chaincode may only read
	// (but not modify) its state variables and return the result
	Query(stub ChaincodeStubInterface, function string, args []string) ([]byte, error)
}

Chaincode interface must be implemented by all chaincodes. The fabric runs the transactions by calling these functions as specified.

type ChaincodeLogger

type ChaincodeLogger struct {
	// contains filtered or unexported fields
}

ChaincodeLogger is an abstraction of a logging object for use by chaincodes. These objects are created by the NewLogger API.

func NewLogger

func NewLogger(name string) *ChaincodeLogger

NewLogger allows a Go language chaincode to create one or more logging objects whose logs will be formatted consistently with, and temporally interleaved with the logs created by the shim interface. The logs created by this object can be distinguished from shim logs by the name provided, which will appear in the logs.

func (*ChaincodeLogger) Critical

func (c *ChaincodeLogger) Critical(args ...interface{})

Critical logs always appear; They can not be disabled.

func (*ChaincodeLogger) Criticalf

func (c *ChaincodeLogger) Criticalf(format string, args ...interface{})

Criticalf logs always appear; They can not be disabled.

func (*ChaincodeLogger) Debug

func (c *ChaincodeLogger) Debug(args ...interface{})

Debug logs will only appear if the ChaincodeLogger LoggingLevel is set to LogDebug.

func (*ChaincodeLogger) Debugf

func (c *ChaincodeLogger) Debugf(format string, args ...interface{})

Debugf logs will only appear if the ChaincodeLogger LoggingLevel is set to LogDebug.

func (*ChaincodeLogger) Error

func (c *ChaincodeLogger) Error(args ...interface{})

Error logs will appear if the ChaincodeLogger LoggingLevel is set to LogError, LogWarning, LogNotice, LogInfo or LogDebug.

func (*ChaincodeLogger) Errorf

func (c *ChaincodeLogger) Errorf(format string, args ...interface{})

Errorf logs will appear if the ChaincodeLogger LoggingLevel is set to LogError, LogWarning, LogNotice, LogInfo or LogDebug.

func (*ChaincodeLogger) Info

func (c *ChaincodeLogger) Info(args ...interface{})

Info logs will appear if the ChaincodeLogger LoggingLevel is set to LogInfo or LogDebug.

func (*ChaincodeLogger) Infof

func (c *ChaincodeLogger) Infof(format string, args ...interface{})

Infof logs will appear if the ChaincodeLogger LoggingLevel is set to LogInfo or LogDebug.

func (*ChaincodeLogger) IsEnabledFor

func (c *ChaincodeLogger) IsEnabledFor(level LoggingLevel) bool

IsEnabledFor returns true if the logger is enabled to creates logs at the given logging level.

func (*ChaincodeLogger) Notice

func (c *ChaincodeLogger) Notice(args ...interface{})

Notice logs will appear if the ChaincodeLogger LoggingLevel is set to LogNotice, LogInfo or LogDebug.

func (*ChaincodeLogger) Noticef

func (c *ChaincodeLogger) Noticef(format string, args ...interface{})

Noticef logs will appear if the ChaincodeLogger LoggingLevel is set to LogNotice, LogInfo or LogDebug.

func (*ChaincodeLogger) SetLevel

func (c *ChaincodeLogger) SetLevel(level LoggingLevel)

SetLevel sets the logging level for a chaincode logger. Note that currently the levels are actually controlled by the name given when the logger is created, so loggers should be given unique names other than "shim".

func (*ChaincodeLogger) Warning

func (c *ChaincodeLogger) Warning(args ...interface{})

Warning logs will appear if the ChaincodeLogger LoggingLevel is set to LogWarning, LogNotice, LogInfo or LogDebug.

func (*ChaincodeLogger) Warningf

func (c *ChaincodeLogger) Warningf(format string, args ...interface{})

Warningf logs will appear if the ChaincodeLogger LoggingLevel is set to LogWarning, LogNotice, LogInfo or LogDebug.

type ChaincodeStub

type ChaincodeStub struct {
	TxID string
	// contains filtered or unexported fields
}

ChaincodeStub is an object passed to chaincode for shim side handling of APIs.

func (*ChaincodeStub) CreateTable

func (stub *ChaincodeStub) CreateTable(name string, columnDefinitions []*ColumnDefinition) error

CreateTable creates a new table given the table name and column definitions

func (*ChaincodeStub) DelState

func (stub *ChaincodeStub) DelState(key string) error

DelState removes the specified `key` and its value from the ledger.

func (*ChaincodeStub) DeleteRow

func (stub *ChaincodeStub) DeleteRow(tableName string, key []Column) error

DeleteRow deletes the row for the given key from the specified table.

func (*ChaincodeStub) DeleteTable

func (stub *ChaincodeStub) DeleteTable(tableName string) error

DeleteTable deletes an entire table and all associated rows.

func (*ChaincodeStub) GetArgs

func (stub *ChaincodeStub) GetArgs() [][]byte

func (*ChaincodeStub) GetBinding

func (stub *ChaincodeStub) GetBinding() ([]byte, error)

GetBinding returns the transaction binding

func (*ChaincodeStub) GetCallerCertificate

func (stub *ChaincodeStub) GetCallerCertificate() ([]byte, error)

GetCallerCertificate returns caller certificate

func (*ChaincodeStub) GetCallerMetadata

func (stub *ChaincodeStub) GetCallerMetadata() ([]byte, error)

GetCallerMetadata returns caller metadata

func (*ChaincodeStub) GetPayload

func (stub *ChaincodeStub) GetPayload() ([]byte, error)

GetPayload returns transaction payload, which is a `ChaincodeSpec` defined in fabric/protos/chaincode.proto

func (*ChaincodeStub) GetRow

func (stub *ChaincodeStub) GetRow(tableName string, key []Column) (Row, error)

GetRow fetches a row from the specified table for the given key.

func (*ChaincodeStub) GetRows

func (stub *ChaincodeStub) GetRows(tableName string, key []Column) (<-chan Row, error)

GetRows returns multiple rows based on a partial key. For example, given table | A | B | C | D | where A, C and D are keys, GetRows can be called with [A, C] to return all rows that have A, C and any value for D as their key. GetRows could also be called with A only to return all rows that have A and any value for C and D as their key.

func (*ChaincodeStub) GetState

func (stub *ChaincodeStub) GetState(key string) ([]byte, error)

GetState returns the byte array value specified by the `key`.

func (*ChaincodeStub) GetStringArgs

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

func (*ChaincodeStub) GetTable

func (stub *ChaincodeStub) GetTable(tableName string) (*Table, error)

GetTable returns the table for the specified table name or ErrTableNotFound if the table does not exist.

func (*ChaincodeStub) GetTxID

func (stub *ChaincodeStub) GetTxID() string

func (*ChaincodeStub) GetTxTimestamp

func (stub *ChaincodeStub) GetTxTimestamp() (*timestamp.Timestamp, error)

GetTxTimestamp returns transaction created timestamp, which is currently taken from the peer receiving the transaction. Note that this timestamp may not be the same with the other peers' time.

func (*ChaincodeStub) InsertRow

func (stub *ChaincodeStub) InsertRow(tableName string, row Row) (bool, error)

InsertRow inserts a new row into the specified table. Returns - true and no error if the row is successfully inserted. false and no error if a row already exists for the given key. false and a TableNotFoundError if the specified table name does not exist. false and an error if there is an unexpected error condition.

func (*ChaincodeStub) InvokeChaincode

func (stub *ChaincodeStub) InvokeChaincode(chaincodeName string, args [][]byte) ([]byte, error)

InvokeChaincode locally calls the specified chaincode `Invoke` using the same transaction context; that is, chaincode calling chaincode doesn't create a new transaction message.

func (*ChaincodeStub) PutState

func (stub *ChaincodeStub) PutState(key string, value []byte) error

PutState writes the specified `value` and `key` into the ledger.

func (*ChaincodeStub) QueryChaincode

func (stub *ChaincodeStub) QueryChaincode(chaincodeName string, args [][]byte) ([]byte, error)

QueryChaincode locally calls the specified chaincode `Query` using the same transaction context; that is, chaincode calling chaincode doesn't create a new transaction message.

func (*ChaincodeStub) RangeQueryState

func (stub *ChaincodeStub) RangeQueryState(startKey, endKey string) (StateRangeQueryIteratorInterface, error)

RangeQueryState function can be invoked by a chaincode to query of a range of keys in the state. Assuming the startKey and endKey are in lexical order, an iterator will be returned that can be used to iterate over all keys between the startKey and endKey, inclusive. The order in which keys are returned by the iterator is random.

func (*ChaincodeStub) ReadCertAttribute

func (stub *ChaincodeStub) ReadCertAttribute(attributeName string) ([]byte, error)

ReadCertAttribute is used to read an specific attribute from the transaction certificate, *attributeName* is passed as input parameter to this function. Example:

attrValue,error:=stub.ReadCertAttribute("position")

func (*ChaincodeStub) ReplaceRow

func (stub *ChaincodeStub) ReplaceRow(tableName string, row Row) (bool, error)

ReplaceRow updates the row in the specified table. Returns - true and no error if the row is successfully updated. false and no error if a row does not exist the given key. flase and a TableNotFoundError if the specified table name does not exist. false and an error if there is an unexpected error condition.

func (*ChaincodeStub) SetEvent

func (stub *ChaincodeStub) SetEvent(name string, payload []byte) error

SetEvent saves the event to be sent when a transaction is made part of a block

func (*ChaincodeStub) VerifyAttribute

func (stub *ChaincodeStub) VerifyAttribute(attributeName string, attributeValue []byte) (bool, error)

VerifyAttribute is used to verify if the transaction certificate has an attribute with name *attributeName* and value *attributeValue* which are the input parameters received by this function. Example:

containsAttr, error := stub.VerifyAttribute("position", "Software Engineer")

func (*ChaincodeStub) VerifyAttributes

func (stub *ChaincodeStub) VerifyAttributes(attrs ...*attr.Attribute) (bool, error)

VerifyAttributes does the same as VerifyAttribute but it checks for a list of attributes and their respective values instead of a single attribute/value pair Example:

containsAttrs, error:= stub.VerifyAttributes(&attr.Attribute{"position",  "Software Engineer"}, &attr.Attribute{"company", "ACompany"})

func (*ChaincodeStub) VerifySignature

func (stub *ChaincodeStub) VerifySignature(certificate, signature, message []byte) (bool, error)

VerifySignature verifies the transaction signature and returns `true` if correct and `false` otherwise

type ChaincodeStubInterface

type ChaincodeStubInterface interface {
	// Get the arguments to the stub call as a 2D byte array
	GetArgs() [][]byte

	// Get the arguments to the stub call as a string array
	GetStringArgs() []string

	// Get the transaction ID
	GetTxID() string

	// InvokeChaincode locally calls the specified chaincode `Invoke` using the
	// same transaction context; that is, chaincode calling chaincode doesn't
	// create a new transaction message.
	InvokeChaincode(chaincodeName string, args [][]byte) ([]byte, error)

	// QueryChaincode locally calls the specified chaincode `Query` using the
	// same transaction context; that is, chaincode calling chaincode doesn't
	// create a new transaction message.
	QueryChaincode(chaincodeName string, args [][]byte) ([]byte, error)

	// GetState returns the byte array value specified by the `key`.
	GetState(key string) ([]byte, error)

	// PutState writes the specified `value` and `key` into the ledger.
	PutState(key string, value []byte) error

	// DelState removes the specified `key` and its value from the ledger.
	DelState(key string) error

	// RangeQueryState function can be invoked by a chaincode to query of a range
	// of keys in the state. Assuming the startKey and endKey are in lexical
	// an iterator will be returned that can be used to iterate over all keys
	// between the startKey and endKey, inclusive. The order in which keys are
	// returned by the iterator is random.
	RangeQueryState(startKey, endKey string) (StateRangeQueryIteratorInterface, error)

	// CreateTable creates a new table given the table name and column definitions
	CreateTable(name string, columnDefinitions []*ColumnDefinition) error

	// GetTable returns the table for the specified table name or ErrTableNotFound
	// if the table does not exist.
	GetTable(tableName string) (*Table, error)

	// DeleteTable deletes an entire table and all associated rows.
	DeleteTable(tableName string) error

	// InsertRow inserts a new row into the specified table.
	// Returns -
	// true and no error if the row is successfully inserted.
	// false and no error if a row already exists for the given key.
	// false and a TableNotFoundError if the specified table name does not exist.
	// false and an error if there is an unexpected error condition.
	InsertRow(tableName string, row Row) (bool, error)

	// ReplaceRow updates the row in the specified table.
	// Returns -
	// true and no error if the row is successfully updated.
	// false and no error if a row does not exist the given key.
	// flase and a TableNotFoundError if the specified table name does not exist.
	// false and an error if there is an unexpected error condition.
	ReplaceRow(tableName string, row Row) (bool, error)

	// GetRow fetches a row from the specified table for the given key.
	GetRow(tableName string, key []Column) (Row, error)

	// GetRows returns multiple rows based on a partial key. For example, given table
	// | A | B | C | D |
	// where A, C and D are keys, GetRows can be called with [A, C] to return
	// all rows that have A, C and any value for D as their key. GetRows could
	// also be called with A only to return all rows that have A and any value
	// for C and D as their key.
	GetRows(tableName string, key []Column) (<-chan Row, error)

	// DeleteRow deletes the row for the given key from the specified table.
	DeleteRow(tableName string, key []Column) error

	// ReadCertAttribute is used to read an specific attribute from the transaction certificate,
	// *attributeName* is passed as input parameter to this function.
	// Example:
	//  attrValue,error:=stub.ReadCertAttribute("position")
	ReadCertAttribute(attributeName string) ([]byte, error)

	// VerifyAttribute is used to verify if the transaction certificate has an attribute
	// with name *attributeName* and value *attributeValue* which are the input parameters
	// received by this function.
	// Example:
	//    containsAttr, error := stub.VerifyAttribute("position", "Software Engineer")
	VerifyAttribute(attributeName string, attributeValue []byte) (bool, error)

	// VerifyAttributes does the same as VerifyAttribute but it checks for a list of
	// attributes and their respective values instead of a single attribute/value pair
	// Example:
	//    containsAttrs, error:= stub.VerifyAttributes(&attr.Attribute{"position",  "Software Engineer"}, &attr.Attribute{"company", "ACompany"})
	VerifyAttributes(attrs ...*attr.Attribute) (bool, error)

	// VerifySignature verifies the transaction signature and returns `true` if
	// correct and `false` otherwise
	VerifySignature(certificate, signature, message []byte) (bool, error)

	// GetCallerCertificate returns caller certificate
	GetCallerCertificate() ([]byte, error)

	// GetCallerMetadata returns caller metadata
	GetCallerMetadata() ([]byte, error)

	// GetBinding returns the transaction binding
	GetBinding() ([]byte, error)

	// GetPayload returns transaction payload, which is a `ChaincodeSpec` defined
	// in fabric/protos/chaincode.proto
	GetPayload() ([]byte, error)

	// GetTxTimestamp returns transaction created timestamp, which is currently
	// taken from the peer receiving the transaction. Note that this timestamp
	// may not be the same with the other peers' time.
	GetTxTimestamp() (*timestamp.Timestamp, error)

	// SetEvent saves the event to be sent when a transaction is made part of a block
	SetEvent(name string, payload []byte) error
}

ChaincodeStubInterface is used by deployable chaincode apps to access and modify their ledgers

type Column

type Column struct {
	// Types that are valid to be assigned to Value:
	//	*Column_String_
	//	*Column_Int32
	//	*Column_Int64
	//	*Column_Uint32
	//	*Column_Uint64
	//	*Column_Bytes
	//	*Column_Bool
	Value isColumn_Value `protobuf_oneof:"value"`
}

func (*Column) Descriptor

func (*Column) Descriptor() ([]byte, []int)

func (*Column) GetBool

func (m *Column) GetBool() bool

func (*Column) GetBytes

func (m *Column) GetBytes() []byte

func (*Column) GetInt32

func (m *Column) GetInt32() int32

func (*Column) GetInt64

func (m *Column) GetInt64() int64

func (*Column) GetString_

func (m *Column) GetString_() string

func (*Column) GetUint32

func (m *Column) GetUint32() uint32

func (*Column) GetUint64

func (m *Column) GetUint64() uint64

func (*Column) GetValue

func (m *Column) GetValue() isColumn_Value

func (*Column) ProtoMessage

func (*Column) ProtoMessage()

func (*Column) Reset

func (m *Column) Reset()

func (*Column) String

func (m *Column) String() string

func (*Column) XXX_OneofFuncs

func (*Column) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{})

XXX_OneofFuncs is for the internal use of the proto package.

type ColumnDefinition

type ColumnDefinition struct {
	Name string                `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
	Type ColumnDefinition_Type `protobuf:"varint,2,opt,name=type,enum=shim.ColumnDefinition_Type" json:"type,omitempty"`
	Key  bool                  `protobuf:"varint,3,opt,name=key" json:"key,omitempty"`
}

func (*ColumnDefinition) Descriptor

func (*ColumnDefinition) Descriptor() ([]byte, []int)

func (*ColumnDefinition) ProtoMessage

func (*ColumnDefinition) ProtoMessage()

func (*ColumnDefinition) Reset

func (m *ColumnDefinition) Reset()

func (*ColumnDefinition) String

func (m *ColumnDefinition) String() string

type ColumnDefinition_Type

type ColumnDefinition_Type int32
const (
	ColumnDefinition_STRING ColumnDefinition_Type = 0
	ColumnDefinition_INT32  ColumnDefinition_Type = 1
	ColumnDefinition_INT64  ColumnDefinition_Type = 2
	ColumnDefinition_UINT32 ColumnDefinition_Type = 3
	ColumnDefinition_UINT64 ColumnDefinition_Type = 4
	ColumnDefinition_BYTES  ColumnDefinition_Type = 5
	ColumnDefinition_BOOL   ColumnDefinition_Type = 6
)

func (ColumnDefinition_Type) EnumDescriptor

func (ColumnDefinition_Type) EnumDescriptor() ([]byte, []int)

func (ColumnDefinition_Type) String

func (x ColumnDefinition_Type) String() string

type Column_Bool

type Column_Bool struct {
	Bool bool `protobuf:"varint,7,opt,name=bool,oneof"`
}

type Column_Bytes

type Column_Bytes struct {
	Bytes []byte `protobuf:"bytes,6,opt,name=bytes,proto3,oneof"`
}

type Column_Int32

type Column_Int32 struct {
	Int32 int32 `protobuf:"varint,2,opt,name=int32,oneof"`
}

type Column_Int64

type Column_Int64 struct {
	Int64 int64 `protobuf:"varint,3,opt,name=int64,oneof"`
}

type Column_String_

type Column_String_ struct {
	String_ string `protobuf:"bytes,1,opt,name=string,oneof"`
}

type Column_Uint32

type Column_Uint32 struct {
	Uint32 uint32 `protobuf:"varint,4,opt,name=uint32,oneof"`
}

type Column_Uint64

type Column_Uint64 struct {
	Uint64 uint64 `protobuf:"varint,5,opt,name=uint64,oneof"`
}

type Handler

type Handler struct {
	sync.RWMutex

	To         string
	ChatStream PeerChaincodeStream
	FSM        *fsm.FSM
	// contains filtered or unexported fields
}

Handler handler implementation for shim side of chaincode.

type LoggingLevel

type LoggingLevel logging.Level

LoggingLevel is an enumerated type of severity levels that control chaincode logging.

func LogLevel

func LogLevel(levelString string) (LoggingLevel, error)

LogLevel converts a case-insensitive string chosen from CRITICAL, ERROR, WARNING, NOTICE, INFO or DEBUG into an element of the LoggingLevel type. In the event of errors the level returned is LogError.

type MockStateRangeQueryIterator

type MockStateRangeQueryIterator struct {
	Closed   bool
	Stub     *MockStub
	StartKey string
	EndKey   string
	Current  *list.Element
}

func NewMockStateRangeQueryIterator

func NewMockStateRangeQueryIterator(stub *MockStub, startKey string, endKey string) *MockStateRangeQueryIterator

func (*MockStateRangeQueryIterator) Close

func (iter *MockStateRangeQueryIterator) Close() error

Close closes the range query iterator. This should be called when done reading from the iterator to free up resources.

func (*MockStateRangeQueryIterator) HasNext

func (iter *MockStateRangeQueryIterator) HasNext() bool

HasNext returns true if the range query iterator contains additional keys and values.

func (*MockStateRangeQueryIterator) Next

func (iter *MockStateRangeQueryIterator) Next() (string, []byte, error)

Next returns the next key and value in the range query iterator.

func (*MockStateRangeQueryIterator) Print

func (iter *MockStateRangeQueryIterator) Print()

type MockStub

type MockStub struct {

	// A nice name that can be used for logging
	Name string

	// State keeps name value pairs
	State map[string][]byte

	// Keys stores the list of mapped values in lexical order
	Keys *list.List

	// registered list of other MockStub chaincodes that can be called from this MockStub
	Invokables map[string]*MockStub

	// stores a transaction uuid while being Invoked / Deployed
	// TODO if a chaincode uses recursion this may need to be a stack of TxIDs or possibly a reference counting map
	TxID string
	// contains filtered or unexported fields
}

MockStub is an implementation of ChaincodeStubInterface for unit testing chaincode. Use this instead of ChaincodeStub in your chaincode's unit test calls to Init, Query or Invoke.

func NewMockStub

func NewMockStub(name string, cc Chaincode) *MockStub

Constructor to initialise the internal State map

func (*MockStub) CreateTable

func (stub *MockStub) CreateTable(name string, columnDefinitions []*ColumnDefinition) error

Not implemented

func (*MockStub) DelState

func (stub *MockStub) DelState(key string) error

DelState removes the specified `key` and its value from the ledger.

func (*MockStub) DeleteRow

func (stub *MockStub) DeleteRow(tableName string, key []Column) error

Not implemented

func (*MockStub) DeleteTable

func (stub *MockStub) DeleteTable(tableName string) error

Not implemented

func (*MockStub) GetArgs

func (stub *MockStub) GetArgs() [][]byte

func (*MockStub) GetBinding

func (stub *MockStub) GetBinding() ([]byte, error)

Not implemented

func (*MockStub) GetCallerCertificate

func (stub *MockStub) GetCallerCertificate() ([]byte, error)

Not implemented

func (*MockStub) GetCallerMetadata

func (stub *MockStub) GetCallerMetadata() ([]byte, error)

Not implemented

func (*MockStub) GetPayload

func (stub *MockStub) GetPayload() ([]byte, error)

Not implemented

func (*MockStub) GetRow

func (stub *MockStub) GetRow(tableName string, key []Column) (Row, error)

Not implemented

func (*MockStub) GetRows

func (stub *MockStub) GetRows(tableName string, key []Column) (<-chan Row, error)

Not implemented

func (*MockStub) GetState

func (stub *MockStub) GetState(key string) ([]byte, error)

GetState retrieves the value for a given key from the ledger

func (*MockStub) GetStringArgs

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

func (*MockStub) GetTable

func (stub *MockStub) GetTable(tableName string) (*Table, error)

Not implemented

func (*MockStub) GetTxID

func (stub *MockStub) GetTxID() string

func (*MockStub) GetTxTimestamp

func (stub *MockStub) GetTxTimestamp() (*timestamp.Timestamp, error)

Not implemented

func (*MockStub) InsertRow

func (stub *MockStub) InsertRow(tableName string, row Row) (bool, error)

Not implemented

func (*MockStub) InvokeChaincode

func (stub *MockStub) InvokeChaincode(chaincodeName string, args [][]byte) ([]byte, error)

Invokes a peered chaincode. E.g. stub1.InvokeChaincode("stub2Hash", funcArgs) Before calling this make sure to create another MockStub stub2, call stub2.MockInit(uuid, func, args) and register it with stub1 by calling stub1.MockPeerChaincode("stub2Hash", stub2)

func (*MockStub) MockInit

func (stub *MockStub) MockInit(uuid string, function string, args []string) ([]byte, error)

Initialise this chaincode, also starts and ends a transaction.

func (*MockStub) MockInvoke

func (stub *MockStub) MockInvoke(uuid string, function string, args []string) ([]byte, error)

Invoke this chaincode, also starts and ends a transaction.

func (*MockStub) MockPeerChaincode

func (stub *MockStub) MockPeerChaincode(invokableChaincodeName string, otherStub *MockStub)

Register a peer chaincode with this MockStub invokableChaincodeName is the name or hash of the peer otherStub is a MockStub of the peer, already intialised

func (*MockStub) MockQuery

func (stub *MockStub) MockQuery(function string, args []string) ([]byte, error)

Query this chaincode

func (*MockStub) MockTransactionEnd

func (stub *MockStub) MockTransactionEnd(uuid string)

End a mocked transaction, clearing the UUID.

func (*MockStub) MockTransactionStart

func (stub *MockStub) MockTransactionStart(txid string)

Used to indicate to a chaincode that it is part of a transaction. This is important when chaincodes invoke each other. MockStub doesn't support concurrent transactions at present.

func (*MockStub) PutState

func (stub *MockStub) PutState(key string, value []byte) error

PutState writes the specified `value` and `key` into the ledger.

func (*MockStub) QueryChaincode

func (stub *MockStub) QueryChaincode(chaincodeName string, args [][]byte) ([]byte, error)

func (*MockStub) RangeQueryState

func (stub *MockStub) RangeQueryState(startKey, endKey string) (StateRangeQueryIteratorInterface, error)

func (*MockStub) ReadCertAttribute

func (stub *MockStub) ReadCertAttribute(attributeName string) ([]byte, error)

Not implemented

func (*MockStub) ReplaceRow

func (stub *MockStub) ReplaceRow(tableName string, row Row) (bool, error)

Not implemented

func (*MockStub) SetEvent

func (stub *MockStub) SetEvent(name string, payload []byte) error

Not implemented

func (*MockStub) VerifyAttribute

func (stub *MockStub) VerifyAttribute(attributeName string, attributeValue []byte) (bool, error)

Not implemented

func (*MockStub) VerifyAttributes

func (stub *MockStub) VerifyAttributes(attrs ...*attr.Attribute) (bool, error)

Not implemented

func (*MockStub) VerifySignature

func (stub *MockStub) VerifySignature(certificate, signature, message []byte) (bool, error)

Not implemented

type PeerChaincodeStream

type PeerChaincodeStream interface {
	Send(*pb.ChaincodeMessage) error
	Recv() (*pb.ChaincodeMessage, error)
	CloseSend() error
}

PeerChaincodeStream interface for stream between Peer and chaincode instance.

type Row

type Row struct {
	Columns []*Column `protobuf:"bytes,1,rep,name=columns" json:"columns,omitempty"`
}

func (*Row) Descriptor

func (*Row) Descriptor() ([]byte, []int)

func (*Row) GetColumns

func (m *Row) GetColumns() []*Column

func (*Row) ProtoMessage

func (*Row) ProtoMessage()

func (*Row) Reset

func (m *Row) Reset()

func (*Row) String

func (m *Row) String() string

type StateRangeQueryIterator

type StateRangeQueryIterator struct {
	// contains filtered or unexported fields
}

StateRangeQueryIterator allows a chaincode to iterate over a range of key/value pairs in the state.

func (*StateRangeQueryIterator) Close

func (iter *StateRangeQueryIterator) Close() error

Close closes the range query iterator. This should be called when done reading from the iterator to free up resources.

func (*StateRangeQueryIterator) HasNext

func (iter *StateRangeQueryIterator) HasNext() bool

HasNext returns true if the range query iterator contains additional keys and values.

func (*StateRangeQueryIterator) Next

func (iter *StateRangeQueryIterator) Next() (string, []byte, error)

Next returns the next key and value in the range query iterator.

type StateRangeQueryIteratorInterface

type StateRangeQueryIteratorInterface interface {

	// HasNext returns true if the range query iterator contains additional keys
	// and values.
	HasNext() bool

	// Next returns the next key and value in the range query iterator.
	Next() (string, []byte, error)

	// Close closes the range query iterator. This should be called when done
	// reading from the iterator to free up resources.
	Close() error
}

StateRangeQueryIteratorInterface allows a chaincode to iterate over a range of key/value pairs in the state.

type Table

type Table struct {
	Name              string              `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
	ColumnDefinitions []*ColumnDefinition `protobuf:"bytes,2,rep,name=columnDefinitions" json:"columnDefinitions,omitempty"`
}

func (*Table) Descriptor

func (*Table) Descriptor() ([]byte, []int)

func (*Table) GetColumnDefinitions

func (m *Table) GetColumnDefinitions() []*ColumnDefinition

func (*Table) ProtoMessage

func (*Table) ProtoMessage()

func (*Table) Reset

func (m *Table) Reset()

func (*Table) String

func (m *Table) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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