高端织物基食品安全系统案例研究
1. 食品相关功能实现
1.1 食品配料流通
该功能实现了用户(即配料卖家)之间的配料流通,并将变更记录保存到区块链。以下是具体的代码实现:
// Change in ingredients
func (c *IngredientsExchangeCC) ingredientExchange(stub shim.ChaincodeStubInterface, args []string) pb.Response {
// Check the number of parameters
if len(args) != 3 {
return shim.Error("not enough args")
}
// Verify the correctness of the parameters
ownerId := args[0]
ingredientId := args[1]
currentOwnerId := args[2]
if ownerId == "" || ingredientId == "" || currentOwnerId == "" {
return shim.Error("invalid args")
}
// Verify the existence of the data
originOwnerBytes, err := stub.GetState(constructUserKey(ownerId))
if err != nil || len(ori
超级会员免费看
订阅专栏 解锁全文
790

被折叠的 条评论
为什么被折叠?



