Hyperledger中的复合键功能 [英] Composite Key functions in Hyperledger

查看:66
本文介绍了Hyperledger中的复合键功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在超级账本中实现复合密钥,这样我才能根据放入账本中的属性获得唯一的密钥.函数CreateCompositeKey(objectType string, attributes []string)(string,error) 接受objectType和attribute字符串.我在网上找不到任何示例,如何将要传递给组合键的相关属性以及以哪种方式给出输出?
因此,应该使用复合密钥的方式是先生成一个密钥,然后使用PutState(key string, value []byte) error将其推送到区块链,其中PutState中的嘿是CreateCompositeKey的输出?如果不是,那么如何使用复合键?
类似地

I need to implement composite keys in hyperledger so that I could have a unique key based on the attributes put into the ledger. The function CreateCompositeKey(objectType string, attributes []string)(string,error) takes in objectType and attributes string. I couldnt find any examples of this online, how are the relevant attributes to be made into the composite key passed and in what way is the output given?
So the way Composite keys should be used is make a key first and then push it to the blockchain with PutState(key string, value []byte) error where the hey in PutState is the output of CreateCompositeKey? If not, then how are composite keys to be used?
Similarly in

GetStateByPartialCompositeKey(objectType string, keys []string) (StateQueryIteratorInterface, error)

我们要如何通过传递给函数进行查询的键?输出数据类型为"StateQueryIteratorInterface"和"HistoryQueryIteratorInterface"是什么?
我对编程还很陌生,并且没有任何数据库方面的知识,因此对真正的基础知识感到困惑.非常感谢您的帮助!

How are the keys we want to make queries by passed to the function? And what are the output data types "StateQueryIteratorInterface" and "HistoryQueryIteratorInterface"?
I am fairly new to programming and have no prior knowledge of databases so am getting confused with really basic things. I'd really appreciate some help!

推荐答案

在Hyperledger Fabric中,有一个示例链代码显示了如何使用组合键,请检查一下:

In Hyperledger Fabric there is an example chaincode which shows how to use composite keys, check it out: Marbles

基本上就像您说的那样:

Basically it almost as you said:

key, err := stub.CreateCompositeKey(index, []string{key1, key2, key3})

// Skiped

stub.PutState(key, value)

这篇关于Hyperledger中的复合键功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆