无法删除ID为ID的对象,因为该对象不存在

时间:2019-05-24 05:17:38

标签: hyperledger-fabric hyperledger-composer ibm-blockchain

我正在做本教程 link。我添加了将由事务removeHighQuantityCommodities删除的对象。这是交易方法。

/**
 * 
 * @param {org.example.mynetwork.RemoveHighQuantityCommodities} remove -  remove to be proocessed
 * @transaction
 */
    async function RemoveHighQuantityCommodities(remove){
let assetRegistry = await getAssetRegistry('org.example.mynetwork.Commodity');
let results = await query('selectCommoditiesWithHighQuantity');

for (let n = 0; n < results.length; n++) {
    let trade = results[n];

    // emit a notification that a trade was removed
    let removeNotification = getFactory().newEvent('org.example.mynetwork','RemoveNotification')
    removeNotification.commodity = trade;
    emit(removeNotification);
    await assetRegistry.remove(trade);
}

当我调用此事务时,会出现以下错误:

  

尝试调用事务ID为b74ec4d56a631bda73718891cf22cabeda1d50ea57fd5643a00b4843c4618e8e的业务网络时出错。错误:没有来自任何对等方的有效响应。\ n来自尝试对等方通信的响应是一个错误:错误:事务返回失败:错误:无法删除ID为“ Asset:org.example.mynetwork”的ID为“ APL”的对象。商品”,因为该对象不存在。

当我查询商品时,会显示具有APL ID的商品。

    [
     {
      "$class": "org.example.mynetwork.Commodity",
       "tradingSymbol": "ACN",
       "mainExchange": "NYSE",
       "description": "ACN STOCK",
        "quantity": 50,
        "owner": "resource:org.example.mynetwork.Trader#PERSON"
     },
     {
       "$class": "org.example.mynetwork.Commodity",
       "tradingSymbol": "APL",
       "mainExchange": "NYSE",
       "description": "APPLE STOCK",
       "quantity": 100,
       "owner": "resource:org.example.mynetwork.Trader#PERSON"
   },

0 个答案:

没有答案