Details
-
Sub-task
-
Status: Closed
-
Medium
-
Resolution: Done
-
None
Description
among other things, v8 introduced native "async" and "await" support that transforms messy Promise-based source code like this:
Invoke(stub) { let ret = stub.getFunctionAndParameters(); return stub.getState('dummyKey') .then((value) => { if (value.toString() === 'dummyValue') { return stub.success(); } else { console.error('Failed to retrieve dummyKey or the retrieved value is not expected: ' + value); return shim.error(); } } }
to this:
Invoke(stub) { let ret = stub.getFunctionAndParameters(); let value = await stub.getState('dummyKey'); if (value.toString() === 'dummyValue') { return stub.success(); } else { console.error('Failed to retrieve dummyKey or the retrieved value is not expected: ' + value); return shim.error(); } }
There's also performance benefits due to "Ignition" (interpreter) and "Turbofan" (JIT compiler).
Note that node 8 does not enter LTS (Long-Term Service) status until October (exact date to be determined), but we have obtained agreement from node.js engine committers for support on possible bug fixes during the interim. Thus we felt it's appropriate to introduce the node.js chaincode feature directly on top of node 8 rather than 6.x.
For developers who are writing both chaincode and client applications with the node.js SDK, although the node.js SDK may still be stuck on 6.x for official support (pending further discussions), the good news is that node 8 has excellent backward compatibility, so they should be able to continue to write both code for app and chaincode under node 8 and test. As long as they don't accidentally introduce language features that are not supported by 6.x in the client app, they should be fine.
Attachments
Issue Links
- is duplicated by
-
FABCN-28 Improve the NodeJS chaincode container to use a lighter-weight image
-
- Closed
-