hyperledger-fabric - 检测到循环 ACL 规则,规则条件正在调用相同的规则
问题描述
在超级账本中添加新数据时出现错误。
更新工作正常。
这是我面临问题的一些代码
if(isExist) {
const oldProOwnVal = await PropertyOwnersRegistry.get(isExist.ownershipId);
owners.ownership_start_date = oldProOwnVal.ownership_start_date;
owners.created_at = oldProOwnVal.created_at;
owners.updated_at = updatedProperty.timestamp;
const mergeOwner = Object.assign(oldProOwnVal, owners);
await PropertyOwnersRegistry.update(mergeOwner);
} else {
newKey = 'xxxx-xxxx-4xxx-yxxx-xxxx'.replace(/[xy]/g, function(c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
const newOwnerRes = factory.newResource(NS, 'PropertyOwners', newKey);
owners.ownership_start_date = updatedProperty.timestamp;
owners.created_at = updatedProperty.timestamp;
owners.updated_at = updatedProperty.timestamp;
const newOwner = Object.assign(newOwnerRes, owners);
await PropertyOwnersRegistry.add(newOwner);
}
问题只发生在行中
await PropertyOwnersRegistry.add(newOwner);
不知道这里发生了什么。
解决方案
这可能是您在调用 Composer API 之前的设置方式 - 例如getAssetRegistry
(资产)或getParticipantRegistry
(参与者) - 否则它超出了add
第 2 部分的范围。我没有看到您的模型或之前的代码 -所以在下面酌情补充:
这应该有效(未尝试过) - 注意 - 如果您正在测试背书等,您有不确定的代码:
const NS = 'org.acme.example';
var factory = getFactory();
const propRegistry = await getAssetRegistry(NS+ '.PropertyOwners'');
if(isExist) {
const oldProOwnVal = await propRegistry.get(isExist.ownershipId);
owners.ownership_start_date = oldProOwnVal.ownership_start_date;
owners.created_at = oldProOwnVal.created_at;
const mergeOwner = Object.assign(oldProOwnVal, owners);
//etc
await propRegistry.update(mergeOwner);
} else {
newKey = 'xxxx-xxxx-4xxx-yxxx-xxxx'.replace(/[xy]/g, function(c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); // this code is non-deterministic
return v.toString(16);
});
const newOwnerRes = factory.newResource(NS, 'PropertyOwners', newKey);
owners.ownership_start_date = updatedProperty.timestamp;
owners.created_at = updatedProperty.timestamp;
owners.updated_at = updatedProperty.timestamp;
const newOwner = Object.assign(newOwnerRes, owners);
await propRegistry.add(newOwner);
}
推荐阅读
- reactjs - 当我想使用 react axios 从 django rest api 获取一些东西时,它在我的控制台中显示 [object Object]
- dart - 如何将 8 位无符号 int 数据转换为有符号?
- android - 我如何在颤动中创建这样的下拉列表
- python - ros2:错误:无法识别的参数:--qos-profile-overrides-path profile.yaml
- blockchain - 在solidity中声明为视图错误的函数
- reactjs - React 组件:出现语法错误:尝试将函数添加到我的代码时无法读取未定义的属性(读取“地图”)(0:未定义)
- vba - 如果满足特定条件,则循环遍历范围并删除行
- python - 如何按列中的类别聚合以填充另一列中的空值?(Python)
- vue.js - jsPDF未定义
- angular - 如何从component.ts触发p-tree中的(onNodeSelect)事件?