Documentation ¶
Overview ¶
Package shim provides APIs for the chaincode to access its state variables, transaction context and call other chaincodes.
Package shim is a generated GoMock package.
Index ¶
- Constants
- Variables
- func Error(msg string) pb.Response
- func Start(cc Chaincode) error
- func StartInProc(env []string, args []string, cc Chaincode, recv <-chan *pb.PtnChaincodeMessage, ...) error
- func Success(payload []byte) pb.Response
- type Chaincode
- type ChaincodeStub
- func (stub *ChaincodeStub) DefineToken(tokenType byte, define []byte, creator string) error
- func (stub *ChaincodeStub) DelGlobalState(key string) error
- func (stub *ChaincodeStub) DelState(key string) error
- func (stub *ChaincodeStub) GetArgs() [][]byte
- func (stub *ChaincodeStub) GetArgsSlice() ([]byte, error)
- func (stub *ChaincodeStub) GetChannelID() string
- func (stub *ChaincodeStub) GetContractAllState() (map[string]*modules.ContractStateValue, error)
- func (stub *ChaincodeStub) GetContractID() ([]byte, string)
- func (stub *ChaincodeStub) GetContractState(contractAddr common.Address, key string) ([]byte, error)
- func (stub *ChaincodeStub) GetContractStateByPrefix(contractAddr common.Address, prefix string) ([]*modules.KeyValue, error)
- func (stub *ChaincodeStub) GetFunctionAndParameters() (function string, params []string)
- func (stub *ChaincodeStub) GetGlobalState(key string) ([]byte, error)
- func (stub *ChaincodeStub) GetInvokeAddress() (common.Address, error)
- func (stub *ChaincodeStub) GetInvokeFees() (*modules.AmountAsset, error)
- func (stub *ChaincodeStub) GetInvokeParameters() (invokeAddr common.Address, invokeTokens []*modules.InvokeTokens, ...)
- func (stub *ChaincodeStub) GetInvokeTokens() ([]*modules.InvokeTokens, error)
- func (stub *ChaincodeStub) GetRequesterCert() (certBytes []byte, err error)
- func (stub *ChaincodeStub) GetStableTransactionByHash(txHash string) (*modules.Transaction, error)
- func (stub *ChaincodeStub) GetStableUnit(unitHash string, unitNumber uint64) (*modules.Unit, error)
- func (stub *ChaincodeStub) GetState(key string) ([]byte, error)
- func (stub *ChaincodeStub) GetStateByPrefix(prefix string) ([]*modules.KeyValue, error)
- func (stub *ChaincodeStub) GetStringArgs() []string
- func (stub *ChaincodeStub) GetSystemConfig() (*modules.GlobalProperty, error)
- func (stub *ChaincodeStub) GetTokenBalance(address string, token *modules.Asset) ([]*modules.InvokeTokens, error)
- func (stub *ChaincodeStub) GetTxID() string
- func (stub *ChaincodeStub) GetTxTimestamp(rangeNumber uint32) (*timestamp.Timestamp, error)
- func (stub *ChaincodeStub) InvokeChaincode(chaincodeName string, args [][]byte, channel string) pb.Response
- func (stub *ChaincodeStub) IsRequesterCertValid() (bool, error)
- func (stub *ChaincodeStub) OutChainCall(outChainName string, method string, params []byte) ([]byte, error)
- func (stub *ChaincodeStub) PayOutToken(addr string, invokeTokens *modules.AmountAsset, lockTime uint32) error
- func (stub *ChaincodeStub) PutContractState(contractAddr common.Address, key string, value []byte) error
- func (stub *ChaincodeStub) PutGlobalState(key string, value []byte) error
- func (stub *ChaincodeStub) PutState(key string, value []byte) error
- func (stub *ChaincodeStub) RecvJury(msgType uint32, consultContent []byte, timeout uint32) ([]byte, error)
- func (stub *ChaincodeStub) SendJury(msgType uint32, consultContent []byte, myAnswer []byte) ([]byte, error)
- func (stub *ChaincodeStub) SetEvent(name string, payload []byte) error
- func (stub *ChaincodeStub) SupplyToken(assetId []byte, uniqueId []byte, amt uint64, creator string) error
- type ChaincodeStubInterface
- type Handler
- type MockChaincode
- type MockChaincodeMockRecorder
- type MockChaincodeStubInterface
- func (m *MockChaincodeStubInterface) DefineToken(tokenType byte, define []byte, creator string) error
- func (m *MockChaincodeStubInterface) DelGlobalState(key string) error
- func (m *MockChaincodeStubInterface) DelState(key string) error
- func (m *MockChaincodeStubInterface) EXPECT() *MockChaincodeStubInterfaceMockRecorder
- func (m *MockChaincodeStubInterface) GetArgs() [][]byte
- func (m *MockChaincodeStubInterface) GetArgsSlice() ([]byte, error)
- func (m *MockChaincodeStubInterface) GetChannelID() string
- func (m *MockChaincodeStubInterface) GetContractAllState() (map[string]*modules.ContractStateValue, error)
- func (m *MockChaincodeStubInterface) GetContractID() ([]byte, string)
- func (m *MockChaincodeStubInterface) GetContractState(contractAddr common.Address, key string) ([]byte, error)
- func (m *MockChaincodeStubInterface) GetContractStateByPrefix(contractAddr common.Address, key string) ([]*modules.KeyValue, error)
- func (m *MockChaincodeStubInterface) GetFunctionAndParameters() (string, []string)
- func (m *MockChaincodeStubInterface) GetGlobalState(key string) ([]byte, error)
- func (m *MockChaincodeStubInterface) GetInvokeAddress() (common.Address, error)
- func (m *MockChaincodeStubInterface) GetInvokeFees() (*modules.AmountAsset, error)
- func (m *MockChaincodeStubInterface) GetInvokeParameters() (common.Address, []*modules.InvokeTokens, *modules.AmountAsset, string, ...)
- func (m *MockChaincodeStubInterface) GetInvokeTokens() ([]*modules.InvokeTokens, error)
- func (m *MockChaincodeStubInterface) GetRequesterCert() ([]byte, error)
- func (m *MockChaincodeStubInterface) GetStableTransactionByHash(txHash string) (*modules.Transaction, error)
- func (m *MockChaincodeStubInterface) GetStableUnit(unitHash string, unitNumber uint64) (*modules.Unit, error)
- func (m *MockChaincodeStubInterface) GetState(key string) ([]byte, error)
- func (m *MockChaincodeStubInterface) GetStateByPrefix(prefix string) ([]*modules.KeyValue, error)
- func (m *MockChaincodeStubInterface) GetStringArgs() []string
- func (m *MockChaincodeStubInterface) GetSystemConfig() (*modules.GlobalProperty, error)
- func (m *MockChaincodeStubInterface) GetTokenBalance(address string, token *modules.Asset) ([]*modules.InvokeTokens, error)
- func (m *MockChaincodeStubInterface) GetTxID() string
- func (m *MockChaincodeStubInterface) GetTxTimestamp(rangeNumber uint32) (*timestamp.Timestamp, error)
- func (m *MockChaincodeStubInterface) InvokeChaincode(chaincodeName string, args [][]byte, channel string) peer.Response
- func (m *MockChaincodeStubInterface) IsRequesterCertValid() (bool, error)
- func (m *MockChaincodeStubInterface) OutChainCall(outChainName, method string, params []byte) ([]byte, error)
- func (m *MockChaincodeStubInterface) PayOutToken(addr string, invokeTokens *modules.AmountAsset, lockTime uint32) error
- func (m *MockChaincodeStubInterface) PutContractState(contractAddr common.Address, key string, value []byte) error
- func (m *MockChaincodeStubInterface) PutGlobalState(key string, value []byte) error
- func (m *MockChaincodeStubInterface) PutState(key string, value []byte) error
- func (m *MockChaincodeStubInterface) RecvJury(msgType uint32, consultContent []byte, timeout uint32) ([]byte, error)
- func (m *MockChaincodeStubInterface) SendJury(msgType uint32, consultContent, myAnswer []byte) ([]byte, error)
- func (m *MockChaincodeStubInterface) SetEvent(name string, payload []byte) error
- func (m *MockChaincodeStubInterface) SupplyToken(assetId, uniqueId []byte, amt uint64, creator string) error
- type MockChaincodeStubInterfaceMockRecorder
- func (mr *MockChaincodeStubInterfaceMockRecorder) DefineToken(tokenType, define, creator interface{}) *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) DelGlobalState(key interface{}) *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) DelState(key interface{}) *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) GetArgs() *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) GetArgsSlice() *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) GetChannelID() *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) GetContractAllState() *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) GetContractID() *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) GetContractState(contractAddr, key interface{}) *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) GetContractStateByPrefix(contractAddr, key interface{}) *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) GetFunctionAndParameters() *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) GetGlobalState(key interface{}) *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) GetInvokeAddress() *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) GetInvokeFees() *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) GetInvokeParameters() *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) GetInvokeTokens() *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) GetRequesterCert() *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) GetStableTransactionByHash(txHash interface{}) *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) GetStableUnit(unitHash, unitNumber interface{}) *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) GetState(key interface{}) *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) GetStateByPrefix(prefix interface{}) *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) GetStringArgs() *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) GetSystemConfig() *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) GetTokenBalance(address, token interface{}) *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) GetTxID() *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) GetTxTimestamp(rangeNumber interface{}) *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) InvokeChaincode(chaincodeName, args, channel interface{}) *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) IsRequesterCertValid() *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) OutChainCall(outChainName, method, params interface{}) *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) PayOutToken(addr, invokeTokens, lockTime interface{}) *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) PutContractState(contractAddr, key, value interface{}) *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) PutGlobalState(key, value interface{}) *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) PutState(key, value interface{}) *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) RecvJury(msgType, consultContent, timeout interface{}) *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) SendJury(msgType, consultContent, myAnswer interface{}) *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) SetEvent(name, payload interface{}) *gomock.Call
- func (mr *MockChaincodeStubInterfaceMockRecorder) SupplyToken(assetId, uniqueId, amt, creator interface{}) *gomock.Call
- type PeerChaincodeStream
- type SendPanicFailure
Constants ¶
const ( // OK constant - status code less than 400, endorser will endorse it. // OK means init or invoke successfully. OK = 200 // ERRORTHRESHOLD constant - status code greater than or equal to 400 will be considered an error and rejected by endorser. ERRORTHRESHOLD = 400 // ERROR constant - default error value ERROR = 500 )
Variables ¶
var ERROR_ONLY_SYS_CONTRACT = errors.New("Only system contract can call this function.")
var GlobalStateContractId = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
Functions ¶
func StartInProc ¶
func StartInProc(env []string, args []string, cc Chaincode, recv <-chan *pb.PtnChaincodeMessage, send chan<- *pb.PtnChaincodeMessage) 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 Instantiate transaction after the chaincode containerGetTxID // has been established for the first time, allowing the chaincode to // initialize its internal data Init(stub ChaincodeStubInterface) pb.Response // Invoke is called to update or query the ledger in a proposal transaction. // Updated state variables are not committed to the ledger until the // transaction is committed. Invoke(stub ChaincodeStubInterface) pb.Response }
Chaincode interface must be implemented by all chaincodes. The runs the transactions by calling these functions as specified.
type ChaincodeStub ¶
type ChaincodeStub struct { ContractId []byte TxID string ChannelId string // contains filtered or unexported fields }
ChaincodeStub is an object passed to chaincode for shim side handling of APIs.
func (*ChaincodeStub) DefineToken ¶
func (stub *ChaincodeStub) DefineToken(tokenType byte, define []byte, creator string) error
func (*ChaincodeStub) DelGlobalState ¶
func (stub *ChaincodeStub) DelGlobalState(key string) error
func (*ChaincodeStub) DelState ¶
func (stub *ChaincodeStub) DelState(key string) error
DelState documentation can be found in interfaces.go
func (*ChaincodeStub) GetArgs ¶
func (stub *ChaincodeStub) GetArgs() [][]byte
GetArgs documentation can be found in interfaces.go
func (*ChaincodeStub) GetArgsSlice ¶
func (stub *ChaincodeStub) GetArgsSlice() ([]byte, error)
GetArgsSlice documentation can be found in interfaces.go
func (*ChaincodeStub) GetChannelID ¶
func (stub *ChaincodeStub) GetChannelID() string
GetChannelID returns the channel for the proposal
func (*ChaincodeStub) GetContractAllState ¶
func (stub *ChaincodeStub) GetContractAllState() (map[string]*modules.ContractStateValue, error)
func (*ChaincodeStub) GetContractID ¶
func (stub *ChaincodeStub) GetContractID() ([]byte, string)
func (*ChaincodeStub) GetContractState ¶
func (*ChaincodeStub) GetContractStateByPrefix ¶ added in v1.0.6
func (*ChaincodeStub) GetFunctionAndParameters ¶
func (stub *ChaincodeStub) GetFunctionAndParameters() (function string, params []string)
GetFunctionAndParameters documentation can be found in interfaces.go
func (*ChaincodeStub) GetGlobalState ¶
func (stub *ChaincodeStub) GetGlobalState(key string) ([]byte, error)
func (*ChaincodeStub) GetInvokeAddress ¶
func (stub *ChaincodeStub) GetInvokeAddress() (common.Address, error)
func (*ChaincodeStub) GetInvokeFees ¶
func (stub *ChaincodeStub) GetInvokeFees() (*modules.AmountAsset, error)
func (*ChaincodeStub) GetInvokeParameters ¶
func (stub *ChaincodeStub) GetInvokeParameters() (invokeAddr common.Address, invokeTokens []*modules.InvokeTokens, invokeFees *modules.AmountAsset, funcName string, params []string, err error)
GetInvokeParameters documentation can be found in interfaces.go
func (*ChaincodeStub) GetInvokeTokens ¶
func (stub *ChaincodeStub) GetInvokeTokens() ([]*modules.InvokeTokens, error)
func (*ChaincodeStub) GetRequesterCert ¶
func (stub *ChaincodeStub) GetRequesterCert() (certBytes []byte, err error)
根据证书ID获得证书字节数据,不包含BEGIN和EN两行字符
func (*ChaincodeStub) GetStableTransactionByHash ¶ added in v1.0.5
func (stub *ChaincodeStub) GetStableTransactionByHash(txHash string) (*modules.Transaction, error)
func (*ChaincodeStub) GetStableUnit ¶ added in v1.0.5
func (*ChaincodeStub) GetState ¶
func (stub *ChaincodeStub) GetState(key string) ([]byte, error)
GetState documentation can be found in interfaces.go
func (*ChaincodeStub) GetStateByPrefix ¶
func (stub *ChaincodeStub) GetStateByPrefix(prefix string) ([]*modules.KeyValue, error)
func (*ChaincodeStub) GetStringArgs ¶
func (stub *ChaincodeStub) GetStringArgs() []string
GetStringArgs documentation can be found in interfaces.go
func (*ChaincodeStub) GetSystemConfig ¶
func (stub *ChaincodeStub) GetSystemConfig() (*modules.GlobalProperty, error)
---------- Deposit API ---------- func (stub *ChaincodeStub) GetSystemConfig(key string) (string, error) {
func (*ChaincodeStub) GetTokenBalance ¶
func (stub *ChaincodeStub) GetTokenBalance(address string, token *modules.Asset) ([]*modules.InvokeTokens, error)
获得该合约的Token余额
func (*ChaincodeStub) GetTxID ¶
func (stub *ChaincodeStub) GetTxID() string
GetTxID returns the transaction ID for the proposal
func (*ChaincodeStub) GetTxTimestamp ¶
func (stub *ChaincodeStub) GetTxTimestamp(rangeNumber uint32) (*timestamp.Timestamp, error)
GetTxTimestamp documentation can be found in interfaces.go
func (*ChaincodeStub) InvokeChaincode ¶
func (stub *ChaincodeStub) InvokeChaincode(chaincodeName string, args [][]byte, channel string) pb.Response
InvokeChaincode documentation can be found in interfaces.go
func (*ChaincodeStub) IsRequesterCertValid ¶
func (stub *ChaincodeStub) IsRequesterCertValid() (bool, error)
func (*ChaincodeStub) OutChainCall ¶
func (*ChaincodeStub) PayOutToken ¶
func (stub *ChaincodeStub) PayOutToken(addr string, invokeTokens *modules.AmountAsset, lockTime uint32) error
将合约上锁定的某种Token支付出去
func (*ChaincodeStub) PutContractState ¶ added in v1.0.8
func (*ChaincodeStub) PutGlobalState ¶
func (stub *ChaincodeStub) PutGlobalState(key string, value []byte) error
func (*ChaincodeStub) PutState ¶
func (stub *ChaincodeStub) PutState(key string, value []byte) error
PutState documentation can be found in interfaces.go
func (*ChaincodeStub) SetEvent ¶
func (stub *ChaincodeStub) SetEvent(name string, payload []byte) error
SetEvent documentation can be found in interfaces.go
func (*ChaincodeStub) SupplyToken ¶
func (stub *ChaincodeStub) SupplyToken(assetId []byte, uniqueId []byte, amt uint64, creator string) error
增发一种之前已经定义好的Token 如果是ERC20增发,则uniqueId为空,如果是ERC721增发,则必须指定唯一的uniqueId
type ChaincodeStubInterface ¶
type ChaincodeStubInterface interface { // GetArgs returns the arguments intended for the chaincode Init and Invoke // as an arrayte a of byrrays. GetArgs() [][]byte // GetStringArgs returns the arguments intended for the chaincode Init and // Invoke as a string array. Only use GetStringArgs if the client passes // arguments intended to be used as strings. GetStringArgs() []string // GetFunctionAndParameters returns the first argument as the function // name and the rest of the arguments as parameters in a string array. // Only use GetFunctionAndParameters if the client passes arguments intended // to be used as strings. GetFunctionAndParameters() (string, []string) // GetArgsSlice returns the arguments intended for the chaincode Init and // Invoke as a byte array GetArgsSlice() ([]byte, error) // GetTxID returns the tx_id of the transaction proposal, which is unique per // transaction and per client. See ChannelHeader in protos/common/common.proto // for further details. GetTxID() string // GetChannelID returns the channel the proposal is sent to for chaincode to process. // This would be the channel_id of the transaction proposal (see ChannelHeader // in protos/common/common.proto) except where the chaincode is calling another on // a different channel GetChannelID() 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. // If the called chaincode is on the same channel, it simply adds the called // chaincode read set and write set to the calling transaction. // If the called chaincode is on a different channel, // only the Response is returned to the calling chaincode; any PutState calls // from the called chaincode will not have any effect on the ledger; that is, // the called chaincode on a different channel will not have its read set // and write set applied to the transaction. Only the calling chaincode's // read set and write set will be applied to the transaction. Effectively // the called chaincode on a different channel is a `Query`, which does not // participate in state validation checks in subsequent commit phase. // If `channel` is empty, the caller's channel is assumed. InvokeChaincode(chaincodeName string, args [][]byte, channel string) pb.Response // GetState returns the value of the specified `key` from the // ledger. Note that GetState doesn't read data from the writeset, which // has not been committed to the ledger. In other words, GetState doesn't // consider data modified by PutState that has not been committed. // If the key does not exist in the state database, (nil, nil) is returned. GetState(key string) ([]byte, error) GetGlobalState(key string) ([]byte, error) GetContractState(contractAddr common.Address, key string) ([]byte, error) GetContractStateByPrefix(contractAddr common.Address, key string) ([]*modules.KeyValue, error) GetStateByPrefix(prefix string) ([]*modules.KeyValue, error) // PutState puts the specified `key` and `value` into the transaction's // writeset as a data-write proposal. PutState doesn't effect the ledger // until the transaction is validated and successfully committed. // Simple keys must not be an empty string and must not start with null // character (0x00), in order to avoid range query collisions with // composite keys, which internally get prefixed with 0x00 as composite // key namespace. PutState(key string, value []byte) error PutGlobalState(key string, value []byte) error PutContractState(contractAddr common.Address, key string, value []byte) error OutChainCall(outChainName string, method string, params []byte) ([]byte, error) //retrun local jury's signature SendJury(msgType uint32, consultContent []byte, myAnswer []byte) ([]byte, error) //return all jury's Address and Address,format:[]JuryMsgAddr //type JuryMsgAddr struct { // Address string // Address []byte //} RecvJury(msgType uint32, consultContent []byte, timeout uint32) ([]byte, error) // DelState records the specified `key` to be deleted in the writeset of // the transaction proposal. The `key` and its value will be deleted from // the ledger when the transaction is validated and successfully committed. DelState(key string) error DelGlobalState(key string) error // GetTxTimestamp returns the timestamp when the transaction was created. This // is taken from the transaction ChannelHeader, therefore it will indicate the // client's timestamp and will have the same value across all endorsers. GetTxTimestamp(rangeNumber uint32) (*timestamp.Timestamp, error) // SetEvent allows the chaincode to set an event on the response to the // proposal to be included as part of a transaction. The event will be // available within the transaction in the committed block regardless of the // validity of the transaction. SetEvent(name string, payload []byte) error //获取合约的一些配置参数 //GetSystemConfig(filed string) (value string, err error) GetSystemConfig() (gp *modules.GlobalProperty, err error) //获取支付合约的 from 地址 GetInvokeAddress() (invokeAddr common.Address, err error) //获取支付ptn数量 GetInvokeTokens() (invokeTokens []*modules.InvokeTokens, err error) //获取所有的世界状态 GetContractAllState() (states map[string]*modules.ContractStateValue, err error) //获取调用合约所支付的PTN手续费 GetInvokeFees() (invokeFees *modules.AmountAsset, err error) //获取合约地址 GetContractID() ([]byte, string) //获得某地址的Token余额 //如果地址为空则表示当前合约 //如果token为空则表示查询所有Token余额 GetTokenBalance(address string, token *modules.Asset) ([]*modules.InvokeTokens, error) //根据交易哈希获得一个稳定的交易内容 GetStableTransactionByHash(txHash string) (*modules.Transaction, error) //根据单元哈希或单元高度获得一个稳定的单元 GetStableUnit(unitHash string, unitNumber uint64) (*modules.Unit, error) //将合约上锁定的某种Token支付出去 PayOutToken(addr string, invokeTokens *modules.AmountAsset, lockTime uint32) error //获取invoke参数,包括invokeAddr,tokens,fee,funcName,params GetInvokeParameters() (invokeAddr common.Address, invokeTokens []*modules.InvokeTokens, invokeFees *modules.AmountAsset, funcName string, params []string, err error) //定义并发行一种全新的Token DefineToken(tokenType byte, define []byte, creator string) error //增发一种之前已经定义好的Token //如果是ERC20增发,则uniqueId为空,如果是ERC721增发,则必须指定唯一的uniqueId SupplyToken(assetId []byte, uniqueId []byte, amt uint64, creator string) error // 根据证书ID获得证书字节数据 GetRequesterCert() (certBytes []byte, err error) // 验证证书是否合法, error返回的是不合法的原因 IsRequesterCertValid() (bool, error) }
ChaincodeStubInterface is used by deployable chaincode apps to access and modify their ledgers
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 MockChaincode ¶
type MockChaincode struct {
// contains filtered or unexported fields
}
MockChaincode is a mock of Chaincode interface
func NewMockChaincode ¶
func NewMockChaincode(ctrl *gomock.Controller) *MockChaincode
NewMockChaincode creates a new mock instance
func (*MockChaincode) EXPECT ¶
func (m *MockChaincode) EXPECT() *MockChaincodeMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockChaincode) Init ¶
func (m *MockChaincode) Init(stub ChaincodeStubInterface) peer.Response
Init mocks base method
func (*MockChaincode) Invoke ¶
func (m *MockChaincode) Invoke(stub ChaincodeStubInterface) peer.Response
Invoke mocks base method
type MockChaincodeMockRecorder ¶
type MockChaincodeMockRecorder struct {
// contains filtered or unexported fields
}
MockChaincodeMockRecorder is the mock recorder for MockChaincode
func (*MockChaincodeMockRecorder) Init ¶
func (mr *MockChaincodeMockRecorder) Init(stub interface{}) *gomock.Call
Init indicates an expected call of Init
func (*MockChaincodeMockRecorder) Invoke ¶
func (mr *MockChaincodeMockRecorder) Invoke(stub interface{}) *gomock.Call
Invoke indicates an expected call of Invoke
type MockChaincodeStubInterface ¶
type MockChaincodeStubInterface struct {
// contains filtered or unexported fields
}
MockChaincodeStubInterface is a mock of ChaincodeStubInterface interface
func NewMockChaincodeStubInterface ¶
func NewMockChaincodeStubInterface(ctrl *gomock.Controller) *MockChaincodeStubInterface
NewMockChaincodeStubInterface creates a new mock instance
func (*MockChaincodeStubInterface) DefineToken ¶
func (m *MockChaincodeStubInterface) DefineToken(tokenType byte, define []byte, creator string) error
DefineToken mocks base method
func (*MockChaincodeStubInterface) DelGlobalState ¶
func (m *MockChaincodeStubInterface) DelGlobalState(key string) error
DelGlobalState mocks base method
func (*MockChaincodeStubInterface) DelState ¶
func (m *MockChaincodeStubInterface) DelState(key string) error
DelState mocks base method
func (*MockChaincodeStubInterface) EXPECT ¶
func (m *MockChaincodeStubInterface) EXPECT() *MockChaincodeStubInterfaceMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockChaincodeStubInterface) GetArgs ¶
func (m *MockChaincodeStubInterface) GetArgs() [][]byte
GetArgs mocks base method
func (*MockChaincodeStubInterface) GetArgsSlice ¶
func (m *MockChaincodeStubInterface) GetArgsSlice() ([]byte, error)
GetArgsSlice mocks base method
func (*MockChaincodeStubInterface) GetChannelID ¶
func (m *MockChaincodeStubInterface) GetChannelID() string
GetChannelID mocks base method
func (*MockChaincodeStubInterface) GetContractAllState ¶
func (m *MockChaincodeStubInterface) GetContractAllState() (map[string]*modules.ContractStateValue, error)
GetContractAllState mocks base method
func (*MockChaincodeStubInterface) GetContractID ¶
func (m *MockChaincodeStubInterface) GetContractID() ([]byte, string)
GetContractID mocks base method
func (*MockChaincodeStubInterface) GetContractState ¶
func (m *MockChaincodeStubInterface) GetContractState(contractAddr common.Address, key string) ([]byte, error)
GetContractState mocks base method
func (*MockChaincodeStubInterface) GetContractStateByPrefix ¶ added in v1.0.6
func (m *MockChaincodeStubInterface) GetContractStateByPrefix(contractAddr common.Address, key string) ([]*modules.KeyValue, error)
GetContractStateByPrefix mocks base method
func (*MockChaincodeStubInterface) GetFunctionAndParameters ¶
func (m *MockChaincodeStubInterface) GetFunctionAndParameters() (string, []string)
GetFunctionAndParameters mocks base method
func (*MockChaincodeStubInterface) GetGlobalState ¶
func (m *MockChaincodeStubInterface) GetGlobalState(key string) ([]byte, error)
GetGlobalState mocks base method
func (*MockChaincodeStubInterface) GetInvokeAddress ¶
func (m *MockChaincodeStubInterface) GetInvokeAddress() (common.Address, error)
GetInvokeAddress mocks base method
func (*MockChaincodeStubInterface) GetInvokeFees ¶
func (m *MockChaincodeStubInterface) GetInvokeFees() (*modules.AmountAsset, error)
GetInvokeFees mocks base method
func (*MockChaincodeStubInterface) GetInvokeParameters ¶
func (m *MockChaincodeStubInterface) GetInvokeParameters() (common.Address, []*modules.InvokeTokens, *modules.AmountAsset, string, []string, error)
GetInvokeParameters mocks base method
func (*MockChaincodeStubInterface) GetInvokeTokens ¶
func (m *MockChaincodeStubInterface) GetInvokeTokens() ([]*modules.InvokeTokens, error)
GetInvokeTokens mocks base method
func (*MockChaincodeStubInterface) GetRequesterCert ¶
func (m *MockChaincodeStubInterface) GetRequesterCert() ([]byte, error)
GetRequesterCert mocks base method
func (*MockChaincodeStubInterface) GetStableTransactionByHash ¶ added in v1.0.5
func (m *MockChaincodeStubInterface) GetStableTransactionByHash(txHash string) (*modules.Transaction, error)
GetStableTransactionByHash mocks base method
func (*MockChaincodeStubInterface) GetStableUnit ¶ added in v1.0.5
func (m *MockChaincodeStubInterface) GetStableUnit(unitHash string, unitNumber uint64) (*modules.Unit, error)
GetStableUnit mocks base method
func (*MockChaincodeStubInterface) GetState ¶
func (m *MockChaincodeStubInterface) GetState(key string) ([]byte, error)
GetState mocks base method
func (*MockChaincodeStubInterface) GetStateByPrefix ¶
func (m *MockChaincodeStubInterface) GetStateByPrefix(prefix string) ([]*modules.KeyValue, error)
GetStateByPrefix mocks base method
func (*MockChaincodeStubInterface) GetStringArgs ¶
func (m *MockChaincodeStubInterface) GetStringArgs() []string
GetStringArgs mocks base method
func (*MockChaincodeStubInterface) GetSystemConfig ¶
func (m *MockChaincodeStubInterface) GetSystemConfig() (*modules.GlobalProperty, error)
GetSystemConfig mocks base method
func (*MockChaincodeStubInterface) GetTokenBalance ¶
func (m *MockChaincodeStubInterface) GetTokenBalance(address string, token *modules.Asset) ([]*modules.InvokeTokens, error)
GetTokenBalance mocks base method
func (*MockChaincodeStubInterface) GetTxID ¶
func (m *MockChaincodeStubInterface) GetTxID() string
GetTxID mocks base method
func (*MockChaincodeStubInterface) GetTxTimestamp ¶
func (m *MockChaincodeStubInterface) GetTxTimestamp(rangeNumber uint32) (*timestamp.Timestamp, error)
GetTxTimestamp mocks base method
func (*MockChaincodeStubInterface) InvokeChaincode ¶
func (m *MockChaincodeStubInterface) InvokeChaincode(chaincodeName string, args [][]byte, channel string) peer.Response
InvokeChaincode mocks base method
func (*MockChaincodeStubInterface) IsRequesterCertValid ¶
func (m *MockChaincodeStubInterface) IsRequesterCertValid() (bool, error)
IsRequesterCertValid mocks base method
func (*MockChaincodeStubInterface) OutChainCall ¶
func (m *MockChaincodeStubInterface) OutChainCall(outChainName, method string, params []byte) ([]byte, error)
OutChainCall mocks base method
func (*MockChaincodeStubInterface) PayOutToken ¶
func (m *MockChaincodeStubInterface) PayOutToken(addr string, invokeTokens *modules.AmountAsset, lockTime uint32) error
PayOutToken mocks base method
func (*MockChaincodeStubInterface) PutContractState ¶ added in v1.0.8
func (m *MockChaincodeStubInterface) PutContractState(contractAddr common.Address, key string, value []byte) error
PutContractState mocks base method
func (*MockChaincodeStubInterface) PutGlobalState ¶
func (m *MockChaincodeStubInterface) PutGlobalState(key string, value []byte) error
PutGlobalState mocks base method
func (*MockChaincodeStubInterface) PutState ¶
func (m *MockChaincodeStubInterface) PutState(key string, value []byte) error
PutState mocks base method
func (*MockChaincodeStubInterface) RecvJury ¶
func (m *MockChaincodeStubInterface) RecvJury(msgType uint32, consultContent []byte, timeout uint32) ([]byte, error)
RecvJury mocks base method
func (*MockChaincodeStubInterface) SendJury ¶
func (m *MockChaincodeStubInterface) SendJury(msgType uint32, consultContent, myAnswer []byte) ([]byte, error)
SendJury mocks base method
func (*MockChaincodeStubInterface) SetEvent ¶
func (m *MockChaincodeStubInterface) SetEvent(name string, payload []byte) error
SetEvent mocks base method
func (*MockChaincodeStubInterface) SupplyToken ¶
func (m *MockChaincodeStubInterface) SupplyToken(assetId, uniqueId []byte, amt uint64, creator string) error
SupplyToken mocks base method
type MockChaincodeStubInterfaceMockRecorder ¶
type MockChaincodeStubInterfaceMockRecorder struct {
// contains filtered or unexported fields
}
MockChaincodeStubInterfaceMockRecorder is the mock recorder for MockChaincodeStubInterface
func (*MockChaincodeStubInterfaceMockRecorder) DefineToken ¶
func (mr *MockChaincodeStubInterfaceMockRecorder) DefineToken(tokenType, define, creator interface{}) *gomock.Call
DefineToken indicates an expected call of DefineToken
func (*MockChaincodeStubInterfaceMockRecorder) DelGlobalState ¶
func (mr *MockChaincodeStubInterfaceMockRecorder) DelGlobalState(key interface{}) *gomock.Call
DelGlobalState indicates an expected call of DelGlobalState
func (*MockChaincodeStubInterfaceMockRecorder) DelState ¶
func (mr *MockChaincodeStubInterfaceMockRecorder) DelState(key interface{}) *gomock.Call
DelState indicates an expected call of DelState
func (*MockChaincodeStubInterfaceMockRecorder) GetArgs ¶
func (mr *MockChaincodeStubInterfaceMockRecorder) GetArgs() *gomock.Call
GetArgs indicates an expected call of GetArgs
func (*MockChaincodeStubInterfaceMockRecorder) GetArgsSlice ¶
func (mr *MockChaincodeStubInterfaceMockRecorder) GetArgsSlice() *gomock.Call
GetArgsSlice indicates an expected call of GetArgsSlice
func (*MockChaincodeStubInterfaceMockRecorder) GetChannelID ¶
func (mr *MockChaincodeStubInterfaceMockRecorder) GetChannelID() *gomock.Call
GetChannelID indicates an expected call of GetChannelID
func (*MockChaincodeStubInterfaceMockRecorder) GetContractAllState ¶
func (mr *MockChaincodeStubInterfaceMockRecorder) GetContractAllState() *gomock.Call
GetContractAllState indicates an expected call of GetContractAllState
func (*MockChaincodeStubInterfaceMockRecorder) GetContractID ¶
func (mr *MockChaincodeStubInterfaceMockRecorder) GetContractID() *gomock.Call
GetContractID indicates an expected call of GetContractID
func (*MockChaincodeStubInterfaceMockRecorder) GetContractState ¶
func (mr *MockChaincodeStubInterfaceMockRecorder) GetContractState(contractAddr, key interface{}) *gomock.Call
GetContractState indicates an expected call of GetContractState
func (*MockChaincodeStubInterfaceMockRecorder) GetContractStateByPrefix ¶ added in v1.0.6
func (mr *MockChaincodeStubInterfaceMockRecorder) GetContractStateByPrefix(contractAddr, key interface{}) *gomock.Call
GetContractStateByPrefix indicates an expected call of GetContractStateByPrefix
func (*MockChaincodeStubInterfaceMockRecorder) GetFunctionAndParameters ¶
func (mr *MockChaincodeStubInterfaceMockRecorder) GetFunctionAndParameters() *gomock.Call
GetFunctionAndParameters indicates an expected call of GetFunctionAndParameters
func (*MockChaincodeStubInterfaceMockRecorder) GetGlobalState ¶
func (mr *MockChaincodeStubInterfaceMockRecorder) GetGlobalState(key interface{}) *gomock.Call
GetGlobalState indicates an expected call of GetGlobalState
func (*MockChaincodeStubInterfaceMockRecorder) GetInvokeAddress ¶
func (mr *MockChaincodeStubInterfaceMockRecorder) GetInvokeAddress() *gomock.Call
GetInvokeAddress indicates an expected call of GetInvokeAddress
func (*MockChaincodeStubInterfaceMockRecorder) GetInvokeFees ¶
func (mr *MockChaincodeStubInterfaceMockRecorder) GetInvokeFees() *gomock.Call
GetInvokeFees indicates an expected call of GetInvokeFees
func (*MockChaincodeStubInterfaceMockRecorder) GetInvokeParameters ¶
func (mr *MockChaincodeStubInterfaceMockRecorder) GetInvokeParameters() *gomock.Call
GetInvokeParameters indicates an expected call of GetInvokeParameters
func (*MockChaincodeStubInterfaceMockRecorder) GetInvokeTokens ¶
func (mr *MockChaincodeStubInterfaceMockRecorder) GetInvokeTokens() *gomock.Call
GetInvokeTokens indicates an expected call of GetInvokeTokens
func (*MockChaincodeStubInterfaceMockRecorder) GetRequesterCert ¶
func (mr *MockChaincodeStubInterfaceMockRecorder) GetRequesterCert() *gomock.Call
GetRequesterCert indicates an expected call of GetRequesterCert
func (*MockChaincodeStubInterfaceMockRecorder) GetStableTransactionByHash ¶ added in v1.0.5
func (mr *MockChaincodeStubInterfaceMockRecorder) GetStableTransactionByHash(txHash interface{}) *gomock.Call
GetStableTransactionByHash indicates an expected call of GetStableTransactionByHash
func (*MockChaincodeStubInterfaceMockRecorder) GetStableUnit ¶ added in v1.0.5
func (mr *MockChaincodeStubInterfaceMockRecorder) GetStableUnit(unitHash, unitNumber interface{}) *gomock.Call
GetStableUnit indicates an expected call of GetStableUnit
func (*MockChaincodeStubInterfaceMockRecorder) GetState ¶
func (mr *MockChaincodeStubInterfaceMockRecorder) GetState(key interface{}) *gomock.Call
GetState indicates an expected call of GetState
func (*MockChaincodeStubInterfaceMockRecorder) GetStateByPrefix ¶
func (mr *MockChaincodeStubInterfaceMockRecorder) GetStateByPrefix(prefix interface{}) *gomock.Call
GetStateByPrefix indicates an expected call of GetStateByPrefix
func (*MockChaincodeStubInterfaceMockRecorder) GetStringArgs ¶
func (mr *MockChaincodeStubInterfaceMockRecorder) GetStringArgs() *gomock.Call
GetStringArgs indicates an expected call of GetStringArgs
func (*MockChaincodeStubInterfaceMockRecorder) GetSystemConfig ¶
func (mr *MockChaincodeStubInterfaceMockRecorder) GetSystemConfig() *gomock.Call
GetSystemConfig indicates an expected call of GetSystemConfig
func (*MockChaincodeStubInterfaceMockRecorder) GetTokenBalance ¶
func (mr *MockChaincodeStubInterfaceMockRecorder) GetTokenBalance(address, token interface{}) *gomock.Call
GetTokenBalance indicates an expected call of GetTokenBalance
func (*MockChaincodeStubInterfaceMockRecorder) GetTxID ¶
func (mr *MockChaincodeStubInterfaceMockRecorder) GetTxID() *gomock.Call
GetTxID indicates an expected call of GetTxID
func (*MockChaincodeStubInterfaceMockRecorder) GetTxTimestamp ¶
func (mr *MockChaincodeStubInterfaceMockRecorder) GetTxTimestamp(rangeNumber interface{}) *gomock.Call
GetTxTimestamp indicates an expected call of GetTxTimestamp
func (*MockChaincodeStubInterfaceMockRecorder) InvokeChaincode ¶
func (mr *MockChaincodeStubInterfaceMockRecorder) InvokeChaincode(chaincodeName, args, channel interface{}) *gomock.Call
InvokeChaincode indicates an expected call of InvokeChaincode
func (*MockChaincodeStubInterfaceMockRecorder) IsRequesterCertValid ¶
func (mr *MockChaincodeStubInterfaceMockRecorder) IsRequesterCertValid() *gomock.Call
IsRequesterCertValid indicates an expected call of IsRequesterCertValid
func (*MockChaincodeStubInterfaceMockRecorder) OutChainCall ¶
func (mr *MockChaincodeStubInterfaceMockRecorder) OutChainCall(outChainName, method, params interface{}) *gomock.Call
OutChainCall indicates an expected call of OutChainCall
func (*MockChaincodeStubInterfaceMockRecorder) PayOutToken ¶
func (mr *MockChaincodeStubInterfaceMockRecorder) PayOutToken(addr, invokeTokens, lockTime interface{}) *gomock.Call
PayOutToken indicates an expected call of PayOutToken
func (*MockChaincodeStubInterfaceMockRecorder) PutContractState ¶ added in v1.0.8
func (mr *MockChaincodeStubInterfaceMockRecorder) PutContractState(contractAddr, key, value interface{}) *gomock.Call
PutContractState indicates an expected call of PutContractState
func (*MockChaincodeStubInterfaceMockRecorder) PutGlobalState ¶
func (mr *MockChaincodeStubInterfaceMockRecorder) PutGlobalState(key, value interface{}) *gomock.Call
PutGlobalState indicates an expected call of PutGlobalState
func (*MockChaincodeStubInterfaceMockRecorder) PutState ¶
func (mr *MockChaincodeStubInterfaceMockRecorder) PutState(key, value interface{}) *gomock.Call
PutState indicates an expected call of PutState
func (*MockChaincodeStubInterfaceMockRecorder) RecvJury ¶
func (mr *MockChaincodeStubInterfaceMockRecorder) RecvJury(msgType, consultContent, timeout interface{}) *gomock.Call
RecvJury indicates an expected call of RecvJury
func (*MockChaincodeStubInterfaceMockRecorder) SendJury ¶
func (mr *MockChaincodeStubInterfaceMockRecorder) SendJury(msgType, consultContent, myAnswer interface{}) *gomock.Call
SendJury indicates an expected call of SendJury
func (*MockChaincodeStubInterfaceMockRecorder) SetEvent ¶
func (mr *MockChaincodeStubInterfaceMockRecorder) SetEvent(name, payload interface{}) *gomock.Call
SetEvent indicates an expected call of SetEvent
func (*MockChaincodeStubInterfaceMockRecorder) SupplyToken ¶
func (mr *MockChaincodeStubInterfaceMockRecorder) SupplyToken(assetId, uniqueId, amt, creator interface{}) *gomock.Call
SupplyToken indicates an expected call of SupplyToken
type PeerChaincodeStream ¶
type PeerChaincodeStream interface { Send(*pb.PtnChaincodeMessage) error Recv() (*pb.PtnChaincodeMessage, error) CloseSend() error }
PeerChaincodeStream interface for stream between Peer and chaincode instance.
type SendPanicFailure ¶
type SendPanicFailure string
SendPanicFailure
func (SendPanicFailure) Error ¶
func (e SendPanicFailure) Error() string