According to the documentation:'It is critical to select a serialization scheme which is deterministic across executions of the transaction, across platforms, and across versions of the serialization framework. Data structures which don’t enforce ordered serialization (e.g. sets, maps, dicts) should be avoided.'https://sawtooth.hyperledger.org/docs/core/releases/1.2.6/architecture/global_state.html?highlight=deterministic
Node.js uses event-driven non blocking I/O execution model: Execution: PHP is synchronous: Node.js is asynchronous: Execution Speed: PHP is slower than Node.js: Faster than PHP and also light weight compared to PHP. Web Server: PHP runs on the Apache web server. It can also run on IIS web server in case of a windows machine.
Because in javascript most variables are maps, it's not clear how one should should store data.
Thus, storing general JSON data would seem to be a bad idea, as in:
Although JSON.stringify is to a certain extent deterministic (Is JSON.stringify() deterministic in V8?)
Also cbor and protobuff might not be recommended because they do not enforce an ordering:
'The CBOR data model for maps does not allow ascribing semantics tothe order of the key/value pairs in the map representation.'https://tools.ietf.org/html/rfc7049
'By default, repeated invocations of serialization methods on the same protocol buffer message instance may not return the same byte output; i.e. the default serialization is not deterministic.'https://developers.google.com/protocol-buffers/docs/encoding
'Wire format ordering and map iteration ordering of map values is undefined, so you cannot rely on your map items being in a particular order.'https://developers.google.com/protocol-buffers/docs/proto3#maps
MaxIm DL Pro Suite 5.08 all versions serial number and keygen .... From the documentation the only examples I've seen are storing a String with a specific format:https://github.com/hyperledger/sawtooth-sdk-javascript/blob/master/examples/xo/state.js
Or storing a single cbor encoded value:https://github.com/hyperledger/sawtooth-sdk-javascript/blob/master/examples/intkey/handler.js
However, both approaches seem very limited.
The v8.serialize() method is an inbuilt application programming interface of the v8 module which is used to serialize any type of data into a buffer using default serializer.
Syntax:
Parameters: This method one parameter as described below and mentioned above.
Return Value: This method returns a buffer containing serialized data of the passed value.
Below examples illustrate the use of v8.serialize() method in Node.js. Sb0460 driver windows 10.
Example 1:Filename: index.js
const v8 = require( 'v8' ); // Calling v8.serialize() |
Run index.js file using the following command:
Output:
Example 2:Filename: index.js
const v8 = require( 'v8' ); // Calling v8.serialize() console.log( 'nSerialized data is ' ); console.log( 'nSerialized data is ' ); console.log( 'nSerialized data is ' ); console.log( 'nSerialized data is ' ); |
Run index.js file using the following command:
Output:
Reference:https://nodejs.org/api/v8.html#v8_v8_serialize_value
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the 'Improve Article' button below.