Когда я пытаюсь отправить транзакцию через сервер REST API, возвращается ошибка 500.Я начал получать эту ошибку после обновления до версии 0.19.7 Hyperledger Composer.
BNA с этой транзакцией и моделью была протестирована на площадке Hyperledger Composer, и там она работает хорошо.
Вот ошибкаиз ответа я получаю
{"error":{"statusCode":500,"name":"Error","message":"Error trying invoke business network. Error: No valid responses from any peers.\nResponse from attempted peer comms was an error: Error: 2 UNKNOWN: error executing chaincode: transaction returned with failure: Error: Generated invalid JSON: ...
at _initializeChannel.then.then.then.then.catch (/home/composer/.npm-global/lib/node_modules/composer-rest-server/node_modules/composer-connector-hlfv1/lib/hlfconnection.js:980:34)\n at <anonymous>"}}
Вот журнал с остального сервера
Response from attempted peer comms was an error: Error: 2 UNKNOWN: error executing chaincode: transaction returned with failure: Error: Generated invalid JSON: ...
at _initializeChannel.then.then.then.then.catch (/home/composer/.npm-global/lib/node_modules/composer-rest-server/node_modules/composer-connector-hlfv1/lib/hlfconnection.js:980:34)
at <anonymous>
Вот транзакция по отправке, в которой я получаю сообщение об ошибке:
/**
* @param
{com.iba.linux.chainnetwork.contract.transaction.ResponseConfiguration} responseConfiguration
* @transaction
*/
function responseConfiguration(responseConfiguration) {
var subOrder = responseConfiguration.subOrder;
subOrder.productionTime = responseConfiguration.productionTime;
return updateSubOrder(subOrder, 'approvedConfig');
}
function updateSubOrder(subOrder, state) {
var order = subOrder.order;
subOrder.state = state;
return updateAssetInRegistry(subOrder).then(function () {
return updateOrderIfSubOrdersStateEquals(order, state, subOrder);
}).then(function (order) {
return updateAssetInRegistry(order);
});
}
function updateAssetInRegistry(asset) {
return getAssetRegistry(asset.getFullyQualifiedType())
.then(function updTheReg(registry) {
return registry.update(asset);
});
}
function updateOrderIfSubOrdersStateEquals(order, state, modifiableSubOrder) {
var shouldBeUpdated = 0;
return Promise.all(order.subOrders.map(function (subOrder) {
return getAssetFromRegistry(subOrder)
.then(function (subOrder) {
if (state === subOrder.state || modifiableSubOrder.getIdentifier() === subOrder.getIdentifier()) {
shouldBeUpdated++;
}
return subOrder;
});
})).then(function () {
if (shouldBeUpdated === order.subOrders.length) {
order.state = state;
}
return order;
});
}
Модель:
contract_transactions.cto
namespace com.iba.linux.chainnetwork.contract.transaction
import com.iba.linux.chainnetwork.contract.SubOrder
import com.iba.linux.chainnetwork.contract.Order
transaction ResponseConfiguration {
--> SubOrder subOrder
o Integer productionTime
}
contract.cto
namespace com.iba.linux.chainnetwork.contract
import com.iba.linux.chainnetwork.asset.definition.AssetDetails
import com.iba.linux.chainnetwork.asset.entity.SimpleAsset
import com.iba.linux.chainnetwork.partner.PrivateOwner
enum OrderState {
o createdConfig
o approvedConfig
o acceptedByClient
o rejectedByClient
o manufacturing
o readyForDeliver
o delivering
o delivered
}
asset SubOrder identified by subOrderId {
o String subOrderId
--> AssetDetails assetDetails
--> Order order
o String note optional
o Integer productionTime optional
--> SimpleAsset orderedAsset optional
o String clientSign optional
o OrderState state
--> Invoice invoice optional
}
asset Order identified by orderId {
o String orderId
--> PrivateOwner client
--> SubOrder[] subOrders
o OrderState state
--> PrivateOwner courier
}
asset Invoice identified by invoiceId {
o String invoiceId
}
partners.cto
namespace com.iba.linux.chainnetwork.partner
abstract participant Person identified by email {
o String email
}
enum Role {
o Client
o Seller
o Courier
}
participant PrivateOwner extends Person {
o Role businessRole
}
Что не так?