Ethereum transaction data serialization size
Publish: 2021-04-28 00:14:11
1.
transactions.forEach(function(tx){
vartxInfo=web3.eth.getTransaction(tx.transactionHash);
/ / at this time, the transaction information txinfo can be stored in the database
})< br />}); Pre >
If you want to query the transaction records on the main network, you can use Etherscan. However, if you build your own private chain, how should you query the transaction records
the answer is that you need to listen to the logs on the chain, save them in the database, and then query them in the database. For example:
< pre t = "code" L = "Java" > varaddr = & quot& quot;< br />varfilter=web3.eth.filter({fromB lock:0 ,toBlock:' latest', address:addr });< br />filter.get(function(err,transactions){transactions.forEach(function(tx){
vartxInfo=web3.eth.getTransaction(tx.transactionHash);
/ / at this time, the transaction information txinfo can be stored in the database
})< br />}); Pre >
Web3. Eth. Filter() is used to monitor the log on the chain, and Web3. Eth. Gettransaction() is used to extract the information of the specified transaction. Once the transaction information is obtained, it can be stored in the database for query
recommend a practical introction, you can see: Ethereum tutorial
2. You use hibernate to save data. As long as the XML file is configured, the Dao layer of the entity class is correct. Call the save method and commit to save the data
serialization is to convert the data you want to save into bytecode, while deserialization is to convert bytecode into data
you can directly submit data to the hard disk through the local server, which really does not require serialization
but when you transmit on the network, you can't do it. You pass something to others. After it receives all the bytecodes, it doesn't know what object you originally transmitted, so it can't parse it according to the original
after you serialize, when you send it to the other party and receive it, it will be deserialized according to the specific mode of serialization. That is to say, what you send, what the other party receives, and the parsing is successful. You can use the method and attribute correctly.
serialization is to convert the data you want to save into bytecode, while deserialization is to convert bytecode into data
you can directly submit data to the hard disk through the local server, which really does not require serialization
but when you transmit on the network, you can't do it. You pass something to others. After it receives all the bytecodes, it doesn't know what object you originally transmitted, so it can't parse it according to the original
after you serialize, when you send it to the other party and receive it, it will be deserialized according to the specific mode of serialization. That is to say, what you send, what the other party receives, and the parsing is successful. You can use the method and attribute correctly.
3. What is serialization:
serialization is to save the state of an object (each attribute quantity) and then obtain it at an appropriate time
serialization is divided into two parts: serialization and deserialization. Serialization is the first part of the process, decomposing data into byte streams for storage in files or transmission over the network. Deserialization is to open the byte stream and reconstruct the object. Object serialization not only converts the basic data type to byte representation, but also recovers the data sometimes. Recovering data requires an object instance of the recovered data
What are the characteristics of serialization:
If a class can be serialized, its subclasses can also be serialized. Member data declared as static and transient types cannot be serialized. Because static represents the state of the class, transient represents the temporary data of the object<
when to use serialization:
1: object serialization can realize distributed objects. Main applications, for example, RMI uses object serialization to run services on remote hosts, just like running objects on local hosts
2: object serialization not only preserves the data of an object, but also recursively preserves the data of each object referenced by an object. The entire object hierarchy can be written to a byte stream, saved in a file or passed over a network connection. Object serialization can be used for & quot; Deep ;, That is to the object itself and the referenced object itself. Serializing an object can result in an entire sequence of objects.
serialization is to save the state of an object (each attribute quantity) and then obtain it at an appropriate time
serialization is divided into two parts: serialization and deserialization. Serialization is the first part of the process, decomposing data into byte streams for storage in files or transmission over the network. Deserialization is to open the byte stream and reconstruct the object. Object serialization not only converts the basic data type to byte representation, but also recovers the data sometimes. Recovering data requires an object instance of the recovered data
What are the characteristics of serialization:
If a class can be serialized, its subclasses can also be serialized. Member data declared as static and transient types cannot be serialized. Because static represents the state of the class, transient represents the temporary data of the object<
when to use serialization:
1: object serialization can realize distributed objects. Main applications, for example, RMI uses object serialization to run services on remote hosts, just like running objects on local hosts
2: object serialization not only preserves the data of an object, but also recursively preserves the data of each object referenced by an object. The entire object hierarchy can be written to a byte stream, saved in a file or passed over a network connection. Object serialization can be used for & quot; Deep ;, That is to the object itself and the referenced object itself. Serializing an object can result in an entire sequence of objects.
4. Convert an array to a string and store it in the database.
reference function:
implode() --- convert an array to a string.
explode() --- convert a string to an array.
detailed instructions are given in the manual.
for one-dimensional arrays, you can simply use the
implode
explode
function to make an array - string transformation, but note that the separator should use characters that do not exist in the array
for multi-dimensional arrays, you can use the serialize function
serialize
unserialize
function's usage manual
reference function:
implode() --- convert an array to a string.
explode() --- convert a string to an array.
detailed instructions are given in the manual.
for one-dimensional arrays, you can simply use the
implode
explode
function to make an array - string transformation, but note that the separator should use characters that do not exist in the array
for multi-dimensional arrays, you can use the serialize function
serialize
unserialize
function's usage manual
5. mark
6. How to deserialize datatable with huge amount of data and long waiting time< The main functions of serialization and deserialization are as follows:
1. Read the information of the last saved object when the process starts next time
2. Transfer data between different AppDomains or processes
3. Transfer data in distributed application system
there are three common serialization methods in C: BinaryFormatter, soapformatter XML serialization
therefore, adding a property [serializable] to a class is to indicate that the class is serializable to the above methods. Otherwise, serializationexception will be thrown.
as for what you said, it is feasible for WebService to return datatable. It is feasible. Net framework will automatically generate XML content for each system's namespace class, but this does not mean that datatable can be deserialized smoothly. After the web service returns and restores at the remote end, some properties will become null. That's why datatable is not serializable
happy to live in Baodi for a thousand years
1. Read the information of the last saved object when the process starts next time
2. Transfer data between different AppDomains or processes
3. Transfer data in distributed application system
there are three common serialization methods in C: BinaryFormatter, soapformatter XML serialization
therefore, adding a property [serializable] to a class is to indicate that the class is serializable to the above methods. Otherwise, serializationexception will be thrown.
as for what you said, it is feasible for WebService to return datatable. It is feasible. Net framework will automatically generate XML content for each system's namespace class, but this does not mean that datatable can be deserialized smoothly. After the web service returns and restores at the remote end, some properties will become null. That's why datatable is not serializable
happy to live in Baodi for a thousand years
7. If it's a JSON string, you just need to parse it
the frameworks for parsing JSON include open source frameworks such as gson jsonobject
jsonobj = new jsonobject (JSON string)
the value methods are:
obj. GetString (key)< br />obj.getJSONObject(key);< br />obj.getJSONArray(key);
for more information, see the API
the frameworks for parsing JSON include open source frameworks such as gson jsonobject
jsonobj = new jsonobject (JSON string)
the value methods are:
obj. GetString (key)< br />obj.getJSONObject(key);< br />obj.getJSONArray(key);
for more information, see the API
8. 1) After encoding, serialize is about 1.5 times of JSON
reason:
after serialize, the string contains the length of substring, which may be the optimization of speed, but the test result is not satisfactory
serialize has more detailed type differentiation, while JSON has only four types and is represented by simple symbols
2) speed comparison
in the case of small data, serialize is several orders of magnitude faster than JSON
in the case of large amount of data, JSON is slightly worse than serialize
3) processing objects
JSON cannot process data such as object methods
4) scope of use
JSON is generally used in front-end and back-end interaction. In addition, currently, JSON only supports UTF-8 encoded data
serialization uses serialize, especially the storage of objects. This is the meaning of its existence
JSON can be used for object independent data storage, such as arrays containing a large number of numbers.
reason:
after serialize, the string contains the length of substring, which may be the optimization of speed, but the test result is not satisfactory
serialize has more detailed type differentiation, while JSON has only four types and is represented by simple symbols
2) speed comparison
in the case of small data, serialize is several orders of magnitude faster than JSON
in the case of large amount of data, JSON is slightly worse than serialize
3) processing objects
JSON cannot process data such as object methods
4) scope of use
JSON is generally used in front-end and back-end interaction. In addition, currently, JSON only supports UTF-8 encoded data
serialization uses serialize, especially the storage of objects. This is the meaning of its existence
JSON can be used for object independent data storage, such as arrays containing a large number of numbers.
9. It inherits the serializable interface and declares declare a static final serialVersionUID, which is similar to private static final long serialVersionUID = 1L; If not, add it
Hot content
