0

在超级账本作曲家中,我们必须在注释中指定参数和事务,编译器不应该忽略注释吗?这是如何工作的,为什么有必要在评论中这样做?

/**
  * A temperature reading has been received for a shipment
  * @param {org.acme.shipping.perishable.TemperatureReading} 
    temperatureReading - the TemperatureReading transaction
  * @transaction
*/
    function temperatureReading(temperatureReading) {

var shipment = temperatureReading.shipment;

console.log('Adding temperature ' + temperatureReading.centigrade + ' to shipment ' + shipment.$identifier);

if (shipment.temperatureReadings) {
    shipment.temperatureReadings.push(temperatureReading);
} else {
    shipment.temperatureReadings = [temperatureReading];
}

return getAssetRegistry('org.acme.shipping.perishable.Shipment')
    .then(function (shipmentRegistry) {
        // add the temp reading to the shipment
        return shipmentRegistry.update(shipment);
    });
  }
4

1 回答 1

0

有关更多说明,请参见此处-> https://hyperledger.github.io/composer/reference/js_scripts.html

“评论”中的装饰器用于使用运行时处理所需的元数据来注释函数。装饰器是一个动态添加功能到另一个对象的对象,在 Javascript 中并不少见。

于 2017-11-09T14:55:42.800 回答