Documentation
¶
Index ¶
- Constants
- func Error(code uint32, log string) *pb.ContractMessage
- func Inited(log string, data []byte) *pb.ContractMessage
- func Start(c Contract) error
- func Success(log string, data []byte) *pb.ContractMessage
- type ClientStream
- type Contract
- type ContractStub
- func (cs *ContractStub) DelState(collection, key string) error
- func (cs *ContractStub) GetArgs() [][]byte
- func (cs *ContractStub) GetArgsSlice() ([]byte, error)
- func (cs *ContractStub) GetFunctionAndParameters() (string, []string)
- func (cs *ContractStub) GetState(collection, key string) ([]byte, error)
- func (cs *ContractStub) GetStringArgs() []string
- func (cs *ContractStub) GetTxID() string
- func (cs *ContractStub) InvokeContract(cID string, args [][]byte)
- func (cs *ContractStub) PutState(collection, key string, value []byte) error
- type ContractStubInterface
- type Handler
- type NodeContractStream
Constants ¶
View Source
const ( CodeTypeOK uint32 = 0 CodeTypeEncodingError uint32 = 1 CodeTypeBadFunction uint32 = 2 CodeTypeUnknownError uint32 = 4 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ClientStream ¶
type ClientStream interface { NodeContractStream CloseSend() error }
type Contract ¶
type Contract interface { // Init is called during Instantiate transaction after the contract container // has been established for the first time, allowing the contract to // initialize its internal data Init(ContractStubInterface) *pb.ContractMessage // 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(ContractStubInterface) *pb.ContractMessage }
Contract interface must be implemented by all contracts. The candy runs the transactions by calling these functions as specified.
type ContractStub ¶
type ContractStub struct { TxID string // contains filtered or unexported fields }
func (*ContractStub) DelState ¶
func (cs *ContractStub) DelState(collection, key string) error
func (*ContractStub) GetArgs ¶
func (cs *ContractStub) GetArgs() [][]byte
func (*ContractStub) GetArgsSlice ¶
func (cs *ContractStub) GetArgsSlice() ([]byte, error)
func (*ContractStub) GetFunctionAndParameters ¶
func (cs *ContractStub) GetFunctionAndParameters() (string, []string)
func (*ContractStub) GetState ¶
func (cs *ContractStub) GetState(collection, key string) ([]byte, error)
func (*ContractStub) GetStringArgs ¶
func (cs *ContractStub) GetStringArgs() []string
func (*ContractStub) GetTxID ¶
func (cs *ContractStub) GetTxID() string
func (*ContractStub) InvokeContract ¶
func (cs *ContractStub) InvokeContract(cID string, args [][]byte)
type ContractStubInterface ¶
type ContractStubInterface interface { // GetArgs returns the arguments intended for the contract Init and Invoke // as an array of byte arrays. GetArgs() [][]byte // GetStringArgs returns the arguments intended for the contract 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 contract Init and // Invoke as a byte array GetArgsSlice() ([]byte, error) InvokeContract(cID string, args [][]byte) /*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(collection, key string) ([]byte, 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 a // null character (0x00) in order to avoid range query collisions with // composite keys, which internally get prefixed with 0x00 as composite // key namespace. In addition, if using CouchDB, keys can only contain // valid UTF-8 strings and cannot begin with an underscore ("_"). PutState(collection, key string, value []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(collection, key string) error // GetTxID returns the tx_id of the transaction proposal, which is unique per // transaction and per client GetTxID() string }
ContractStubInterface is used by deployable contract apps to access and modify their ledgers
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewContractHandler ¶
func NewContractHandler(stream NodeContractStream, c Contract) *Handler
type NodeContractStream ¶
type NodeContractStream interface { Send(*pb.ContractMessage) error Recv() (*pb.ContractMessage, error) }
Click to show internal directories.
Click to hide internal directories.