作曲者-错误:8 RESOURCE_EXHAUSTED“网络过载”

时间:2018-06-21 10:35:49

标签: hyperledger-fabric blockchain hyperledger hyperledger-composer

我想更新我的业务网络时遇到以下错误

Error: 8 RESOURCE_EXHAUSTED: received trailing metadata size exceeds limit

在检查了我的系统资源后,我发现只有网络超载了,可能是由于容器之间发送了数据,但我不知道是什么使它变得如此高。

我正在使用虚拟机ubuntu 16.04,而我对商业网络的新更新是

-模型

/**
 * My commodity trading network
 */
namespace org.example.mynetwork
asset Commodity identified by tradingSymbol {
    o String tradingSymbol
    o String name
    o String description
    o Double value
    --> Trader owner
}
participant Trader identified by traderId {
    o String traderId
    o String firstName
    o String lastName
    o Double balance
    o String password
}
transaction Trade {
    --> Commodity commodity
    --> Trader newOwner
}

交易

/*
*
 * @param {org.example.mynetwork.Trade} trade
 * @transaction
 */
async function tradeCommodity(trade) {
  if(trade.newOwner.balance < trade.commodity.value)
    return;
  trade.commodity.owner.balance = trade.commodity.owner.balance + trade.commodity.value;
  let participantRegistry = await getParticipantRegistry('org.example.mynetwork.Trader');
  await participantRegistry.update(trade.commodity.owner);
  trade.newOwner.balance = trade.newOwner.balance - trade.commodity.value;
  trade.commodity.owner = trade.newOwner;
  let assetRegistry = await getAssetRegistry('org.example.mynetwork.Commodity');
  await assetRegistry.update(trade.commodity);
  await participantRegistry.update(trade.newOwner);
}

我刚刚尝试用默认实现创建一个新的网络,但由于同样的原因它也失败了!

2 个答案:

答案 0 :(得分:0)

this issue in Composer中观察到,您可能有太多的Docker容器(可能还有docker映像)。

如果您乐意“再次启动”,则可以尝试以下命令来停止和删除容器,以及删除docker映像:

docker stop $(docker ps -q)

docker remove $(docker ps -aq)

docker rmi $(docker images -q)

我建议rm -rf ~/.composer删除所有“旧”卡,然后在fabric-dev-servers文件夹中使用脚本downloadFabric.shstartFabric.shcreatePeerAdminCard.sh < / p>

答案 1 :(得分:0)

我刚刚在默认的trade-network网络中尝试了以下功能-它可以按您的预期工作,因此非常想知道它是否对您有用。此外,您是否有交易者的余额余额值?

我创建了一个名为trade2的事务-因此它也有一个单独的函数名称(基本上是后缀2)。我想知道您是否为代码中的现有trade事务保留了相同的函数名称,并且未调用正确的函数??

/*
*
 * @param {org.example.mynetwork.Trade2} trade2
 * @transaction
 */

    async function tradeCommodity2(trade2) {
      if(trade2.newOwner.balance < trade2.commodity.value)
        return; // left this for now.

      trade2.commodity.owner.balance = trade2.commodity.owner.balance + trade2.commodity.value;
      console.log(" owner balance after is " + trade2.commodity.owner.balance ) ;
      let participantRegistry = await getParticipantRegistry('org.example.mynetwork.Trader');
      await participantRegistry.update(trade2.commodity.owner);

      trade2.newOwner.balance = trade2.newOwner.balance - trade2.commodity.value;

      trade2.commodity.owner = trade2.newOwner;
      let assetRegistry = await getAssetRegistry('org.example.mynetwork.Commodity');
      await assetRegistry.update(trade2.commodity);
      await participantRegistry.update(trade2.newOwner);
    }

此外,您应该使用throw而不是return仅供参考

例如

if(trade2.newOwner.balance < trade2.commodity.value) {
    throw new Error('Insufficient balance');
 }