执行命令时:
composer archive create --sourceType dir --sourceName /home/testuser/test-network -a /home/testuser/test-network/dist/test-network.bna
我收到错误:
Creating Business Network Archive
Looking for package.json of Business Network Definition
Input directory: /home/testuser/test-network
/usr/lib/node_modules/composer-cli/node_modules/yargs/yargs.js:1079
else throw err
^
Error: namespace already exists
at ModelManager.addModelFiles (/usr/lib/node_modules/composer-cli/node_modules/composer-common/lib/modelmanager.js:234:31)
at Function.fromDirectory (/usr/lib/node_modules/composer-cli/node_modules/composer-common/lib/businessnetworkdefinition.js:493:43)
at Function.handler (/usr/lib/node_modules/composer-cli/lib/cmds/archive/lib/create.js:80:42)
at Object.module.exports.handler (/usr/lib/node_modules/composer-cli/lib/cmds/archive/createCommand.js:31:30)
at Object.self.runCommand (/usr/lib/node_modules/composer-cli/node_modules/yargs/lib/command.js:233:22)
at Object.Yargs.self._parseArgs (/usr/lib/node_modules/composer-cli/node_modules/yargs/yargs.js:990:30)
at Object.self.runCommand (/usr/lib/node_modules/composer-cli/node_modules/yargs/lib/command.js:204:45)
at Object.Yargs.self._parseArgs (/usr/lib/node_modules/composer-cli/node_modules/yargs/yargs.js:990:30)
at Object.get [as argv] (/usr/lib/node_modules/composer-cli/node_modules/yargs/yargs.js:927:19)
at Object.<anonymous> (/usr/lib/node_modules/composer-cli/cli.js:58:5)
我已经更改了文件来构建网络,甚至我得到了示例文件的错误:
文件/home/testuser/test-network/lib/logic.js:
function sampleTransaction(tx) {
// Save the old value of the asset.
var oldValue = tx.asset.value;
// Update the asset with the new value.
tx.asset.value = tx.newValue;
// Get the asset registry for the asset.
return getAssetRegistry('org2.acme.sample2.SampleAsset')
.then(function (assetRegistry) {
// Update the asset in the asset registry.
return assetRegistry.update(tx.asset);
})
.then(function () {
// Emit an event for the modified asset.
var event = getFactory().newEvent('org2.acme.sample2', 'SampleEvent');
event.asset = tx.asset;
event.oldValue = oldValue;
event.newValue = tx.newValue;
emit(event);
});
}
文件/home/testuser/test-network/test.cto:
namespace org2.acme.sample2
asset SampleAsset identified by assetId {
o String assetId
--> SampleParticipant owner
o String value
}
participant SampleParticipant identified by participantId {
o String participantId
o String firstName
o String lastName
}
transaction SampleTransaction {
--> SampleAsset asset
o String newValue
}
event SampleEvent {
--> SampleAsset asset
o String oldValue
o String newValue
}
我也试图更改命名空间,但我得到了同样的错误
答案 0 :(得分:1)
请参阅https://hyperledger.github.io/composer/reference/cto_language.html
否则,建议移动任何版本&#39;具有相同命名空间名称的CTO文件。
然后再次尝试构建.bna文件。