WO2020224380A1 - 一种基于区块链的数据处理方法及装置 - Google Patents

一种基于区块链的数据处理方法及装置 Download PDF

Info

Publication number
WO2020224380A1
WO2020224380A1 PCT/CN2020/084319 CN2020084319W WO2020224380A1 WO 2020224380 A1 WO2020224380 A1 WO 2020224380A1 CN 2020084319 W CN2020084319 W CN 2020084319W WO 2020224380 A1 WO2020224380 A1 WO 2020224380A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
node
length
indication information
position indication
Prior art date
Application number
PCT/CN2020/084319
Other languages
English (en)
French (fr)
Inventor
陈宇
李辉忠
张开翔
范瑞彬
Original Assignee
深圳前海微众银行股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳前海微众银行股份有限公司 filed Critical 深圳前海微众银行股份有限公司
Publication of WO2020224380A1 publication Critical patent/WO2020224380A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/565Conversion or adaptation of application format or content
    • H04L67/5651Reducing the amount or size of exchanged application data
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/3236Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials using cryptographic hash functions
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/50Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols using hash chains, e.g. blockchains or hash trees

Definitions

  • the embodiments of the present application relate to the field of financial technology (Fintech), and in particular, to a data processing method and device based on a blockchain (BlockChain).
  • a blockchain is a chain composed of a series of blocks. Each block records the data of the block and the hash value of the previous block. In this way, all blocks form a chain one after another.
  • the cryptographic technology and decentralized ideas on which the blockchain is based make the historical information on the chain unable to be tampered with.
  • the software development kit communicates through the nodes.
  • the serialization and deserialization logic is implemented at the node layer.
  • the SDK provides business data (containing one or more structures) to the nodes for serialization Process and obtain the deserialized business data from the node. If the data format of the sender node and the receiver node are different, the sender node needs to convert the data format to the data format of the receiver node according to the data format of the receiver node before sending, and the sender node needs to store in the blockchain system Configuration information of all receiver nodes to obtain the data format of the receiver node, and complete the data format conversion before sending. In this solution, the sender node has a large amount of stored data, consumes a lot of energy, and has high requirements for node management when the network changes dynamically.
  • the embodiments of the present application provide a data processing method and device based on a blockchain to solve the problem of a large amount of stored data of a sender node and a large amount of work energy consumption.
  • the embodiments of the present application provide a blockchain-based data processing method, which can be executed by a first-party node in the blockchain.
  • the first node may be a sender node in the blockchain, or It can be the receiver node in the blockchain.
  • the first node obtains first service data; the first service data includes a plurality of first structures; the first node converts the first service data to a preset value according to the configuration information of the first node
  • the first byte stream of the data format is sent to the second node; the configuration information includes the version number of the node and the length of the position indication information of the node; the preset data format includes the length of the position indication information and each structure set in sequence
  • the second node converts the first byte stream into second service data according to the configuration information of the second node; the second service data includes a plurality of second structures.
  • the first node converts the first service data into a first byte stream according to the configuration information of the node.
  • the first byte stream includes position indication information and data information.
  • the position indication information is used to indicate the data carried by the structure. The position of the data in the byte stream.
  • the first node can convert the variable-length fields of each structure in the first service data into fixed-length fields, so that the second node can process the first word in the data format Throttling, and can use the index in the position indication information to search for variable length data, so as to realize the deserialization of data.
  • the first node only needs to convert the first business data into the byte stream corresponding to the data format that the second node can process, instead of converting the first business data into the byte stream corresponding to the data format of the second node
  • the first byte stream can be processed by other receiver nodes under preset conditions, and the first node does not need to convert each receiver node into a byte stream corresponding to the data format of the receiver node, which reduces The workload of the first node.
  • the first node does not need to store the configuration information of all receiver nodes in the blockchain system, but only needs to store its own configuration information, and the amount of stored data of the first node is small.
  • the embodiments of the present application also provide a block chain-based data serialization device.
  • the device may be the first node in the first aspect, or a device containing the first node, or a device with a first node.
  • the device includes a module, unit, or means corresponding to the foregoing method, and the module, unit, or means can be implemented by hardware, software, or hardware executing corresponding software.
  • the hardware or software includes one or more modules or units corresponding to the above-mentioned functions.
  • the device includes: an obtaining unit, configured to obtain first service data; the first service data includes a plurality of first structures; and a processing unit, configured to convert the first service data according to the configuration information of the first node
  • the data is converted into a first byte stream with a preset data format and sent to the second node;
  • the configuration information includes the version number of the node and the length of the position indication information of the node;
  • the preset data format includes the length of the position indication information,
  • the position indication information of each structure and the data information used to record the data carried by each structure are sequentially set; the position indication information is used to indicate the position of the data carried by the structure in the byte stream;
  • the preset The data format is used by the second node to convert the first byte stream into second service data according to the configuration information of the second node;
  • the second service data includes a plurality of second structures.
  • an embodiment of the present application also provides a computing device, including: a processor and a memory; the processor is configured to be coupled with the memory, and by calling and executing the memory stored in the memory storing computer programs or instructions, when the When the processor executes the computer program or instruction, the communication device can execute the method of the first aspect.
  • the computing device may be the first node in the foregoing first aspect, or a device including the foregoing first node, or a chip with corresponding functions of the first node, or the like.
  • embodiments of the present application also provide a computer-readable non-volatile storage medium, including computer-readable instructions.
  • the computer reads and executes the computer-readable instructions, the computer executes the block-based The data processing method of the chain.
  • this application provides a computer program product containing instructions, which when run on a computer, enables the computer to execute the method of the first aspect.
  • the technical effects brought by any one of the possible implementation manners of the foregoing second aspect to the fifth aspect may refer to the technical effects brought about by the different implementation manners of the foregoing first aspect, and details are not described herein again.
  • FIG. 1 is a schematic diagram of a system architecture provided by an embodiment of the application
  • FIG. 2 is a schematic diagram of another system architecture provided by an embodiment of the application.
  • Figure 3(a) is a schematic diagram of the first service data format provided by an embodiment of this application.
  • Figure 3(b) is a schematic diagram of the byte stream Data1 provided by an embodiment of this application.
  • Figure 3(c) is a schematic diagram of the byte stream Data2 provided by an embodiment of this application.
  • Figure 4(a) is a schematic diagram of a second service data format provided by an embodiment of this application.
  • Figure 4(b) is a schematic diagram of the byte stream Data3 provided by an embodiment of this application.
  • Figure 4(c) is a schematic diagram of the byte stream Data4 provided by an embodiment of this application.
  • Figure 4(d) is a schematic diagram of the byte stream Data5 provided by an embodiment of this application.
  • FIG. 5 is a schematic flowchart of a data processing method provided by an embodiment of this application.
  • FIG. 6 is a schematic flowchart of another data processing method provided by an embodiment of the application.
  • FIG. 7 is a schematic diagram of position indication information of a supplementary structure provided by an embodiment of this application.
  • FIG. 8 is a schematic diagram of position indication information for deleting a structure provided by an embodiment of this application.
  • FIG. 9(a) is a schematic diagram of the byte stream Data6 provided by an embodiment of this application.
  • Figure 9(b) is a schematic diagram of the byte stream Data7 provided by an embodiment of this application.
  • FIG. 9(c) is a schematic diagram of the position indication information of another deletion structure provided by an embodiment of this application.
  • FIG. 10 is a schematic flowchart of a data serialization method provided by an embodiment of this application.
  • FIG. 11 is a schematic flowchart of a data deserialization method provided by an embodiment of this application.
  • FIG. 12 is a schematic structural diagram of a data processing device provided by an embodiment of this application.
  • FIG. 13 is a schematic structural diagram of a computing device provided by an embodiment of this application.
  • FIG. 1 exemplarily shows the system architecture applicable to the blockchain-based data processing method provided by the embodiment of the present application.
  • the system architecture may be a blockchain system.
  • the blockchain system includes multiple nodes, each The nodes include P2P (Peer to Peer, peer-to-peer network) modules, data processing modules, and data storage modules.
  • the P2P module is used for communication between nodes, which can be point-to-point directional transmission or broadcast.
  • the data processing module is used to serialize or deserialize data, where serialization refers to the process of converting business data into byte stream sequences, and deserialization refers to converting byte stream sequences into business data the process of.
  • the data storage module is used to store node configuration information, such as the version number.
  • the version number can include the node version number, data version number, etc.
  • the node version number corresponds to the data version number, and the version number is used to uniquely determine the data format.
  • the version number is the identification number of the version of the system, software, and data, enabling users to know whether the system, software, and data used are the latest version and the functions it provides.
  • the formatted description of the version number is the main version number, minor version number [. revised version number [. compiled version number]], which consists of two to four parts: major version number, minor version number, revised version number, and compiled version number .
  • the major version number and the minor version number are required, and the revised version number and the compiled version number are optional, but if the compiled version number part is defined, the revised version number is required. All defined parts must be integers greater than or equal to 0.
  • the version number management strategy is as follows:
  • the first version of the project is 1.0 or 1.0.0;
  • the compilation version number is generally automatically generated by the compiler during the compilation process. We only define its format and do not control it manually.
  • the node in the blockchain system receives the business data generated by the server SDK outside the blockchain system, serializes the business data into a byte stream through the data processing module of the node, and then sends the byte stream to the P2P module for use between nodes transmission.
  • the SDK can be a software development tool for servers outside the blockchain system, or a software development tool for nodes in the blockchain system.
  • the sender node is defined as the first node, and the SDK connected to the sender node is the first SDK.
  • the sender node includes a first P2P module, a first data processing module and a first data storage module; correspondingly, the receiver node is defined as the second node, the SDK connected to the receiver node is the second SDK, and the receiver node It includes a second P2P module, a second data processing module and a second data storage module.
  • the first SDK generates the first service data and sends it to the first data processing module.
  • the first data processing module serializes the first service data to generate a byte stream.
  • the first P2P module sends the byte stream to the second P2P Module, the second data processing module deserializes the byte stream into second service data and sends it to the second SDK.
  • the sender node When data is transmitted between nodes in the blockchain system, if the data format of the sender node is the same as the data format of the receiver node, the sender node converts the business data into the byte stream corresponding to the data format of the sender node. Directly processed by the receiver node; if the data format of the sender node is different from the data format of the receiver node, the sender node needs to convert the business data into the byte stream corresponding to the data format of the receiver node or into the receiver node The byte stream corresponding to the processable data format.
  • the byte stream corresponding to the data format of the node may include data length, single structure length, fixed-length bytes, variable-length bytes, and so on.
  • the node version number of the node is N1.3 and the data version number is D1.1
  • the service data received by the node may be as shown in Figure 3(a), and the service data includes three structures; data
  • the byte stream Data1 corresponding to the format is shown in Figure 3(b), and the byte stream Data1 includes the information shown in Table 1.
  • the node version number of the node is N1.8 and the data version number is D1.2
  • the service data received by the node may be as shown in Figure 4(a), and the service data includes 3 structures; data
  • the byte stream Data3 corresponding to the format is shown in Figure 4(b), and the byte stream Data3 includes the information shown in Table 2.
  • the byte length occupied by “data length” is 4 bytes
  • the byte length occupied by “single structure length” is 4 bytes
  • the length of "fixed length” is 4 bytes.
  • the byte length occupied by “data x” is 1 byte
  • the byte length occupied by “fixed-length data y” is 1 byte
  • the byte length occupied by “variable-length data z” is 7 bytes,...
  • the byte length occupied by all parameters in the byte stream can be set based on experience, and is not limited to the byte length in the table. This description also applies to the byte length occupied by the "version number” and the byte length occupied by the "number of position indication information" in the following table.
  • the data version number D1.1 is lower than the data version number D1.2, that is to say, the data format shown in FIG. 3(a) is relatively higher than the data format shown in FIG. 4(a) The data format of the lower version.
  • the data version number of the first node is D1.1 and the data version number of the second node is D1.2
  • the first node needs to The business data is converted into a byte stream corresponding to the D1.2 data format or into a byte stream corresponding to a data format that can be processed by the second node.
  • the first node needs to convert the business data It is the byte stream corresponding to the D1.1 data format or converted into the byte stream corresponding to the data format that can be processed by the second node.
  • Fig. 5 is a blockchain-based data processing flow provided by an embodiment of the application.
  • the data processing flow details an implementation manner in which a first node sends a first byte stream to a second node.
  • Step 501 The first node obtains first service data.
  • the first service data is the first service data sent by the first SDK to the first node, and the first service data may include multiple first structures. Exemplarily, the first service data may be as shown in Fig. 3(a) or Fig. 4(a).
  • Step 502 The first node converts the first service data into a first byte stream having a preset data format according to the configuration information of the first node.
  • Step 503 The first node sends the first byte stream to the second node.
  • Step 504 The second node converts the first byte stream into second service data according to the configuration information of the second node.
  • the second node converts the first byte stream into second service data according to the version number of the second node and the length of the location indication information, and the second service data includes a plurality of second structures.
  • each node locally stores the configuration information of the node, and the configuration information includes the version number of the node and the length of the position indication information of the node.
  • the version number may include the node version number and the data version number, or only the data version number, as long as the version number can uniquely determine the data format of the node.
  • the first node converts the first service data into a first byte stream having a preset data format according to the configuration information of the first node.
  • the preset data format may include the length of the position indication information, the position indication information of each structure set in sequence, and the data information used to record the data carried by each structure.
  • the position indication information is used to indicate the structure carried The position of the data in the byte stream.
  • the preset data format is used by the second node to convert the first byte stream into second service data according to the configuration information of the second node.
  • the preset data format may also include the version number and the number of position indication information.
  • the version number is used by the receiving node to determine whether to process the byte stream according to the version number in the byte stream after receiving the byte stream.
  • the specific implementation process is described in the following embodiments.
  • the number of position indication information is used to indicate the number of position indication information contained in the byte stream, as shown in Figure 4(c) in the byte stream Data4, the number of position indication information is 3. After receiving the byte stream Data4, you can read that the byte stream Data4 includes 3 position indication information. After the receiver node reads the third position indication information, the position in the byte stream Data4 can be determined The instruction information has been read.
  • the position indication information of each structure can include the position of the variable-length data of each structure in the data information and the fixed-length data, which can be explained in conjunction with the byte stream Data4 shown in Figure 4(c); the position indication of each structure
  • the information may also include the position of the fixed-length data of each structure in the data information and the position of the variable-length data in the data information, which can be explained in conjunction with the byte stream Data5 shown in FIG. 4(d).
  • the first position indication information corresponds to the first structure in the first service data
  • the position indication information includes the fixed-length data x in the first structure.
  • variable-length data z start from the 0th byte of the character string in the data message, and read the 7 bytes of the character string in the data message.
  • the byte stream Data4 includes the information shown in Table 3.
  • the first position indication information corresponds to the first structure in the first service data
  • the position indication information includes the fixed-length data in the first structure in the data
  • the variable-length data in each structure can be placed in the data information in the order of each structure, and the The position of the variable length data in each structure in the data information is recorded in the position indication information of each structure.
  • the position indication information of each structure includes the variable length data of each structure in the data information. Position and fixed length data of each structure.
  • each structure has only fixed-length data, so when generating the first byte stream, there is no need to generate data information, and there is no need to include the position indication information. Record the position of the variable-length byte in the data message.
  • the generated first byte stream Data2 can be as shown in Figure 3(c).
  • the position indication information when used to describe the position of the variable-length data in the data information of each structure and the fixed-length data, the starting position of the variable-length data and the length of the variable-length data can be set, so that the The variable-length data is located in the data information.
  • the start position of the variable-length data and the end position of the variable-length data can be set, and the variable-length data in each structure can be located in the data information, or in other ways, use For locating the position of variable-length data in each structure in the data information, there is no restriction here.
  • the position indication information is used to describe the position of the variable-length data of each structure in the data information and the position of the fixed-length data in the data information, the above method is also applicable.
  • the first node converts the first service data into a first byte stream having a preset data format according to the configuration information of the first node, and the first byte stream includes position indication information And data information, the position indication information includes the position of the variable-length data of each structure in the data information and the fixed-length data of each structure or the position of the variable-length data of each structure in the data information and the position of each structure The position of the fixed-length data in the data information.
  • the first node can convert the variable-length fields of each structure in the first business data into fixed-length fields, so that the second node can process the first data format.
  • the first node only needs to convert the first business data into the byte stream corresponding to the data format that the second node can process, instead of converting the first business data into the byte stream corresponding to the data format of the second node .
  • the first node can generate the byte stream in the same data format for different receiver nodes, and use it for different receiver nodes to read the first byte stream.
  • the first node does not need to target each receiver node. Converting to the byte stream corresponding to the data format of the receiver node reduces the workload of the first node.
  • the first node does not need to store the configuration information of all receiver nodes in the blockchain system, but only needs to store its own configuration information, and the amount of stored data of the first node is small.
  • the first node is equivalent to the sender node of the byte stream
  • the second node is equivalent to the receiver node of the byte stream
  • the second node is after receiving the first byte stream
  • the implementation manner of converting the first byte stream into the second service data is similar to the implementation manner when the first node is the receiver node, and the following embodiments can be referred to.
  • the first node When the first node is the receiver node, it can receive the second byte stream sent by the third node, and convert the second byte stream into fourth service data according to the configuration information of the first node.
  • the version logic of the first node when the version number of the first node is lower than the version number of the third node, the version logic of the first node supports the data generated by the version of the third node, which is equivalent to that the first node can achieve forward compatibility;
  • the version logic of the first node When the version number of the node is higher than the version number of the third node, the version logic of the first node supports the data generated by the version of the third node, which is equivalent to that the first node can achieve backward compatibility.
  • Step 601 The first node obtains the second byte stream.
  • the second byte stream is that the third node converts the third service data into a byte stream having a preset data format according to the configuration information of the third node, and the third service data includes a plurality of third structures.
  • the implementation manner in which the third node converts the third service data into the second byte stream according to the configuration information of the third node is similar to the implementation manner in which the first node serves as the sender node, and will not be repeated here.
  • Step 602 The first node determines the fixed-length data of each structure and the variable-length data of each structure.
  • the first node determines the fixed-length data of each structure and the change of each structure according to the length of the position indication information of the first node, the length of the position indication information of the third node, and the position indication information of each structure in the second byte stream.
  • Long data that is, determine the fixed-length data of each structure and the variable-length data of each structure in the transformed business data.
  • Step 603 The first node determines the fourth service data including at least one first structure according to the fixed-length data of each structure and the variable-length data of each structure.
  • the fixed-length data and variable-length data of each structure are determined, and the structure is formed.
  • This structure is the first structure determined by the first node according to the configuration information of the node, and At least one first structure is formed into fourth service data.
  • step 602 it can be defined that the length of the position indication information of the first node is M bytes, the length of the position indication information of the third node is N bytes, and M and N are positive integers.
  • the first node combines the sizes of M and N to process the received second byte stream in different ways, as follows.
  • the first node determines that M is greater than N, it adds M-N bytes assigned to zero after the position indication information of each structure in the second byte stream, and according to the position indication information of each structure after supplementation, Extract the fixed length data of each structure from the position indication information of each structure and extract the variable length data of each structure from the data information.
  • the first node determines that M is less than N, it discards the NM bytes after the position indication information of each structure in the second byte stream, and according to the position indication information of each structure after discarding, from the position of each structure Extract the fixed-length data of each structure from the instruction information and extract the variable-length data of each structure from the data information.
  • the first node determines that M is equal to N, it means that the data format corresponding to the second byte stream received by the first node is the data format of the first node, that is, the version number of the first node and The version numbers of the third node are the same, and the first node can directly deserialize the second byte stream, so it is not repeated here.
  • the format is shown in Figure 3(a).
  • the byte stream Data2 received by the first node is shown in Figure 3(c). After the first node reads the length of the position indication information in the byte stream Data2 as 2, and determines that M is greater than N, then it is in the byte stream Data2
  • the position indication information of each structure is supplemented with M-N bytes assigned to zero, that is, 8 bytes assigned to zero are added after the fixed-length data x and fixed-length data y of the first structure.
  • the position indication information of the first structure can be shown in Figure 7. According to the position indication information of the first structure after supplement, it is determined that the fixed-length data of the first structure is fixed-length data x and fixed-length The data y is assigned to 2 and 5 respectively, and the variable-length data length is 0.
  • the byte stream Data4 received by the first node is shown in Figure 4(c).
  • the first node After the first node reads the length of the position indication information in the byte stream Data4 to be 10, and determines that M is less than N, it discards the byte stream Data4
  • the NM bytes after the position indication information of each structure that is, the last 8 bytes of the 10 bytes in the position indication information of the first structure are deleted, and the position indication information of the first structure after deletion can be As shown in Figure 8, according to the position indication information of the discarded first structure, it is determined that the fixed-length data of the first structure is fixed-length data x and fixed-length data y, and the assignments are 2 and 5, respectively.
  • the long data length is 0.
  • the purpose of adding M-N bytes assigned to zero after the position indication information of each structure in the second byte stream is to reduce the number of bytes processed by the first node
  • the first node receives the second byte stream, it does not use the position indication information to supplement M -N number of bytes assigned as zero, but directly processing the received second byte stream, there will be the following situations:
  • the first node receives the second byte stream sent by the third node.
  • the length of the position indication information in the second byte stream is 2.
  • After the first node reads the length of the position indication information in the second byte stream, it will A function for processing the position indication information of length 2 is generated, which is assumed to be F (N 2).
  • the length of the position indication information in the second byte stream is 4.
  • the first node directly reads the second byte stream, it needs to generate functions for position indication information of different lengths, so as to be suitable for processing different position indication information.
  • the first node adds M-N bytes assigned to zero after the position indication information of each structure in the second byte stream, it can only process position indications with a length of 10. information.
  • the first node may add M-N bytes assigned to zero after the position indication information of each structure, so that the length of the position indication information of each structure is M, or The position indication information of each structure is supplemented with other bytes to achieve the same purpose.
  • the position indication information of each structure after supplementation or the position indication information of each structure after discarding may record the position information of variable length data. Take Figure 9(a) and Figure 9(b) as examples.
  • the version number of the sender node is V2.2, and the sender node generates the format of the byte stream Data6 as shown in Figure 9(a) according to the configuration information in the node.
  • the byte stream Data6 includes 2 position indication information, position indication The length of the information is 18, and the position indication information includes fixed-length data x, fixed-length data y, the starting position and length of the first variable-length data z 1 and the starting position and length of the second variable-length data z 2 .
  • the byte stream Data6 includes the information shown in Table 5.
  • the version number of the receiver node is V2.1.
  • the receiver node generates the format of the byte stream Data7 as shown in Figure 9(b) according to the configuration information in the node.
  • the byte stream Data7 includes 2 position indication information, position The length of the indication information is 10, and the position indication information includes the starting position and length of fixed-length data x, fixed-length data y, and variable-length data z.
  • the byte stream Data7 includes the information shown in Table 6.
  • the variable length data z can be obtained from the data information according to the starting position 0 of the variable length data z in the data information and the length 7 of the variable length data z in the position indication information.
  • the purpose of adding M-N bytes assigned to zero after the position indication information of each structure in the second byte stream is to reduce the processing byte stream of the first node
  • the workload is interpreted as: when the first node receives the second byte stream sent by multiple sender nodes, if the position indication information length of each structure in the second byte stream sent by multiple sender nodes is different, Then the first node can use the method of supplementing the bytes assigned as zero to supplement the byte length of the position indication information of each structure in each second byte stream to M, so that the first node only needs to process the position of length M Indication information, that is, only one function for processing position indication information of length M needs to be generated.
  • the NM bytes after the position indication information of each structure in the second byte stream are discarded, so that the length of the position indication information of each structure in the second byte stream is the same as the configuration of the first node
  • the position in the information indicates that the length of the information is equal, so that the first node can process the second byte stream.
  • the length of the position indication information in the second byte stream is greater than the length of the position indication information in the configuration information of the first node, which means that the version number of the third node is higher than the version number of the first node, and the second The NM bytes after the position indication information of each structure in the byte stream are discarded, which only deletes the version logic higher than the first node, and does not affect the version logic of the first node itself.
  • the position indication information of each structure records the fixed length data of each structure and the variable length data of each structure in the data information.
  • the position index can extract the fixed-length data and variable-length data of each structure in parallel according to the position indication information of each structure, which improves the efficiency of data deserialization.
  • the first node can first extract the version number of the third node from the second byte stream, and determine whether to perform the second byte stream according to the version number of the third node. deal with. Optionally, it can be judged whether the major version number in the version number of the first node is consistent with the major version number in the version number of the third node. If so, it is determined to process the second byte stream; otherwise, it is determined not to Two byte stream is processed.
  • the version number of the first node is V1.2 (the main version number of the version number of the first node is V1), if the version number of the third node extracted by the first node is V1.1 (the version of the third node The major version number of the number is V1), that is, it is determined that the major version number in the version number of the first node is consistent with the major version number in the version number of the third node, and the second byte stream is determined to be processed.
  • the major version number of the version number of the third node is V2.1 (the major version number of the version number of the third node is V2)
  • the major version number and the third node in the version number of the first node are determined
  • the major version number in the version number is inconsistent, so determine not to process the second byte stream.
  • the first node determines whether the major version number of the sender node is consistent with the major version number of its own node, thereby judging whether the first node supports the second byte stream. For processing, the byte stream sent by the node that is inconsistent with the main version number of the own node can be filtered out in advance, thereby improving the efficiency of the first node for processing the byte stream.
  • Step 1001 Open up storage space A.
  • Step 1002 Write the version number in the node configuration information in A.
  • Step 1003 Write the number of position indication information and the length of a single position indication information in sequence in A.
  • Step 1004 Traverse the business data to obtain the same structure defined in the business data.
  • Step 1005 It is judged whether the structure has variable length data, if not, go to step 1006, if yes, go to step 1007.
  • step 1006 the fixed-length data is written into A according to the occupancy of the field type.
  • Step 1007 It is judged whether there is a buffer zone B, if not, go to step 1008, if yes, go to step 1009.
  • Step 1008 open up storage space B.
  • Step 1009 Write the fixed-length data into A according to the occupancy of the field type, and write the two fields of the current size of B and the variable-length data length into A in sequence.
  • Step 1010 write variable length data into B.
  • Step 1011 After processing the business data, write the data of B at the end of A.
  • the serialization operation is completed, and the generated byte stream can be sent by the P2P module.
  • Step 1101 Determine the version number.
  • Step 1102 it is judged whether the main version numbers are consistent, if yes, go to step 1103, otherwise, end.
  • Step 1103 Determine the number n of position indication information and the length N of position indication information in the byte stream.
  • Step 1104 Determine the length M of the position indication information in the configuration information.
  • Step 1105 Determine whether M is greater than N, if yes, go to step 1106, if not, go to step 1107.
  • Step 1106 Add 0 to the position indication information of each structure in the byte stream until the length of the single position indication information is M.
  • Step 1107 Read the first M bytes in the position indication information of each structure in the byte stream.
  • Step 1108 it is judged whether there is variable length data, if yes, go to step 1109, otherwise, go to step 1110.
  • Step 1109 According to the starting position and length of the variable-length data in the read data, find the corresponding character string in the data information and replace it.
  • Step 1110 The n pieces of position indication information are processed.
  • the first node converts the first service data into a first byte stream according to the configuration information of the node.
  • the first byte stream includes position indication information and data information, and the position indication information includes the information of each structure.
  • the position of the variable-length data in the data information and the fixed-length data of each structure, or the position of the variable-length data of each structure in the data information and the position of the fixed-length data of each structure in the data information through this method ,
  • the first node can convert the variable-length fields of each structure in the first service data into fixed-length fields, so that the second node can process the first byte stream of the data format, and can use the index in the position indication information Search for variable-length data to achieve data deserialization.
  • the first node only needs to convert the first business data into the byte stream corresponding to the data format that the second node can process, instead of converting the first business data into the byte stream corresponding to the data format of the second node
  • the first byte stream can be processed by other receiver nodes under preset conditions, and the first node does not need to convert each receiver node into a byte stream corresponding to the data format of the receiver node, which reduces The workload of the first node.
  • the first node does not need to store the configuration information of all receiver nodes in the blockchain system, but only needs to store its own configuration information, and the amount of stored data of the first node is small.
  • the first node determines whether the main version number of the sender node is consistent with the main version number of its own node, thereby determining whether the first node performs the second byte stream For processing, the byte stream sent by the node that is inconsistent with the main version number of the own node can be filtered in advance, thereby improving the efficiency of the first node in processing the byte stream.
  • FIG. 12 exemplarily shows the structure of a block chain-based data processing device provided by an embodiment of the present application, and the device can execute the flow of the block chain-based data processing method.
  • the device can exist in the form of software or hardware.
  • the apparatus may include: a processing unit 1202 and an obtaining unit 1201.
  • the acquiring unit 1201 may include a receiving unit, and the apparatus may also include a sending unit.
  • the processing unit 1202 is used to control and manage the actions of the device.
  • the acquiring unit 1201 and the sending unit are used to support communication between the device and other network entities.
  • the processing unit 1202 may be a processor or a control device, for example, a general-purpose central processing unit (CPU), a general-purpose processor, a digital signal processing (digital signal processing, DSP), and an application specific integrated circuit (application specific integrated circuit). circuits, ASIC), field programmable gate array (FPGA) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It can implement or execute various exemplary logical blocks, modules and circuits described in conjunction with the disclosure of this application.
  • the processor may also be a combination that implements computing functions, for example, including a combination of one or more microprocessors, a combination of DSP and microprocessor, and so on.
  • the acquiring unit 1201 is an interface circuit of the device, and is used to receive signals from other devices.
  • the acquisition unit 1201 is an interface circuit for the chip to receive signals from other chips or devices
  • the sending unit is an interface circuit for the chip to send signals to other chips or devices.
  • the device may be the first node in the foregoing embodiment, or may be a chip used for the first node.
  • the processing unit 1202 may be a processor, and the acquiring unit 1201 may be a transceiver, for example.
  • the transceiver may include a radio frequency circuit, and the storage unit may be, for example, a memory.
  • the processing unit 1202 may be, for example, a processor, and the acquiring unit 1201 or the sending unit may be, for example, an input/output interface, a pin, or a circuit.
  • the processing unit 1202 can execute computer-executable instructions stored in the storage unit.
  • the storage unit is a storage unit in the chip, such as a register, a cache, etc., and the storage unit may also be located in the chip in the first forwarding server.
  • External storage units such as read-only memory (ROM) or other types of static storage devices that can store static information and instructions, random access memory (RAM), etc.
  • the device is the first node in the foregoing embodiment.
  • the obtaining unit 1201 is configured to obtain first service data; the first service data includes multiple first structures;
  • the processing unit 1202 is configured to convert the first service data into a first byte stream with a preset data format according to the configuration information of the first node and send it to the second node;
  • the configuration information includes the version number of the node And the length of the position indication information of the node;
  • the preset data format includes the length of the position indication information, the position indication information of each structure set in sequence, and the data information used to record the data carried by each structure; the position indication information Used to indicate the position of the data carried by the structure in the byte stream;
  • the preset data format is used by the second node to convert the first byte stream into the second node according to the configuration information of the second node Business data;
  • the second business data includes multiple second structures.
  • the position indication information of each structure includes the position of the variable-length data of each structure in the data information and the fixed-length data of each structure; the data information includes the sequence setting The variable length data of each structure.
  • the processing unit 1202 is further configured to: control the acquiring unit 1201 to acquire a second byte stream; the second byte stream is the third node's configuration information of the third node
  • the data is converted into a byte stream having the preset data format;
  • the third service data includes a plurality of third structures; according to the length of the position indication information of the first node and the position indication information of the third node
  • the length and the position indication information of each structure in the second byte stream determine the fixed-length data of each structure and the variable-length data of each structure; according to the fixed-length data of each structure and each structure
  • the variable-length data is determined to include at least one fourth service data of the first structure.
  • the length of the position indication information of the first node is M bytes
  • the length of the position indication information of the third node is N bytes
  • M and N are positive integers
  • the processing unit 1202 specifically uses Yu: If it is determined that M is greater than N, then add M-N bytes assigned to zero after the position indication information of each structure in the second byte stream; according to the position indication information of each structure after the supplement, The fixed-length data of each structure is extracted from the position indication information of each structure, and the variable-length data of each structure is extracted from the data information.
  • the processing unit 1202 is further configured to: if it is determined that M is less than N, discard NM bytes after the position indication information of each structure in the second byte stream; according to the discarded structure
  • the position indication information of each structure is extracted from the position indication information of each structure, and the fixed length data of each structure is extracted from the data information.
  • the preset data format further includes a version number; the processing unit 1202 is further configured to:
  • the version number of the third node Before determining the fixed-length data of each structure and the variable-length data of each structure, extract the version number of the third node from the second byte stream; determine the version number of the first node Whether the major version number of the third node is consistent with the major version number in the version number of the third node, if so, it is determined to process the second byte stream.
  • an embodiment of the present application further provides a computing device, and the computing device 1300 may be the operating diagnostic device in the foregoing embodiment.
  • the computing device 1300 includes a processor 1302 and a communication interface 1303.
  • the computing device 1300 may further include a memory 1301.
  • the computing device 1300 may further include a communication line 1304.
  • the communication interface 1303, the processor 1302, and the memory 1301 may be connected to each other through a communication line 1304;
  • the communication line 1304 may be a peripheral component interconnection standard (peripheral component interconnect, PCI for short) bus or an extended industry standard architecture (extended industry standard architecture) , Referred to as EISA) bus and so on.
  • the communication line 1304 can be divided into an address bus, a data bus, a control bus, and so on. For ease of presentation, only one thick line is used in FIG. 13, but it does not mean that there is only one bus or one type of bus.
  • the processor 1302 may be a CPU, a microprocessor, an ASIC, or one or more integrated circuits used to control the execution of the program of the present application.
  • the processor 1302 may be configured to: according to the configuration information of the first node, convert the first service data into a first byte stream with a preset data format and send it through the communication interface 1303
  • the first service data includes multiple first structures
  • the configuration information includes the version number of the node and the length of the position indication information of the node
  • the preset data format includes the length of the position indication information and the information of each structure set in sequence Position indication information and data information used to record the data carried by each structure
  • position indication information is used to indicate the position of the data carried by the structure in the byte stream
  • the preset data format is used by the second node to transfer the first byte
  • the stream is transformed into second service data according to the configuration information of the second node; the second service data includes multiple second structures.
  • Communication interface 1303 using any device such as a transceiver to communicate with other equipment or communication networks, such as Ethernet, radio access network (RAN), wireless local area networks (WLAN), Wired access network, etc.
  • RAN radio access network
  • WLAN wireless local area networks
  • Wired access network etc.
  • the communication interface 1303, is used to obtain the first service data.
  • the memory 1301 can be ROM or other types of static storage devices that can store static information and instructions, RAM or other types of dynamic storage devices that can store information and instructions, or it can be an electrically erasable programmable read-only memory (electrically erasable programmable read-only memory).
  • read-only memory EEPROM
  • compact disc read-only memory, CD-ROM
  • optical disc storage including compact discs, laser discs, optical discs, digital universal discs, Blu-ray discs, etc.
  • magnetic disks A storage medium or other magnetic storage device, or any other medium that can be used to carry or store desired program codes in the form of instructions or data structures and that can be accessed by a computer, but is not limited thereto.
  • the memory can exist independently and is connected to the processor through a communication line 1304. The memory can also be integrated with the processor.
  • the memory 1301 is used to store computer-executable instructions for executing the solution of the present application, and the processor 1302 controls the execution.
  • the processor 1302 is configured to execute computer-executable instructions stored in the memory 1301, so as to implement the method provided in the foregoing embodiment of the present application.
  • the computer-executable instructions in the embodiments of the present application may also be referred to as application program code, which is not specifically limited in the embodiments of the present application.
  • the embodiments of the present application also provide a computer-readable non-volatile storage medium, including computer-readable instructions.
  • the computer reads and executes the computer-readable instructions, the computer executes the block-based The data processing method of the chain.
  • These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing equipment to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction device.
  • the device implements the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
  • These computer program instructions can also be loaded on a computer or other programmable data processing equipment, so that a series of operation steps are executed on the computer or other programmable equipment to produce computer-implemented processing, so as to execute on the computer or other programmable equipment.
  • the instructions provide steps for implementing functions specified in a flow or multiple flows in the flowchart and/or a block or multiple blocks in the block diagram.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本申请公开了一种基于区块链的数据处理方法及装置,其中,方法包括:第一节点获取第一业务数据,根据第一节点的配置信息,将第一业务数据转换为具有预设数据格式的第一字节流并发送给第二节点,第二节点将第一字节流根据第二节点的配置信息转化为第二业务数据,其中,预设数据格式包括位置指示信息长度、依序设置的各结构体的位置指示信息及用于记录各结构体承载的数据的数据信息,位置指示信息用于指示结构体承载的数据在字节流中的位置。本技术方案用以解决发送方节点的存储数据量大,工作耗能多的问题。

Description

一种基于区块链的数据处理方法及装置
相关申请的交叉引用
本申请要求在2019年05月08日提交中国专利局、申请号为201910379418.0、申请名称为“一种基于区块链的数据处理方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请实施例涉及金融科技(Fintech)领域,尤其涉及一种基于区块链(BlockChain)的数据处理方法及装置。
背景技术
区块链是由一系列区块组成的一条链,每个区块记录本块的数据及上一块的哈希值,所有区块通过这种方式前后相继组成一条链。区块链所基于的密码学技术和去中心化思想使链上的历史信息无法被篡改。
随着计算机技术的发展,越来越多的技术应用在金融领域,传统金融业正在逐步向金融科技转变,区块链传输技术也不例外,但由于金融、支付行业的安全性、实时性要求,也对技术提出的更高的要求。
软件开发工具包(software development kit,SDK)通过节点进行通信,此场景中序列化和反序列化逻辑在节点层实现,SDK提供业务数据(内含一个或多个结构体)给节点进行序列化处理,并从节点获取反序列化之后的业务数据。若发送方节点和接收方节点的数据格式不同,发送方节点需要根据接收方节点的数据格式,将数据格式转换为接收方节点的数据格式后进行发送,发送方节点需要存储区块链系统中所有接收方节点的配置信息,以获取接收方节点的数据格式,并在发送前完成数据格式的转换。此方案中,发送方节点的存储数据量大,工作耗能多,且在网络动态变化时,对节点的管理要求高。
发明内容
本申请实施例提供一种基于区块链的数据处理方法及装置,用以解决发送方节点的存储数据量大,工作耗能多的问题。
第一方面,本申请实施例提供一种基于区块链的数据处理方法,该方法可以通过区块链中的第一方节点执行,第一节点可以为区块链中的发送方节点,也可以为区块链中的接收方节点。第一节点获取第一业务数据;所述第一业务数据包括多个第一结构体;所述第一节点根据所述第一节点的配置信息,将所述第一业务数据转换为具有预设数据格式的第一字节流并发送给第二节点;所述配置信息包括节点的版本号和节点的位置指示信息长度;所述预设数据格式包括位置指示信息长度、依序设置的各结构体的位置指示信息及用于记录各结构体承载的数据的数据信息;所述位置指示信息用于指示结构体承载的数据在字节流中的位置;所述预设数据格式用于所述第二节点将所述第一字节流根据所述第二节点的配置信息转化为第二业务数据;所述第二业务数据包括多个第二结构体。
上述技术方案中,第一节点根据节点的配置信息将第一业务数据转化为第一字节流,第一字节流中包括位置指示信息和数据信息,位置指示信息用于指示结构体承载的数据在 字节流中的位置,通过该方式,第一节点可以将第一业务数据中各结构体的变长字段转化为定长字段,以使得第二节点可以处理该数据格式的第一字节流,且可以使用位置指示信息中的索引对变长数据进行查找,从而实现数据的反序列化。也就是说,第一节点只需要将第一业务数据转化为第二节点可处理的数据格式对应的字节流,而无需将第一业务数据转化为第二节点的数据格式对应的字节流,进一步的,该第一字节流可以被预设条件下的其他接收方节点处理,第一节点无需针对每个接收方节点转化为该接收方节点的数据格式对应的字节流,减少了第一节点的工作量。且第一节点中不需要存储区块链系统中所有接收方节点的配置信息,只需要存储自身的配置信息即可,第一节点的存储数据量小。
第二方面,本申请实施例还提供了一种基于区块链的数据序列化装置,该装置可以为上述第一方面中的第一节点,或者包含上述第一节点的装置,或者为具有第一节点的相应功能的芯片等。该装置包括实现上述方法相应的模块、单元、或手段(means),该模块、单元、或means可以通过硬件实现,软件实现,或者通过硬件执行相应的软件实现。该硬件或软件包括一个或多个与上述功能相对应的模块或单元。其中,该装置包括:获取单元,用于获取第一业务数据;所述第一业务数据包括多个第一结构体;处理单元,用于根据第一节点的配置信息,将所述第一业务数据转换为具有预设数据格式的第一字节流并发送给第二节点;所述配置信息包括节点的版本号和节点的位置指示信息长度;所述预设数据格式包括位置指示信息长度、依序设置的各结构体的位置指示信息及用于记录各结构体承载的数据的数据信息;所述位置指示信息用于指示结构体承载的数据在字节流中的位置;所述预设数据格式用于所述第二节点将所述第一字节流根据所述第二节点的配置信息转化为第二业务数据;所述第二业务数据包括多个第二结构体。
第三方面,本申请实施例还提供了一种计算设备,包括:处理器和存储器;处理器,用于与存储器耦合,通过调用并执行存储器中存储的存储器存储有计算机程序或指令,当该处理器执行该计算机程序或指令时,以使该通信装置可以执行上述第一方面的方法。该计算设备可以为上述第一方面中的第一节点,或者包含上述第一节点的装置,或者为具有第一节点的相应功能的芯片等。
第四方面,本申请实施例还提供了一种计算机可读非易失性存储介质,包括计算机可读指令,当计算机读取并执行所述计算机可读指令时,使得计算机执行上述基于区块链的数据处理方法。
第五方面,本申请提供了一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机可以执行上述第一方面的方法。
其中,上述第二方面至第五方面中任一种可能的实现方式所带来的技术效果可参见上述第一方面中不同的实现方式所带来的技术效果,此处不再赘述。
附图说明
图1为本申请实施例提供的一种系统架构的示意图;
图2为本申请实施例提供的另一种系统架构的示意图;
图3(a)为本申请实施例提供的第一种业务数据格式的示意图;
图3(b)为本申请实施例提供的字节流Data1的示意图;
图3(c)为本申请实施例提供的字节流Data2的示意图;
图4(a)为本申请实施例提供的第二种业务数据格式的示意图;
图4(b)为本申请实施例提供的字节流Data3的示意图;
图4(c)为本申请实施例提供的字节流Data4的示意图;
图4(d)为本申请实施例提供的字节流Data5的示意图;
图5为本申请实施例提供的一种数据处理方法的流程示意图;
图6为本申请实施例提供的另一种数据处理方法的流程示意图;
图7为本申请实施例提供的一种补充结构体的位置指示信息示意图;
图8为本申请实施例提供的一种删除结构体的位置指示信息示意图;
图9(a)为本申请实施例提供的字节流Data6的示意图;
图9(b)为本申请实施例提供的字节流Data7的示意图;
图9(c)为本申请实施例提供的另一种删除结构体的位置指示信息示意图;
图10为本申请实施例提供的一种数据序列化方法的流程示意图;
图11为本申请实施例提供的一种的数据反序列化方法的流程示意图;
图12为本申请实施例提供的一种数据处理装置的结构示意图;
图13为本申请实施例提供的一种计算设备的结构示意图。
具体实施方式
图1示例性的示出了本申请实施例提供基于区块链的数据处理方法所适用的系统架构,该系统架构可以为区块链系统,该区块链系统中包括多个节点,每个节点中包括P2P(Peer to Peer,对等网络)模块、数据处理模块、数据存储模块。P2P模块用于节点间通信,可以为点对点定向传输,也可以是广播方式。数据处理模块用于对数据进行序列化或反序列化操作,其中,序列化指的是把业务数据转换为字节流序列的过程,反序列化指的是把字节流序列转换为业务数据的过程。数据存储模块用于存储节点配置信息,如版本号,版本号可以包括节点版本号、数据版本号等,节点版本号对应数据版本号,版本号用于唯一确定数据格式。
对版本号解释如下:
版本号是系统、软件、数据的版本的标识号,能使用户了解所使用的系统、软件、数据是否为最新的版本以及它所提供的功能。
版本号的格式化描述为主版本号.次版本号[.修正版本号[.编译版本号]],由二至四个部分组成:主版本号、次版本号、修正版本号和编译版本号。主版本号和次版本号是必选的,修正版本号和编译版本号是可选的,但是如果定义了编译版本号部分,则修正版本号就是必选的。所有定义的部分都必须是大于或等于0的整数。
版本号的管理策略如下:
(1)项目初版,版本号为1.0或1.0.0;
(2)当项目在进行了局部修改或BUG(程序漏洞)修正时,主版本号和次版本号不变,修正版本号加1;
(3)当项目在原有的基础上增加了部分功能时,主版本号不变,次版本号加1,修正版本号复位为0,因而可以被忽略掉;
(4)当项目在进行了重大修改或局部修正累积较多,而导致项目整体发生全局变化时,主版本号加1,此时版本号复位为0但不可以忽略;
(5)编译版本号一般是编译器在编译过程中自动生成的,我们只定义其格式,并不 进行人为控制。
区块链系统中节点接收区块链系统外的服务器SDK生成的业务数据,通过节点的数据处理模块将业务数据序列化为字节流,再将字节流发送至P2P模块,用于节点间传输。进一步说明,SDK可以是区块链系统外的服务器的软件开发工具,也可以是区块链系统中节点的软件开发工具。
为方便描述节点中的数据序列化和反序列化流程、节点间的数据传输流程,如图2所示,将发送方节点定义为第一节点,与发送方节点连接的SDK为第一SDK,发送方节点中包括第一P2P模块、第一数据处理模块和第一数据存储模块;相应的,将接收方节点定义为第二节点,与接收方节点连接的SDK为第二SDK,接收方节点中包括第二P2P模块、第二数据处理模块和第二数据存储模块。
第一SDK生成第一业务数据并发送至第一数据处理模块,第一数据处理模块将第一业务数据进行序列化操作,生成字节流,第一P2P模块将字节流发送至第二P2P模块,第二数据处理模块将字节流反序列化为第二业务数据并发送至第二SDK。
区块链系统中节点间进行数据传输时,若发送方节点的数据格式与接收方节点的数据格式相同,则发送方节点将业务数据转化为发送方节点的数据格式对应的字节流即可以直接被接收方节点处理;若发送方节点的数据格式与接收方节点的数据格式不同,则需要发送方节点将业务数据转化为接收方节点的数据格式对应的字节流或转化为接收方节点可处理的数据格式对应的字节流。
本申请实施例中,节点的数据格式对应的字节流可以包括数据长度、单个结构体长度、定长字节、变长字节等。
示例性的,节点的节点版本号为N1.3、数据版本号为D1.1,节点接收到的业务数据可以为如图3(a)所示,该业务数据中包括3个结构体;数据格式对应的字节流Data1如图3(b)所示,字节流Data1包括如表1所示的信息。
表1
字节长度 作用 赋值
4字节 描述字节流数据长度 18
4字节 描述第一个结构体长度 2
1字节 描述第一个结构体中,定长数据x 2
1字节 描述第一个结构体中,定长数据y 5
4字节 描述第二个结构体长度 2
1字节 描述第二个结构体中,定长数据x 2
1字节 描述第二个结构体中,定长数据y 1
4字节 描述第三个结构体长度 2
1字节 描述第三个结构体中,定长数据x 0
1字节 描述第三个结构体中,定长数据y 1
示例性的,节点的节点版本号为N1.8、数据版本号为D1.2,节点接收到的业务数据可以为如图4(a)所示,该业务数据中包括3个结构体;数据格式对应的字节流Data3如图4(b)所示,字节流Data3包括如表2所示的信息。
表2
字节长度 作用 赋值
4字节 描述字节流数据长度 34
4字节 描述第一个结构体长度 9
1字节 描述第一个结构体中,定长数据x 2
1字节 描述第一个结构体中,定长数据y 5
7字节 描述第一个结构体中,变长数据z abcdefg
4字节 描述第二个结构体长度 6
1字节 描述第二个结构体中,定长数据x 2
1字节 描述第二个结构体中,定长数据y 1
4字节 描述第二个结构体中,变长数据z abcd
4字节 描述第三个结构体长度 7
1字节 描述第三个结构体中,定长数据x 0
1字节 描述第三个结构体中,定长数据y 1
5字节 描述第三个结构体中,变长数据z hjikl
此处,需要说明的是,表1和表2中,“数据长度”所占的字节长度为4字节、“单个结构体长度”所占的字节长度为4字节、“定长数据x”所占的字节长度为1字节、“定长数据y”所占的字节长度为1字节、“变长数据z”所占的字节长度为7字节,……,在本申请实施例中,所有参数在字节流中所占的字节长度可以根据经验进行设定,不限于表格中的字节长度。此说明同样适用于下述表格中的“版本号”所占的字节长度、“位置指示信息个数”所占的字节长度等等。
上述实施例中,数据版本号D1.1低于数据版本号D1.2,也就是说,如图3(a)示出的数据格式相对于如图4(a)示出的数据格式为较低版本的数据格式,若第一节点的数据版本号是D1.1,第二节点的数据版本号是D1.2,当第一节点向第二节点发送字节流时,第一节点需要将业务数据转化为D1.2数据格式对应的字节流或转化为第二节点可处理的数据格式对应的字节流。同理,若第一节点的数据版本号是D1.2,第二节点的数据版本号是D1.1,当第一节点向第二节点发送字节流时,第一节点需要将业务数据转化为D1.1数据格式对应的字节流或转化为第二节点可处理的数据格式对应的字节流。
图5为本申请实施例提供的一种基于区块链的数据处理流程,该数据处理流程详细说明了第一节点向第二节点发送第一字节流的实施方式。
步骤501,第一节点获取第一业务数据。
第一业务数据即第一SDK向第一节点发送的第一业务数据,该第一业务数据中可以包括多个第一结构体。示例性的,第一业务数据可以如图3(a)或如图4(a)所示。
步骤502,第一节点根据第一节点的配置信息,将第一业务数据转换为具有预设数据格式的第一字节流。
步骤503,第一节点发送第一字节流至第二节点。
步骤504,第二节点根据第二节点的配置信息将第一字节流转化为第二业务数据。
第二节点根据第二节点的版本号和位置指示信息长度,将第一字节流转化为第二业务数据,且第二业务数据包括多个第二结构体。
在步骤502中,每个节点本地都存储有该节点的配置信息,配置信息包括节点的版本号和节点的位置指示信息长度。本申请实施中,版本号可以为包括节点版本号和数据版本号,也可以只包括数据版本号,版本号只要可以唯一确定节点的数据格式即可。
第一节点根据第一节点的配置信息,将第一业务数据转换为具有预设数据格式的第一字节流。本申请实施中,预设数据格式可以包括位置指示信息长度、依序设置的各结构体的位置指示信息及用于记录各结构体承载的数据的数据信息,位置指示信息用于指示结构体承载的数据在字节流中的位置。其中,预设数据格式用于第二节点将第一字节流根据第二节点的配置信息转化为第二业务数据。
进一步的,预设数据格式还可以包括版本号和位置指示信息的个数。版本号用于接收方节点在接收到字节流后,根据字节流中的版本号判断是否对该字节流进行处理,具体实现过程在下面实施例中描述。位置指示信息的个数用于表示该字节流中包含的位置指示信息的个数,如图4(c)示出的字节流Data4,位置指示信息的个数为3,在接收方节点接收到字节流Data4后,可以读取到字节流Data4中包括3个位置指示信息,当接收方节点读取完第三个位置指示信息后,即可以确定出字节流Data4中的位置指示信息已经读取完毕。
各结构体的位置指示信息可以包括各结构体的变长数据在数据信息中的位置以及定长数据,可以结合图4(c)示出的字节流Data4解释说明;各结构体的位置指示信息也可以包括各结构体的定长数据在数据信息中的位置以及变长数据在数据信息中的位置,可以结合图4(d)示出的字节流Data5解释说明。
在图4(c)示出的字节流Data4中,第一个位置指示信息对应第一业务数据中的第一个结构体,该位置指示信息包括第一个结构体中的定长数据x、定长数据y和变长数据z在数据信息中的位置信息。在获取变长数据z时,从数据信息中字符串的第0个字节开始,读取数据信息中字符串的7个字节。字节流Data4包括如表3所示的信息。
表3
Figure PCTCN2020084319-appb-000001
在图4(d)示出的字节流Data5中,第一个位置指示信息对应第一业务数据中的第一个结构体,该位置指示信息包括第一个结构体中定长数据在数据信息中的位置信息以及变长数据在数据信息中的位置信息。在获取定长数据x、定长数据y和变长数据z时,从数据信息中字符串的第0个字节开始,读取数据信息中字符串的9个字节。字节流Data5包 括如表4所示的信息。
表4
Figure PCTCN2020084319-appb-000002
第一节点在根据第一节点的配置信息,将第一业务数据转换为第一字节流时,可以将各结构体中的变长数据按照各结构体的顺序置于数据信息中,以及将各结构体中的变长数据在数据信息中的位置记录在各结构体的位置指示信息中,此实现过程中,各结构体的位置指示信息包括各结构体的变长数据在数据信息中的位置及各结构体的定长数据。
需要说明的是,如图3(a)所示的业务数据中,每个结构体只存在定长数据,则在生成第一字节流时,无需生成数据信息,也无需在位置指示信息中记录变长字节在数据信息中的位置。生成的第一字节流Data2可以如图3(c)所示。
此外,位置指示信息用于描述各结构体的变长数据在数据信息中的位置以及定长数据时,可以设置变长数据的起始位置和变长数据的长度,从而将各结构体中的变长数据定位到数据信息中,同样,还可以设置变长数据的起始位置和变长数据的终止位置,将各结构体中的变长数据定位到数据信息中,或者采用其他方式,用于定位各结构体中的变长数据在数据信息中的位置,在此不做限制。且,位置指示信息用于描述各结构体的变长数据在数据信息中的位置以及定长数据在数据信息中的位置时,也适用于上述方式。
本申请实施例中,第一节点将第一业务数据按照第一节点的配置信息将第一业务数据转换为具有预设数据格式的第一字节流,第一字节流中包括位置指示信息和数据信息,位置指示信息中包括各结构体的变长数据在数据信息中的位置及各结构体的定长数据或者包括各结构体的变长数据在数据信息中的位置及各结构体的定长数据在数据信息中的位置,通过该方式,第一节点可以将第一业务数据中各结构体的变长字段转化为定长字段,以使得第二节点可以处理该数据格式的第一字节流,且可以使用位置指示信息中的索引对变长数据进行查找,从而实现数据的反序列化。也就是说,第一节点只需要将第一业务数据转化为第二节点可处理的数据格式对应的字节流,而无需将第一业务数据转化为第二节点的数据格式对应的字节流。进一步的,第一节点针对不同的接收方节点,均可以生成该同一数据格式的字节流,用于不同接收方节点读取该第一字节流,第一节点无需针对每个接收方节点转化为该接收方节点的数据格式对应的字节流,减少了第一节点的工作量。且第一节点中不需要存储区块链系统中所有接收方节点的配置信息,只需要存储自身的配置 信息即可,第一节点的存储数据量小。
步骤501至步骤504示出的实施例中,第一节点相当于字节流的发送方节点,第二节点相当于字节流的接收方节点,第二节点在接收到第一字节流后,将第一字节流转换为第二业务数据的实现方式与第一节点作为接收方节点时的实现方式类似,可参照下述实施例。
当第一节点是接收方节点时,可以接收第三节点发送的第二字节流,并根据第一节点的配置信息,将第二字节流转化为第四业务数据。此处,当第一节点的版本号低于第三节点的版本号时,第一节点的版本逻辑支持第三节点的版本生成的数据,相当于第一节点可以实现前向兼容;当第一节点的版本号高于第三节点的版本号时,第一节点的版本逻辑支持第三节点的版本生成的数据,相当于第一节点可以实现后向兼容。
具体的,第一节点实现前向兼容和后向兼容,可以参照图6示出的流程图。
步骤601,第一节点获取第二字节流。
第二字节流是第三节点根据第三节点的配置信息将第三业务数据转换为具有预设数据格式的字节流,第三业务数据包括多个第三结构体。此处,第三节点根据第三节点的配置信息将第三业务数据转换为第二字节流的实现方式与第一节点作为发送方节点的实现方式类似,在此不在赘述。
步骤602,第一节点确定各结构体的定长数据和各结构体的变长数据。
第一节点根据第一节点的位置指示信息长度、第三节点的位置指示信息长度、第二字节流中各结构体的位置指示信息,确定各结构体的定长数据和各结构体的变长数据,也就是确定转化出的业务数据中的各结构体的定长数据和各结构体的变长数据。
步骤603,第一节点根据各结构体的定长数据和各结构体的变长数据,确定包含至少一个第一结构体的第四业务数据。
针对各结构体的位置指示信息,确定出各结构体的定长数据和变长数据,并组成结构体,该结构体即为第一节点根据节点的配置信息确定出的第一结构体,并将至少一个第一结构体组成第四业务数据。
在步骤602中,可以定义第一节点的位置指示信息长度为M个字节,第三节点的位置指示信息长度为N个字节,M和N为正整数。第一节点结合M和N的大小,对接收到的第二字节流进行不同方式的处理,具体如下。
处理方式一:
第一节点若确定M大于N,则在第二字节流中各结构体的位置指示信息后补充M-N个赋值为零的字节,并根据补充后的各结构体的位置指示信息,从各结构体的位置指示信息中提取各结构体的定长数据且从数据信息中提取各结构体的变长数据。
处理方式二:
第一节点若确定M小于N,则舍弃第二字节流中各结构体的位置指示信息后的N-M个字节,并根据舍弃后的各结构体的位置指示信息,从各结构体的位置指示信息中提取各结构体的定长数据且从数据信息中提取各结构体的变长数据。
此处,需要说明的是,第一节点若确定M等于N,则表示第一节点接收到的第二字节流对应的数据格式是第一节点的数据格式,即第一节点的版本号和第三节点的版本号一致,第一节点可以对第二字节流直接进行反序列化处理,故在此不做赘述。
结合图3(a)、图3(b)、图3(c)、图4(a)、图4(b)、图4(c),以第三业务数据中的第一个结构体为例,分两种情况进行说明。
情况一:
第一节点的位置指示信息长度为10(M=10),对应的业务数据格式如图4(a)所示,第三节点的位置指示信息长度为2(N=2),对应的业务数据格式如图3(a)所示。第一节点接收到的字节流Data2如图3(c)所示,第一节点读取字节流Data2中的位置指示信息长度为2后,确定M大于N,则在字节流Data2中各结构体的位置指示信息后补充M-N个赋值为零的字节,即在第一个结构体的定长数据x和定长数据y后面补充8个赋值为零的字节,补充后的第一个结构体的位置指示信息可以如图7所示,根据补充后的第一个结构体的位置指示信息,确定出第一个结构体的定长数据为定长数据x和定长数据y,赋值分别为2和5,变长数据长度为0。
情况二:
第一节点的位置指示信息长度为2(M=2),对应的业务数据格式如图3(a)所示。当第三节点的位置指示信息长度为10(N=10),对应的业务数据格式如图4(a)所示。第一节点接收到的字节流Data4如图4(c)所示,第一节点读取字节流Data4中的位置指示信息长度为10后,确定M小于N,则舍弃字节流Data4中各结构体的位置指示信息后的N-M个字节,即删除第一个结构体的位置指示信息中10个字节的后8个字节,删除后的第一个结构体的位置指示信息可以如图8所示,根据舍弃后的第一个结构体的位置指示信息,确定出第一个结构体的定长数据为定长数据x和定长数据y,赋值分别为2和5,变长数据长度为0。
本申请实施例中,当M大于N时,将第二字节流中各结构体的位置指示信息后补充M-N个赋值为零的字节的目的在于,减少第一节点处理字节流的工作量,示例性的,当第一节点的位置指示信息长度为10(M=10),与第一节点进行第二字节流传输的节点不仅有第三节点,还会有第四节点和第五节点,分别对应的位置指示信息长度为4(N=4)和6(N=6),若第一节点在接收到第二字节流后,不采用在位置指示信息后补充M-N个赋值为零的字节的方式,而是直接处理接收到的第二字节流,则会存在如下情况:
第一节点接收第三节点发送的第二字节流,第二字节流中位置指示信息的长度为2,第一节点在读取到第二字节流中位置指示信息的长度后,会生成用于处理该长度为2的位置指示信息的函数,假设为F(N=2)。第一节点接收第四节点发送的第二字节流,第二字节流中位置指示信息的长度为4,第一节点在读取到第二字节流中位置指示信息的长度后,会生成用于处理该长度为4的位置指示信息的函数,假设为F(N=4)。同理,第一节点会生成用于处理长度为6的位置指示信息的函数F(N=6)。
也就是说,如果第一节点直接读取第二字节流,需要生成针对不同长度的位置指示信息的函数,以适用于处理不同的位置指示信息。而在本申请实施例中,若第一节点将第二字节流中各结构体的位置指示信息后补充M-N个赋值为零的字节后,则可以仅处理长度为10的位置指示信息。结合上述例子,第一节点接收第三节点发送的第二字节流后,在各结构体的位置指示信息后补充8个赋值为零的字节;第一节点接收第四节点发送的第二字节流后,在各结构体的位置指示信息后补充6个赋值为零的字节;以及第一节点接收第五节点发送的第二字节流后,在各结构体的位置指示信息后补充4个赋值为零的字节。通过该方式,第一节点只需要生成用于处理该长度为10的位置指示信息的函数F(N=10)。
此外,本申请实施例中,第一节点可以在各结构体的位置指示信息后补充M-N个赋值为零的字节,以使得各结构体的位置指示信息的长度为M,也可以在各结构体的位置指 示信息后补充其它字节,以实现该相同目的。
需要说明的是,本申请实施例中存在补充后的各结构体的位置指示信息或舍弃后的各结构体的位置指示信息中记录有变长数据的位置信息的情况。以图9(a)、图9(b)为例。
发送方节点的版本号为V2.2,发送方节点根据节点中的配置信息生成如图9(a)的字节流Data6的格式,该字节流Data6中包括2个位置指示信息,位置指示信息的长度为18,位置指示信息中包括定长数据x、定长数据y、第一个变长数据z 1的起始位置和长度、第二个变长数据z 2的起始位置和长度。字节流Data6包括如表5所示的信息。
表5
Figure PCTCN2020084319-appb-000003
接收方节点的版本号为V2.1,接收方节点根据节点中的配置信息生成如图9(b)的字节流Data7的格式,该字节流Data7的中包括2个位置指示信息,位置指示信息的长度为10,位置指示信息中包括定长数据x、定长数据y、变长数据z的起始位置和长度。字节流Data7包括如表6所示的信息。
表6
Figure PCTCN2020084319-appb-000004
当接收方节点接收到发送方节点发送的如图9(a)所示的字节流Data6之后,会根据接收方节点的位置指示信息长度(M=10)和发送方节点的位置指示信息长度(N=18),确定从字节流Data6各结构体的位置指示信息中舍弃8个字节,举例来说,字节流Data6的第一个位置指示信息舍弃8个字节,可参照如图9(c)示出的位置指示信息。进而可以根据位置指示信息中变长数据z在数据信息中的起始位置0和变长数据z的长度7从数据信息中获取变长数据z。
上述技术方案中,当M大于N时,将第二字节流中各结构体的位置指示信息后补充M-N个赋值为零的字节的目的在于,减少第一节点的处理字节流的工作量,解释为,当第一节点接收多个发送方节点发送的第二字节流时,若多个发送方节点发送的第二字节流中各结构体的位置指示信息长度不同,则第一节点可以采用补充赋值为零的字节的方式,将各第二字节流中各结构体的位置指示信息的字节长度补充为M从而第一节点仅需要处理长度为M的位置指示信息,即仅需要生成一个用于处理长度为的M的位置指示信息的函数。
当M小于N时,将第二字节流中各结构体的位置指示信息后的N-M个字节舍弃,从而第二字节流中的各结构体的位置指示信息长度与第一节点的配置信息中的位置指示信息长度相等,以使得第一节点可以处理该第二字节流。且该技术方案中,第二字节流中的位置指示信息长度大于第一节点的配置信息中的位置指示信息长度,代表第三节点的版本号高于第一节点的版本号,将第二字节流中各结构体的位置指示信息后的N-M个字节舍弃,仅是将高于第一节点的版本逻辑删除,不影响第一节点本身的版本逻辑。
进一步的,第二字节流中存在多个结构体的位置指示信息,由于各结构体的位置指示信息中记录有各结构体的定长数据和各结构体的变长数据在数据信息中的位置索引,则可以根据各结构体的位置指示信息,并行化提取各结构体的定长数据和变长数据,提高了数据反序列化的效率。
此外,第一节点在接收到第二字节流之后,可以先从第二字节流中提取第三节点的版本号,并根据第三节点的版本号判断是否对该第二字节流进行处理。可选的,可以判断第一节点的版本号中的主版本号与第三节点的版本号中的主版本号是否一致,若是,则确定对第二字节流进行处理,否则,确定不对第二字节流进行处理。
例如,第一节点的版本号为V1.2(第一节点的版本号的主版本号为V1),若第一节点提取到的第三节点的版本号为V1.1(第三节点的版本号的主版本号为V1),即确定出第一节点的版本号中的主版本号与第三节点的版本号中的主版本号一致,确定对第二字节流进行处理。若第一节点提取到的第三节点的版本号为V2.1(第三节点的版本号的主版本号为V2),即确定出第一节点的版本号中的主版本号与第三节点的版本号中的主版本号不一致,确定不对第二字节流进行处理。
本申请实施例中,第一节点在接收到第二字节流之后,通过确定发送方节点的主版本号是否与自身节点的主版本号一致,从而判断第一节点是否对第二字节流进行处理,可以预先过滤掉与自身节点的主版本号不一致的节点发送的字节流,从而提高第一节点对字节流处理的效率。
为了更好的解释本申请实施例,下面将在具体的实施场景下描述该基于区块链的数据序列化流程(业务数据→字节流)和数据反序列化流程(字节流→业务数据)。
数据序列化流程(业务数据→字节流)如图10所示。
步骤1001,开辟存储空间A。
步骤1002,在A中写入节点配置信息中的版本号。
步骤1003,在A中按序写入位置指示信息的个数和单个位置指示信息的长度。
步骤1004,遍历业务数据,获取业务数据中定义相同的结构体。
步骤1005,判断结构体是否存在变长数据,若否,转向步骤1006,若是,转向步骤1007。
步骤1006,按照字段类型的占位情况将定长数据写入A。
步骤1007,判断是否存在缓存区间B,若否,转向步骤1008,若是,转向步骤1009。
步骤1008,开辟存储空间B。
步骤1009,按照字段类型的占位情况将定长数据写入A,将当前B的大小和变长数据长度这两字段按序写入A。
步骤1010,将变长数据写入B。
步骤1011,业务数据处理完后,将B的数据写在A最后。
序列化操作完成,所生成的字节流可以交由P2P模块进行发送。
数据反序列化流程(字节流→业务数据)如图11所示。
步骤1101,确定版本号。
步骤1102,判断主版本号是否一致,若是,则转向步骤1103,否则,结束。
步骤1103,确定字节流中位置指示信息个数n和位置指示信息长度N。
步骤1104,确定配置信息中的位置指示信息长度M。
步骤1105,判断M是否大于N,若是,转向步骤1106,若否,转向步骤1107。
步骤1106,在字节流中各结构体的位置指示信息后面补0,直至满足单个位置指示信息长度为M。
步骤1107,在字节流中各结构体的位置指示信息中读取前M个字节。
步骤1108,判断是否存在变长数据,若是,转向步骤1109,否则,转向步骤1110。
步骤1109,根据读取数据中变长数据的起始位置和长度,在数据信息中找出对应的字符串进行替换。
步骤1110,处理完成n个位置指示信息。
由于本实施例的数据序列化和数据反序列化流程的具体实现方式已在其他实施例中描述,在此不作赘述。
本申请实施例中,第一节点根据节点的配置信息将第一业务数据转化为第一字节流,第一字节流中包括位置指示信息和数据信息,位置指示信息中包括各结构体的变长数据在数据信息中的位置及各结构体的定长数据或者包括各结构体的变长数据在数据信息中的位置及各结构体的定长数据在数据信息中的位置,通过该方式,第一节点可以将第一业务数据中各结构体的变长字段转化为定长字段,以使得第二节点可以处理该数据格式的第一字节流,且可以使用位置指示信息中的索引对变长数据进行查找,从而实现数据的反序列化。也就是说,第一节点只需要将第一业务数据转化为第二节点可处理的数据格式对应的字节流,而无需将第一业务数据转化为第二节点的数据格式对应的字节流,进一步的,该第一字节流可以被预设条件下的其他接收方节点处理,第一节点无需针对每个接收方节点转化为该接收方节点的数据格式对应的字节流,减少了第一节点的工作量。且第一节点中不需要存储区块链系统中所有接收方节点的配置信息,只需要存储自身的配置信息即可, 第一节点的存储数据量小。
上述技术方案中,第一节点在接收到第二字节流之后,通过确定发送方节点的主版本号是否与自身节点的主版本号一致,从而判断第一节点是否对第二字节流进行处理,可以预先过滤掉与自身节点的主版本号不一致的节点发送的字节流,从而提高第一节点在对字节流处理时的效率。
基于同一构思,图12示例性的示出了本申请实施例提供的一种基于区块链的数据处理装置的结构,该装置可以执行基于区块链的数据处理方法的流程。该装置可以以软件或硬件的形式存在。如图8所示,装置可以包括:处理单元1202和获取单元1201。作为一种实现方式,该获取单元1201可以包括接收单元,该装置还可以包括发送单元。处理单元1202用于对装置的动作进行控制管理。获取单元1201和发送单元用于支持装置与其他网络实体的通信。
其中,处理单元1202可以是处理器或控制设备,例如可以是通用中央处理器(central processing unit,CPU),通用处理器,数字信号处理(digital signal processing,DSP),专用集成电路(application specific integrated circuits,ASIC),现场可编程门阵列(field programmable gate array,FPGA)或者其他可编程逻辑器件、晶体管逻辑器件、硬件部件或者其任意组合。其可以实现或执行结合本申请公开内容所描述的各种示例性的逻辑方框,模块和电路。处理器也可以是实现计算功能的组合,例如包括一个或多个微处理器组合,DSP和微处理器的组合等等。获取单元1201是一种该装置的接口电路,用于从其它装置接收信号。例如,当该装置以芯片的方式实现时,该获取单元1201是该芯片用于从其它芯片或装置接收信号的接口电路,发送单元是该芯片用于向其它芯片或装置发送信号的接口电路。
该装置可以为上述实施例中的第一节点,还可以为用于第一节点的芯片。例如,当装置为第一节点时,该处理单元1202例如可以是处理器,该获取单元1201例如可以是收发器。可选的,该收发器可以包括射频电路,该存储单元例如可以是存储器。例如,当装置为用于第一节点的芯片时,该处理单元1202例如可以是处理器,该获取单元1201或发送单元例如可以是输入/输出接口、管脚或电路等。该处理单元1202可执行存储单元存储的计算机执行指令,可选地,该存储单元为该芯片内的存储单元,如寄存器、缓存等,该存储单元还可以是第一转发服务器内的位于该芯片外部的存储单元,如只读存储器(read-only memory,ROM)或可存储静态信息和指令的其他类型的静态存储设备,随机存取存储器(random access memory,RAM)等。
在一种实施例中,该装置为上述实施例中的第一节点。其中,获取单元1201,用于获取第一业务数据;所述第一业务数据包括多个第一结构体;
处理单元1202,用于根据第一节点的配置信息,将所述第一业务数据转换为具有预设数据格式的第一字节流并发送给第二节点;所述配置信息包括节点的版本号和节点的位置指示信息长度;所述预设数据格式包括位置指示信息长度、依序设置的各结构体的位置指示信息及用于记录各结构体承载的数据的数据信息;所述位置指示信息用于指示结构体承载的数据在字节流中的位置;所述预设数据格式用于所述第二节点将所述第一字节流根据所述第二节点的配置信息转化为第二业务数据;所述第二业务数据包括多个第二结构体。
可选的,所述各结构体的位置指示信息包括所述各结构体的变长数据在所述数据信息中的位置及所述各结构体的定长数据;所述数据信息包括依序设置的所述各结构体的变长 数据。
可选的,所述处理单元1202还用于:控制所述获取单元1201获取第二字节流;所述第二字节流是第三节点根据所述第三节点的配置信息将第三业务数据转换为具有所述预设数据格式的字节流;所述第三业务数据包括多个第三结构体;根据所述第一节点的位置指示信息长度、所述第三节点的位置指示信息长度、所述第二字节流中各结构体的位置指示信息确定各结构体的定长数据和各结构体的变长数据;根据所述各结构体的定长数据和所述各结构体的变长数据,确定包含至少一个所述第一结构体的第四业务数据。
可选的,所述第一节点的位置指示信息长度为M个字节,所述第三节点的位置指示信息长度为N个字节;M和N为正整数;所述处理单元1202具体用于:若确定M大于N,则在所述第二字节流中各结构体的位置指示信息后补充M-N个赋值为零的字节;根据补充后的各结构体的位置指示信息,从各结构体的位置指示信息中提取各结构体的定长数据且从所述数据信息中提取各结构体的变长数据。
可选的,所述处理单元1202还用于:若确定M小于N,则舍弃所述第二字节流中各结构体的位置指示信息后的N-M个字节;根据舍弃后的各结构体的位置指示信息,从各结构体的位置指示信息中提取各结构体的定长数据且从所述数据信息中提取各结构体的变长数据。
可选的,所述预设数据格式还包括版本号;所述处理单元1202还用于:
在所述确定各结构体的定长数据和各结构体的变长数据之前,从所述第二字节流中提取所述第三节点的版本号;判断所述第一节点的版本号中的主版本号与所述第三节点的版本号中的主版本号是否一致,若是,则确定对所述第二字节流进行处理。
基于同一构思,如图13所示,本申请实施例还提供了一种计算设备,该计算设备1300可以是上述实施例中的运行诊断器。计算设备1300包括:处理器1302和通信接口1303,可选的,计算设备1300还可以包括存储器1301。可选的,计算设备1300还可以包括通信线路1304。其中,通信接口1303、处理器1302以及存储器1301可以通过通信线路1304相互连接;通信线路1304可以是外设部件互连标准(peripheral component interconnect,简称PCI)总线或扩展工业标准结构(extended industry standard architecture,简称EISA)总线等。通信线路1304可以分为地址总线、数据总线、控制总线等。为便于表示,图13中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。
处理器1302可以是一个CPU,微处理器,ASIC,或一个或多个用于控制本申请方案程序执行的集成电路。
一种可能的实施例中,处理器1302,可以用于:根据所述第一节点的配置信息,将第一业务数据转换为具有预设数据格式的第一字节流并通过通信接口1303发送给第二节点;第一业务数据包括多个第一结构体;配置信息包括节点的版本号和节点的位置指示信息长度;预设数据格式包括位置指示信息长度、依序设置的各结构体的位置指示信息及用于记录各结构体承载的数据的数据信息;位置指示信息用于指示结构体承载的数据在字节流中的位置;预设数据格式用于第二节点将第一字节流根据第二节点的配置信息转化为第二业务数据;第二业务数据包括多个第二结构体。
通信接口1303,使用任何收发器一类的装置,用于与其他设备或通信网络通信,如以太网,无线接入网(radio access network,RAN),无线局域网(wireless local area networks,WLAN),有线接入网等。
一种可能的实现方式,通信接口1303,用于获取第一业务数据。
存储器1301可以是ROM或可存储静态信息和指令的其他类型的静态存储设备,RAM或者可存储信息和指令的其他类型的动态存储设备,也可以是电可擦可编程只读存储器(electrically erasable programmable read-only memory,EEPROM)、只读光盘(compact disc read-only memory,CD-ROM)或其他光盘存储、光碟存储(包括压缩光碟、激光碟、光碟、数字通用光碟、蓝光光碟等)、磁盘存储介质或者其他磁存储设备、或者能够用于携带或存储具有指令或数据结构形式的期望的程序代码并能够由计算机存取的任何其他介质,但不限于此。存储器可以是独立存在,通过通信线路1304与处理器相连接。存储器也可以和处理器集成在一起。
其中,存储器1301用于存储执行本申请方案的计算机执行指令,并由处理器1302来控制执行。处理器1302用于执行存储器1301中存储的计算机执行指令,从而实现本申请上述实施例提供的方法。
可选的,本申请实施例中的计算机执行指令也可以称之为应用程序代码,本申请实施例对此不作具体限定。
基于同一构思,本申请实施例还提供了一种计算机可读非易失性存储介质,包括计算机可读指令,当计算机读取并执行所述计算机可读指令时,使得计算机执行上述基于区块链的数据处理方法。
本申请是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
尽管已描述了本申请的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例作出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本申请范围的所有变更和修改。
显然,本领域的技术人员可以对本申请进行各种改动和变型而不脱离本申请的精神和范围。这样,倘若本申请的这些修改和变型属于本申请权利要求及其等同技术的范围之内,则本申请也意图包含这些改动和变型在内。

Claims (14)

  1. 一种基于区块链的数据处理方法,其特征在于,包括:
    第一节点获取第一业务数据;所述第一业务数据包括多个第一结构体;
    所述第一节点根据所述第一节点的配置信息,将所述第一业务数据转换为具有预设数据格式的第一字节流并发送给第二节点;所述配置信息包括节点的版本号和节点的位置指示信息长度;所述预设数据格式包括位置指示信息长度、依序设置的各结构体的位置指示信息及用于记录各结构体承载的数据的数据信息;所述位置指示信息用于指示结构体承载的数据在字节流中的位置;所述预设数据格式用于所述第二节点将所述第一字节流根据所述第二节点的配置信息转化为第二业务数据;所述第二业务数据包括多个第二结构体。
  2. 如权利要求1所述的方法,其特征在于,所述各结构体的位置指示信息包括所述各结构体的变长数据在所述数据信息中的位置及所述各结构体的定长数据;所述数据信息包括依序设置的所述各结构体的变长数据。
  3. 如权利要求1或2所述的方法,其特征在于,还包括:
    所述第一节点获取第二字节流;所述第二字节流是第三节点根据所述第三节点的配置信息将第三业务数据转换为具有所述预设数据格式的字节流;所述第三业务数据包括多个第三结构体;
    所述第一节点根据所述第一节点的位置指示信息长度、所述第三节点的位置指示信息长度、所述第二字节流中各结构体的位置指示信息确定各结构体的定长数据和各结构体的变长数据;
    所述第一节点根据所述各结构体的定长数据和所述各结构体的变长数据,确定包含至少一个所述第一结构体的第四业务数据。
  4. 如权利要求3所述的方法,其特征在于,所述第一节点的位置指示信息长度为M个字节,所述第三节点的位置指示信息长度为N个字节;M和N为正整数;
    所述第一节点根据所述第一节点的位置指示信息长度、所述第三节点的位置指示信息长度、所述第二字节流中各结构体的位置指示信息确定各结构体的定长数据和各结构体的变长数据,包括:
    所述第一节点若确定M大于N,则在所述第二字节流中各结构体的位置指示信息后补充M-N个赋值为零的字节;
    所述第一节点根据补充后的各结构体的位置指示信息,从各结构体的位置指示信息中提取各结构体的定长数据且从所述数据信息中提取各结构体的变长数据。
  5. 如权利要求3或4所述的方法,其特征在于,所述第一节点根据所述第一节点的位置指示信息长度、所述第三节点的位置指示信息长度、所述第二字节流中各结构体的位置指示信息确定各结构体的定长数据和各结构体的变长数据,还包括:
    所述第一节点若确定M小于N,则舍弃所述第二字节流中各结构体的位置指示信息后的N-M个字节;
    所述第一节点根据舍弃后的各结构体的位置指示信息,从各结构体的位置指示信息中提取各结构体的定长数据且从所述数据信息中提取各结构体的变长数据。
  6. 如权利要求3至5任一项所述的方法,其特征在于,所述预设数据格式还包括版本号;
    在所述第一节点确定各结构体的定长数据和各结构体的变长数据之前,还包括:
    所述第一节点从所述第二字节流中提取所述第三节点的版本号;
    所述第一节点判断所述第一节点的版本号中的主版本号与所述第三节点的版本号中的主版本号是否一致,若是,则确定对所述第二字节流进行处理。
  7. 一种基于区块链的数据处理装置,其特征在于,包括:
    获取单元,用于获取第一业务数据;所述第一业务数据包括多个第一结构体;
    处理单元,用于根据第一节点的配置信息,将所述第一业务数据转换为具有预设数据格式的第一字节流并发送给第二节点;所述配置信息包括节点的版本号和节点的位置指示信息长度;所述预设数据格式包括位置指示信息长度、依序设置的各结构体的位置指示信息及用于记录各结构体承载的数据的数据信息;所述位置指示信息用于指示结构体承载的数据在字节流中的位置;所述预设数据格式用于所述第二节点将所述第一字节流根据所述第二节点的配置信息转化为第二业务数据;所述第二业务数据包括多个第二结构体。
  8. 如权利要求7所述的装置,其特征在于,所述各结构体的位置指示信息包括所述各结构体的变长数据在所述数据信息中的位置及所述各结构体的定长数据;所述数据信息包括依序设置的所述各结构体的变长数据。
  9. 如权利要求7或8所述的装置,其特征在于,所述处理单元还用于:
    控制所述获取单元获取第二字节流;所述第二字节流是第三节点根据所述第三节点的配置信息将第三业务数据转换为具有所述预设数据格式的字节流;所述第三业务数据包括多个第三结构体;
    根据所述第一节点的位置指示信息长度、所述第三节点的位置指示信息长度、所述第二字节流中各结构体的位置指示信息确定各结构体的定长数据和各结构体的变长数据;
    根据所述各结构体的定长数据和所述各结构体的变长数据,确定包含至少一个所述第一结构体的第四业务数据。
  10. 如权利要求9所述的装置,其特征在于,所述第一节点的位置指示信息长度为M个字节,所述第三节点的位置指示信息长度为N个字节;M和N为正整数;
    所述处理单元具体用于:
    若确定M大于N,则在所述第二字节流中各结构体的位置指示信息后补充M-N个赋值为零的字节;
    根据补充后的各结构体的位置指示信息,从各结构体的位置指示信息中提取各结构体的定长数据且从所述数据信息中提取各结构体的变长数据。
  11. 如权利要求9或10所述的装置,其特征在于,所述处理单元还用于:
    若确定M小于N,则舍弃所述第二字节流中各结构体的位置指示信息后的N-M个字节;
    根据舍弃后的各结构体的位置指示信息,从各结构体的位置指示信息中提取各结构体的定长数据且从所述数据信息中提取各结构体的变长数据。
  12. 如权利要求9至11任一项所述的装置,其特征在于,所述预设数据格式还包括版本号;
    所述处理单元还用于:
    在所述确定各结构体的定长数据和各结构体的变长数据之前,从所述第二字节流中提取所述第三节点的版本号;
    判断所述第一节点的版本号中的主版本号与所述第三节点的版本号中的主版本号是否一致,若是,则确定对所述第二字节流进行处理。
  13. 一种计算设备,其特征在于,包括:
    存储器,用于存储程序指令;
    处理器,用于调用所述存储器中存储的程序指令,按照获得的程序执行权利要求1至6任一项所述的方法。
  14. 一种计算机可读非易失性存储介质,其特征在于,包括计算机可读指令,当计算机读取并执行所述计算机可读指令时,使得计算机执行如权利要求1至6任一项所述的方法。
PCT/CN2020/084319 2019-05-08 2020-04-10 一种基于区块链的数据处理方法及装置 WO2020224380A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910379418.0A CN110191156B (zh) 2019-05-08 2019-05-08 一种基于区块链的数据处理方法及装置
CN201910379418.0 2019-05-08

Publications (1)

Publication Number Publication Date
WO2020224380A1 true WO2020224380A1 (zh) 2020-11-12

Family

ID=67714246

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/084319 WO2020224380A1 (zh) 2019-05-08 2020-04-10 一种基于区块链的数据处理方法及装置

Country Status (2)

Country Link
CN (1) CN110191156B (zh)
WO (1) WO2020224380A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113094125A (zh) * 2021-04-21 2021-07-09 矢量云科信息科技(无锡)有限公司 业务流程处理方法、装置、服务器及存储介质

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110191156B (zh) * 2019-05-08 2021-11-09 深圳前海微众银行股份有限公司 一种基于区块链的数据处理方法及装置
CN114553887B (zh) * 2022-01-24 2024-04-05 浙江数秦科技有限公司 一种区块链网络点对点数据传输方法

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1881633A1 (en) * 2005-03-30 2008-01-23 NTT DoCoMo Inc. Data transmission method, data transmission system, transmitting method, receiving method, transmitting apparatus and receiving apparatus
CN101163145A (zh) * 2007-11-13 2008-04-16 华为技术有限公司 一种传输数据包的方法及装置和协商密钥的方法
CN105812335A (zh) * 2014-12-31 2016-07-27 上海数字电视国家工程研究中心有限公司 功能字段的插入方法及解析方法
CN108228912A (zh) * 2018-02-12 2018-06-29 浙江中控技术股份有限公司 一种业务数据的处理方法及相关装置
CN110191156A (zh) * 2019-05-08 2019-08-30 深圳前海微众银行股份有限公司 一种基于区块链的数据处理方法及装置

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101848148B (zh) * 2010-04-21 2012-11-21 中国工商银行股份有限公司 应用于金融报文语言的数据传输处理系统、装置及方法
CN102790694A (zh) * 2011-05-20 2012-11-21 中兴通讯股份有限公司 网元管理层消息组织方法和装置
CN103389992A (zh) * 2012-05-09 2013-11-13 北京百度网讯科技有限公司 一种结构化数据存储方法及装置
US20160316045A1 (en) * 2015-04-24 2016-10-27 Freescale Semiconductor, Inc. Method for Coding Packet Classification Key Composition Rules Using Variable Length Commands
CN107657438B (zh) * 2017-09-18 2020-12-04 联动优势科技有限公司 一种区块链生成方法、数据验证方法、节点及系统

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1881633A1 (en) * 2005-03-30 2008-01-23 NTT DoCoMo Inc. Data transmission method, data transmission system, transmitting method, receiving method, transmitting apparatus and receiving apparatus
CN101163145A (zh) * 2007-11-13 2008-04-16 华为技术有限公司 一种传输数据包的方法及装置和协商密钥的方法
CN105812335A (zh) * 2014-12-31 2016-07-27 上海数字电视国家工程研究中心有限公司 功能字段的插入方法及解析方法
CN108228912A (zh) * 2018-02-12 2018-06-29 浙江中控技术股份有限公司 一种业务数据的处理方法及相关装置
CN110191156A (zh) * 2019-05-08 2019-08-30 深圳前海微众银行股份有限公司 一种基于区块链的数据处理方法及装置

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113094125A (zh) * 2021-04-21 2021-07-09 矢量云科信息科技(无锡)有限公司 业务流程处理方法、装置、服务器及存储介质
CN113094125B (zh) * 2021-04-21 2023-12-22 上海弹业信息科技有限公司 业务流程处理方法、装置、服务器及存储介质

Also Published As

Publication number Publication date
CN110191156A (zh) 2019-08-30
CN110191156B (zh) 2021-11-09

Similar Documents

Publication Publication Date Title
WO2020224380A1 (zh) 一种基于区块链的数据处理方法及装置
CN110163609B (zh) 一种区块链中数据处理方法及装置
CN103559156B (zh) 一种fpga与计算机之间的通信系统
CN1997987A (zh) 用于在互连网络路由器内进行分组合并的方法和设备
WO2014173151A1 (en) Method, device and terminal for data processing
CN113396565A (zh) 一种控制方法及装置
CN112182036A (zh) 数据的发送与写入方法、装置、电子设备及可读存储介质
CN114885045B (zh) 一种在高速智能网卡/dpu内节约dma通道资源方法和装置
CN114020272A (zh) 一种序列化编码、解码方法、装置及电子设备
CN114117992B (zh) 一种序列化和反序列化方法、装置和电子设备
CN111259014B (zh) 一种fpga的单向链表数据存储方法及系统
CN117539807A (zh) 一种数据传输方法、相关设备及存储介质
CN109144853B (zh) 一种软件定义无线电SoC芯片调试系统
WO2023061180A1 (zh) 基于多频率的数据发送和接收方法、装置和设备
CN116467372A (zh) 一种数据库自动转换方法、装置、电子设备及存储介质
WO2020024392A1 (zh) 节点处理方法及装置、存储介质和电子设备
US20210034517A1 (en) Method, apparatus, device and computer-readable storage medium for storage management
CN109756550B (zh) 一种智能网联驾驶车云通信方法、装置以及系统
US20170109150A1 (en) Data compaction
CN111163100A (zh) 数据结构、通信方法、装置、存储介质及设备
CN113608703B (zh) 数据处理方法及装置
CN112764666B (zh) 用于存储管理的方法、设备和计算机程序产品
CN112015586B (zh) 一种数据重构计算的方法以及相关装置
CN115297169B (zh) 数据处理方法、装置、电子设备及介质
CN111343612B (zh) 一种物联网数据方法及系统

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20801433

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20801433

Country of ref document: EP

Kind code of ref document: A1

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 18/03/2022)

122 Ep: pct application non-entry in european phase

Ref document number: 20801433

Country of ref document: EP

Kind code of ref document: A1