【Error未解决】Error:500 - Internal Server Error

错误描述

https://stackoverflow.com/questions/55804038/transaction-has-500-error-when-i-test-in-angular-and-composer-rest-server-but-pl
Everyday New Struggle.
【Error未解决】Error:500 - Internal Server Error_第1张图片

在rest server测试了一下:

{
  "error": {
    "statusCode": 500,
    "name": "Error",
    "message": "Error trying invoke business network with transaction id 6516e9a2e5ec0b325c7e756124b07f92dbbce5d47c2c0503f70fe537bc1e33e2. Error: No valid responses from any peers.\nResponse from attempted peer comms was an error: Error: transaction returned with failure: ValidationException: Instance org.sc.product.SampleEvent#6516e9a2e5ec0b325c7e756124b07f92dbbce5d47c2c0503f70fe537bc1e33e2#0 missing required field newowner",
    "stack": "Error: Error trying invoke business network with transaction id 6516e9a2e5ec0b325c7e756124b07f92dbbce5d47c2c0503f70fe537bc1e33e2. Error: No valid responses from any peers.\nResponse from attempted peer comms was an error: Error: transaction returned with failure: ValidationException: Instance org.sc.product.SampleEvent#6516e9a2e5ec0b325c7e756124b07f92dbbce5d47c2c0503f70fe537bc1e33e2#0 missing required field newowner\n    at HLFConnection.invokeChainCode (/home/cielo/.nvm/versions/node/v8.15.1/lib/node_modules/composer-rest-server/node_modules/composer-connector-hlfv1/lib/hlfconnection.js:1117:30)\n    at "
  }
}

【Error未解决】Error:500 - Internal Server Error_第2张图片

无法理解,去playground测试了一下:

t: Instance org.sc.product.SampleEvent#72bf1c2b-7fbd-4267-befd-660981348976#0 missing required field oldowner

【Error未解决】Error:500 - Internal Server Error_第3张图片

解决方案

playground NB!
原来交易的代码在这里!
修改了!
【Error未解决】Error:500 - Internal Server Error_第4张图片
修改如下,就是改源码的时候没改全!!!!

*
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

'use strict';
/**
 * Write your transction processor functions here
 */

/**
 * Sample transaction
 * @param {org.sc.product.SampleTransaction} sampleTransaction
 * @transaction
 */
async function sampleTransaction(tx) {
    // Save the old value of the asset.
    const oldValue = tx.asset.value;
    const oldowner = tx.asset.owner;

    // Update the asset with the new value.
    tx.asset.value = tx.newValue;
    tx.asset.owner = tx.newowner;

    // Get the asset registry for the asset.
    const assetRegistry = await getAssetRegistry('org.sc.product.SampleAsset');
    // Update the asset in the asset registry.
    await assetRegistry.update(tx.asset);

    // Emit an event for the modified asset.
    let event = getFactory().newEvent('org.sc.product', 'SampleEvent');
    event.asset = tx.asset;
    event.oldValue = oldValue;
    event.newValue = tx.newValue;
    event.oldowner = oldowner;
    event.newowner = tx.newowner;
    emit(event);
}

仍然存在问题

playground测试是没问题了,但是别的两个还是有问题。懵。

{
  "error": {
    "statusCode": 500,
    "name": "Error",
    "message": "Error trying invoke business network with transaction id a54d92c666d4f4f36a09799f5aeda90bb00c513f5cb098d8a7fbb842c94ebe75. Error: No valid responses from any peers.\nResponse from attempted peer comms was an error: Error: transaction returned with failure: ValidationException: Instance org.sc.product.SampleEvent#a54d92c666d4f4f36a09799f5aeda90bb00c513f5cb098d8a7fbb842c94ebe75#0 missing required field newowner",
    "stack": "Error: Error trying invoke business network with transaction id a54d92c666d4f4f36a09799f5aeda90bb00c513f5cb098d8a7fbb842c94ebe75. Error: No valid responses from any peers.\nResponse from attempted peer comms was an error: Error: transaction returned with failure: ValidationException: Instance org.sc.product.SampleEvent#a54d92c666d4f4f36a09799f5aeda90bb00c513f5cb098d8a7fbb842c94ebe75#0 missing required field newowner\n    at HLFConnection.invokeChainCode (/home/cielo/.nvm/versions/node/v8.15.1/lib/node_modules/composer-rest-server/node_modules/composer-connector-hlfv1/lib/hlfconnection.js:1117:30)\n    at "
  }
}

你可能感兴趣的:(composer开发记录)