前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >fabric区块链(四)—chaincode接口

fabric区块链(四)—chaincode接口

作者头像
酒楼
发布2023-05-30 09:50:09
2190
发布2023-05-30 09:50:09
举报
文章被收录于专栏:酒楼

fabric智能合约-chaincode接口:

代码语言:javascript
复制
package shim

import (
	"github.com/hyperledger/fabric/protos/peer"
)

// ChaincodeStubInterface provides the shim interface of a chaincode invocation
type ChaincodeStubInterface interface {
	// State Management

	// GetState returns the value of the specified `key`
	GetState(key string) ([]byte, error)
	// PutState writes the specified `value` and `key` into the ledger
	PutState(key string, value []byte) error
	// DelState deletes the specified `key` from the ledger
	DelState(key string) error

	// Private Data Management

	// GetPrivateData returns the value of the specified `key` from the private data collection
	GetPrivateData(collection, key string) ([]byte, error)
	// PutPrivateData writes the specified `value` and `key` into the private data collection
	PutPrivateData(collection, key string, value []byte) error
	// DelPrivateData deletes the specified `key` from the private data collection
	DelPrivateData(collection, key string) error

	// State Query

	// GetStateByRange returns a range iterator over a set of keys in the ledger. The iterator can be used to iterate over all keys
	// between the startKey (inclusive) and endKey (exclusive). However, if the number of keys between startKey and endKey is greater than
	// the totalQueryLimit then iterator will be positioned at startKey and will contain no keys. The totalQueryLimit is intended to be
	// set by a chaincode's MSP policies at install or instantiation time. If no value is set by the policy, then the default value of
	// the peer will be used. Setting totalQueryLimit to zero will allow a chaincode to read any number of keys.
	GetStateByRange(startKey, endKey string) (StateQueryIteratorInterface, error)
	// GetStateByPartialCompositeKey queries the state in the ledger based on a given partial composite key. This function returns an
	// iterator which can be used to iterate over all composite keys whose prefix matches the given partial composite key. The
	// `ObjectType` returned by the iterator is the `Attributes`. If there are no matching keys in the ledger, then the returned
	// iterator will contain no keys.
	GetStateByPartialCompositeKey(objectType string, keys []string) (StateQueryIteratorInterface, error)
	// GetQueryResult performs a "rich" query against a state database. It is only supported by state databases that support rich query,
	// such as CouchDB. An error will be returned if this method is called against a state database that does not support rich query.
	GetQueryResult(query string) (StateQueryIteratorInterface, error)
	// GetHistoryForKey returns a history of key values across time.
	GetHistoryForKey(key string) (HistoryQueryIteratorInterface, error)

	// Transient Data Management

	// GetTransient returns the value of the specified `key` from the transient store
	GetTransient(key string) ([]byte, error)

	// Chaincode Invocation

	// GetArgs returns the argument values from the invocation message
	GetArgs() [][]byte
	// GetStringArgs returns the argument values from the invocation message as strings
	GetStringArgs() []string
	// GetFunctionAndParameters returns the function name and parameters as bytes
	GetFunctionAndParameters() (string, []string)

	// Invokes another chaincode with the specified `chaincodeName`, `args
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2023-05-13,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • fabric智能合约-chaincode接口:
相关产品与服务
区块链
云链聚未来,协同无边界。腾讯云区块链作为中国领先的区块链服务平台和技术提供商,致力于构建技术、数据、价值、产业互联互通的区块链基础设施,引领区块链底层技术及行业应用创新,助力传统产业转型升级,推动实体经济与数字经济深度融合。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档