Data processing method and apparatus
By sharding data and storing it on different nodes in a consortium blockchain and dynamically migrating it, the problems of wasted node storage space and insufficient security are solved, achieving more efficient storage and security.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA MOBILE QUANTONG SYST INTEGRATION CO LTD
- Filing Date
- 2022-01-20
- Publication Date
- 2026-06-19
Smart Images

Figure CN116521051B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of blockchain technology, specifically to a data processing method and apparatus. Background Technology
[0002] Blockchain technology is a decentralized distributed ledger technology composed of numerous nodes across the network, each possessing the complete ledger data. A consortium blockchain is a type of blockchain characterized by the requirement for authorization for nodes to join the network; the nodes are composed of trusted consortium members. Currently, in a consortium blockchain, each member can deploy several nodes, and all the nodes from all members collectively form the consortium blockchain network, where each node also possesses the complete ledger data.
[0003] This approach has two drawbacks: when a consortium member has multiple nodes, each node contains the full ledger, which wastes storage space; and because each node contains the full ledger, and the ledger data of the consortium blockchain is private to non-consortium members, a hacker can obtain the ledger data of all chains once they break into one of the nodes.
[0004] In existing technologies, a better solution is for blockchain to reduce storage space usage by setting up full nodes and light nodes. Full nodes keep the full ledger, while light nodes keep a portion of the ledger. Although this can improve storage space utilization to some extent, it has the following drawbacks: full nodes still occupy a lot of space because they store the full ledger data; secondly, the content stored by light nodes is all the same and is a subset of the content stored by full nodes, resulting in low space utilization; and thirdly, even if a full node is compromised, all ledger data can still be obtained. Summary of the Invention
[0005] This application provides a data processing method to address the technical problem of how to improve the security of data access to blockchain nodes.
[0006] Firstly, this application provides a data processing method, including:
[0007] The target data on the target consortium blockchain is sharded and stored in different data shards, and the shard number of the data shards is determined.
[0008] Based on preset migration rules, a number mapping table is determined between the node numbers of the target consortium chain and the region numbers;
[0009] Based on the number mapping table, determine the target node number corresponding to the area number;
[0010] Migrate the sharded data corresponding to the shard number to the data shard corresponding to the target node number;
[0011] The data segments correspond one-to-one with the nodes of the target consortium blockchain.
[0012] Optionally, migrating the sharded data corresponding to the shard number to the data shard corresponding to the target node number includes:
[0013] Copy the shard data corresponding to the shard number to the data shard corresponding to the target node number;
[0014] After copying is complete, delete the original data in the data segment corresponding to the target node number.
[0015] Optionally, the data processing method provided in this application further includes:
[0016] Based on the target time interval, the area numbers and node numbers in the number mapping table are randomly arranged, and the number mapping table is updated.
[0017] Optionally, storing the target data shards on the target consortium blockchain in different data shards includes:
[0018] The target state data and target block data on the target consortium blockchain are sharded according to the preset sharding rules, and the sharded data is then distributed and stored in different data shards.
[0019] Optionally, the step of sharding the target state data and target block data on the target consortium blockchain according to a preset sharding rule includes:
[0020] Based on the remainder operation rules, determine the remainder result of the target state data and the target block data;
[0021] Based on the remainder result, the data segment for storing the target state data and the target block data is determined.
[0022] Secondly, this application provides a data processing apparatus, comprising:
[0023] The sharding module is used to shard the target data on the target consortium blockchain and store it in different data shards, and to determine the shard number of the data shards.
[0024] The first determining module is used to determine the number mapping table between the node number of the target consortium chain and the area number according to the preset migration rules;
[0025] The second determining module is used to determine the target node number corresponding to the area number based on the number mapping table;
[0026] The migration module is used to migrate the sharded data corresponding to the shard number to the data shard corresponding to the target node number;
[0027] The data segments correspond one-to-one with the nodes of the target consortium blockchain.
[0028] Optionally, the migration module is specifically used for:
[0029] Copy the shard data corresponding to the shard number to the data shard corresponding to the target node number;
[0030] After copying is complete, delete the original data in the data segment corresponding to the target node number.
[0031] Optionally, the data processing apparatus provided in this application further includes:
[0032] An update module is used to randomly arrange the area numbers and node numbers in the number mapping table according to a target time interval, and update the number mapping table.
[0033] Thirdly, this application provides an electronic device including a processor and a memory storing a computer program, wherein the processor executes the program to implement the steps of the data processing method described in the first aspect.
[0034] Fourthly, this application provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the data processing method described in the first aspect.
[0035] The data processing method, apparatus, electronic device, and computer-readable storage medium provided in this application improve the security of data access on consortium blockchain architecture nodes by storing target data in fragments on different nodes. This prevents attackers from obtaining the full ledger data by compromising a single node. Furthermore, by migrating the fragmented data, attackers cannot determine which node stores data on a particular critical chain, thus hindering targeted attacks. In addition, storing target data in fragments on different nodes improves the utilization rate of storage space on consortium blockchain architecture nodes. Attached Figure Description
[0036] To more clearly illustrate the technical solutions in this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0037] Figure 1 This is a flowchart illustrating the data processing method provided in an embodiment of this application;
[0038] Figure 2 This is a schematic diagram of a single alliance member node architecture provided in an embodiment of this application;
[0039] Figure 3 This is a schematic diagram of the structure of the data processing apparatus provided in the embodiments of this application;
[0040] Figure 4 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0041] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings of the embodiments. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0042] Figure 1 This is a schematic flowchart illustrating the data processing method provided in an embodiment of this application. (Refer to...) Figure 1 The data processing method provided in this application embodiment may include:
[0043] Step 110: Divide the target data on the target consortium blockchain into fragments and store them in different data fragment areas, and determine the fragment area number of each data fragment area;
[0044] Step 120: Determine the number mapping table between the node number and the area number of the target consortium chain according to the preset migration rules;
[0045] Step 130: Determine the target node number corresponding to the area number based on the number mapping table;
[0046] Step 140: Migrate the sharded data corresponding to the shard number to the data shard corresponding to the target node number;
[0047] Each data segment corresponds one-to-one with a node in the target consortium blockchain.
[0048] It should be noted that the execution subject of the data processing method provided in this application embodiment can be an electronic device, a component in an electronic device, an integrated circuit, or a chip. The electronic device can be a mobile electronic device or a non-mobile electronic device. For example, a mobile electronic device can be a mobile phone, tablet computer, laptop computer, PDA, in-vehicle electronic device, wearable device, ultra-mobile personal computer (UMPC), netbook, or personal digital assistant (PDA), etc., while a non-mobile electronic device can be a server, network attached storage (NAS), personal computer (PC), television (TV), ATM, or self-service machine, etc., and this application does not make specific limitations.
[0049] Optionally, in step 110, the target data shards on the target consortium blockchain are stored in different data shards, and the shard number of the data shards is determined.
[0050] The internal deployment architecture of a consortium blockchain member is generally a multi-node model. The ledger contains state data (key-value pairs) and block data (continuous transaction information). The target data on the consortium blockchain is sharded according to preset sharding rules. The sharded target data is then distributed across different shards, each stored on a different node, with a one-to-one correspondence between shards and nodes. Each data shard is assigned a number, such as shard 1, shard 2, shard 3, ..., shard n.
[0051] Since each node only stores a portion of the ledger data, but the sum of all node data constitutes the full ledger data, the ledger storage space is reduced compared to the traditional full-node architecture.
[0052] In step 120, a number mapping table between the node number and the area number of the target consortium chain is determined according to the preset migration rules.
[0053] Each node in the consortium blockchain is sequentially numbered, such as node 1, node 2, node 3, ..., node n. According to preset migration rules, node numbers correspond one-to-one with region numbers, and a number mapping table is formed by mapping node numbers to region numbers.
[0054] For example, when n=5, the number mapping table determined according to the preset migration rules is shown in Table 1:
[0055] Table 1 Number Mapping Table
[0056] Node number Area Number Node 1 Area 2 Node 2 Area 4 Node 3 Area 5 Node 4 Area 3 Node 5 Area 1
[0057] In step 130, the target node number corresponding to the area number is determined according to the number mapping table.
[0058] Since there is a one-to-one correspondence between area numbers and node numbers in the number mapping table, for each area number, the corresponding target node number can be found by querying the number mapping table.
[0059] In step 140, the fragmented data corresponding to the fragment number is migrated to the data fragment corresponding to the target node number.
[0060] Once the node number corresponding to the area number is determined, the sharded data corresponding to the area number can be migrated to the data area corresponding to the target node number, which means changing the storage location of the sharded data.
[0061] For example, according to the number mapping table in Table 1, the target node number corresponding to region 1 is node 5. Therefore, the sharded data corresponding to region 1 is migrated to the data region corresponding to node 5. Similarly, the sharded data corresponding to region 2 is migrated to the data region corresponding to node 1; the sharded data corresponding to region 3 is migrated to the data region corresponding to node 4; the sharded data corresponding to region 4 is migrated to the data region corresponding to node 2; and the sharded data corresponding to region 5 is migrated to the data region corresponding to node 3. By migrating all the sharded data corresponding to all region numbers to the data region corresponding to the node numbers, a complete sharded data migration process is completed.
[0062] The data processing method provided in this application improves the security of data access on consortium blockchain architecture nodes by storing target data in shards on different nodes. This prevents attackers from obtaining the full ledger data by compromising a single node. Furthermore, by migrating the sharded data, attackers cannot determine which node stores data on a critical chain, thus hindering targeted attacks. In addition, storing target data in shards on different nodes improves the utilization rate of storage space on consortium blockchain architecture nodes.
[0063] In one embodiment, migrating the shard data corresponding to the shard number to the data shard corresponding to the target node number includes:
[0064] Copy the shard data corresponding to the shard number to the data shard corresponding to the target node number;
[0065] After copying is complete, delete the original data in the data segment corresponding to the target node number.
[0066] Optionally, the process of migrating the sharded data corresponding to shard 1 to the data shard corresponding to Node 5 can be as follows: copy the sharded data corresponding to shard 1 to the data shard corresponding to Node 5, and after the copying is completed, delete the original data in the data shard corresponding to Node 5.
[0067] Understandably, based on the number mapping table, all the data corresponding to each shard number is copied to the data shard of the corresponding target node number, and then the original data in the data shard of the target node number is deleted. That is, for each node, it is a synchronous incremental process. Each node's data shard will gradually form two sets of data. After all the data is copied, the original data is deleted, completing one data migration process.
[0068] The data processing method provided in this application embodiment gradually forms two sets of data on each node through a synchronous incremental process. After the replication is completed, the original data on the node is deleted to ensure the security of data migration.
[0069] In one embodiment, the data processing method provided in this application further includes:
[0070] Based on the target time interval, the area numbers and node numbers in the numbering mapping table are randomly arranged, and the numbering mapping table is updated.
[0071] Optionally, the target time interval can be 24h, 36h, 48h, etc., and its specific value can be adjusted according to actual needs. This application does not limit this. That is, the number mapping table will be updated once every certain period of time, which means that the data will be automatically migrated once every certain period of time.
[0072] By constructing migration intervals based on time units and randomly arranging the region numbers and node numbers in the existing numbering mapping table, a new region-node numbering mapping table can be generated. Based on the newly generated numbering mapping table, the node number corresponding to the region number can be found, which is the node number after migration. Then, the fragmented data in the data region corresponding to the region number can be migrated to the data region corresponding to the node number.
[0073] For example, Table 2 is the updated number mapping table:
[0074] Table 2 Updated Number Mapping Table
[0075] Node number Area Number Node 1 Area 3 Node 2 Area 5 Node 3 Area 4 Node 4 Area 1 Node 5 Area 2
[0076] Referring to Table 2, the node number after migration can be determined. For example, the node number corresponding to region 1 is node 4, meaning the node number after migration is 4, that is, the sharded data corresponding to region 1 is migrated to the data region corresponding to node 4.
[0077] The dynamic migration process provided in this application embodiment is described below with reference to a specific scenario. The specific steps are as follows:
[0078] Step 1: The migration rules define the migration interval, such as 24 hours, meaning that the data will be dynamically migrated once every 24 hours.
[0079] Step 2: In each migration, a Leader will be responsible for generating a new number mapping table among the peer nodes. The leader uses a round-robin mechanism, that is, it starts as peer0, becomes peer1 after one round of migration, and so on. When the last peer finishes serving as leader, it starts again from peer0.
[0080] Step 3: Integrate a timer in the peer node. When the migration time is up, the leader is responsible for generating a new number mapping table using a random order algorithm, and then sending the number mapping table to other non-leader nodes.
[0081] Step 4: After receiving the data, other nodes broadcast the hash of the number mapping table they received. After confirming that it matches the one sent by the leader, they begin to synchronize the data.
[0082] Step 5: At this point, in order not to affect the execution of the transaction, the synchronization process is incremental synchronization, that is, two sets of state databases and block databases will gradually be formed on a certain node.
[0083] Step 6: Since the synchronization process only involves data copying, this process is often very fast. Therefore, the synchronization speed is much faster than the block generation speed. When the peer node calculates that the remaining blocks are less than a certain threshold by comparing the amount of synchronized data, for example, when only 10 blocks are not synchronized, the peer node will suspend accepting new transactions.
[0084] Step 7: The peer node will synchronize the remaining state data and block data, then update the migration rules according to the new data distribution, delete the previous local state database and block database, and then resume providing services.
[0085] Step 8: After one round of migration, the data of the peer nodes will be updated, and then the next round of ledger migration will begin.
[0086] The data processing method provided in this application randomly arranges the existing number mapping table at a target time interval to form a new number mapping table. Nodes synchronize their shard data with each other based on the newly generated number mapping table. Dynamically migrating shard data ensures that the specific storage location of a block or state data is constantly changing, further improving the security of ledger data. Furthermore, the dynamic migration function prevents attackers from knowing which node stores data on a critical chain, thus preventing targeted attacks and enhancing the security of data access to consortium blockchain architecture nodes.
[0087] In one embodiment, storing target data shards on the target consortium blockchain in different data shards includes:
[0088] The target state data and target block data on the target consortium blockchain are sharded according to the preset sharding rules, and the sharded data is then distributed and stored in different data shards.
[0089] Optionally, the target data on a consortium blockchain includes state data (key-value pairs) and block data (continuous transaction information). State data records the current state of each account and smart contract, while block data records every transaction that occurs on the blockchain. Both block data and state data are used and stored by blockchain nodes. A blockchain node is a program that can be accessed on our computers, virtual machines, etc., and multiple nodes are linked together through a network to ultimately form a complete blockchain network.
[0090] By sharding the target state data and target block data according to the preset sharding rules, the sharded target data will be distributed into different shards, and each shard will be stored on a different node.
[0091] The data processing method provided in this application embodiment can save block storage space for consortium blockchain members with multiple nodes by using storage sharding. Assuming the total ledger data size is m and the number of nodes is n, the original storage requirement was m*n, but now only m storage is needed, thus improving the storage space utilization of the consortium blockchain architecture nodes.
[0092] In one embodiment, the target state data and target block data on the target consortium blockchain are sharded according to a preset sharding rule, including:
[0093] Based on the remainder operation rules, determine the remainder results of the target state data and the target block data;
[0094] Based on the remainder result, determine the data segment for storing the target state data and the target block data.
[0095] Optionally, a remainder node rule can be used to determine the status and which node the block data is on based on the remainder result.
[0096] For example, a hash algorithm is applied to the keys of key-value pairs in the state data, and then the remainder is taken from a certain number. The state and the node where the block data is located are determined based on the remainder result. After sharding, the state data will be distributed across different shards. Similarly, block data can be sharded in a similar way, and the data will also be distributed across different shards.
[0097] Each shard is stored on a different node, with a one-to-one correspondence between shards and nodes. Since each node only stores a portion of the ledger data (state data and block data), but the sum of all node data constitutes the full ledger data, the ledger storage space is reduced compared to the traditional full-node architecture.
[0098] The data processing method provided in this application embodiment calculates the segment number by using the modulo operation rule and the segmentation rule, and stores the target data in segments on different nodes, which can save block storage space for consortium blockchain members that deploy multiple nodes.
[0099] Figure 2 This is a schematic diagram of a single alliance member node architecture provided in an embodiment of this application, for reference. Figure 2 The data methods provided in the embodiments of this application will be described in detail.
[0100] A consortium blockchain consists of several consortium members, each deploying several of their own nodes. When the number of nodes is greater than one, this sharding scheme can be used. A single node server consists of smart contracts and peer nodes. Peer nodes are further divided into a peer logic layer, a sharding layer, a state database, and a block database.
[0101] The peer logic layer is responsible for communicating with the smart contract layer. Smart contracts retrieve blockchain state data using get and set methods, and are unaware of sharding. The peer logic layer forwards smart contract requests for state access to the sharding layer and is also responsible for transaction signature verification. The sharding layer is primarily responsible for loading sharding rules, routing state and block data through shards, and establishing the sharding rules, which include the state data key and the rules and algorithms for sharding block data, covering all nodes.
[0102] The sharding rules use a modulo node count rule to determine the state and the node where the block data resides based on the modulo result. However, in practice, sharding rules must be used in conjunction with migration rules because migration rules regenerate a new set of node mappings. Migration rules define the rules for node data flow based on sharding rules. The data on each node is not static but migrates according to certain rules. After migration, the sharded data of a node is no longer the same as before. Migration rules consist of a time interval and a node mapping table. The time interval indicates how often data is migrated, and the node mapping table is used to find the actual node number after the data migration, after the nodes are calculated according to the sharding rules. The state database and block database store the sharded state data and block data, respectively.
[0103] The application of the data processing method provided in this embodiment is explained in detail below. When a transaction is initiated on the blockchain, the specific transaction process is as follows:
[0104] Step 1: The transaction is initiated by the client and sent to a peer node in a certain alliance member.
[0105] Step 2: Peer nodes verify the legality of the transaction and then invoke the smart contract.
[0106] Step 3: The smart contract will access the state database through the interface layer's get / put(key,value) methods, and the interface layer will send the request to the peer node.
[0107] Step 3.1: The peer node sends the request to the sharding layer, which is also a module in the peer.
[0108] Step 3.2: The sharding layer calculates the initial node number through the sharding rules, and then obtains the node number after migration according to the number mapping table in the migration rules.
[0109] Step 3.3: After obtaining the real node number, the node forwards the request to the corresponding node server. The corresponding node server queries its own state database to obtain the corresponding state data, and then returns the state data to the requesting node.
[0110] Step 4: The requesting node peer returns to the smart contract. After a series of processes, a state read / write set is generated. The peer node signs the read / write set and returns it to the client.
[0111] Step 5: The client encapsulates the received read / write set results into a transaction and sends it to the sorting service.
[0112] Step 6: The sorting service sorts the collected transactions, packages them into blocks, and sends the blocks to each peer node.
[0113] Step 7: Peer nodes determine whether they need to retain the block based on the sharding and migration rules.
[0114] Step 8: Peer nodes that need to retain the block should decrypt the transaction and verify the validity of the transaction signatures, and then verify the read and write sets in sequence.
[0115] Step 9: When verifying the read / write set, the system will compare the state data with the corresponding state database nodes according to the sharding and migration rules, and then determine the legality of the transaction.
[0116] Step 10: After the transactions for a final block have been verified, a set of updated state databases is generated. This node applies the state updates from the set to the state databases of all other nodes. At this point, the complete lifecycle of a transaction ends.
[0117] By applying the data processing method provided in this application, storage sharding allows consortium blockchain members deploying multiple nodes to save block storage space. Dynamic migration of sharded data ensures that the specific storage location of a block or state data continuously changes, improving the security of ledger data. The data processing method provided in this application can enhance the data security of the underlying blockchain platform, solve data security issues in blockchain applications in related fields, and meet customer needs for blockchain security.
[0118] The data processing apparatus provided in the embodiments of this application is described below. The data processing apparatus described below and the data processing method described above can be referred to in correspondence.
[0119] Figure 3 This is a schematic diagram of the structure of the data processing apparatus provided in the embodiments of this application, with reference to... Figure 3 The data processing apparatus provided in this application embodiment may include:
[0120] Sharding module 310 is used to shard the target data on the target consortium blockchain and store it in different data shards, and to determine the shard number of the data shards.
[0121] The first determining module 320 is used to determine the number mapping table between the node number and the area number of the target consortium chain according to the preset migration rules;
[0122] The second determining module 330 is used to determine the target node number corresponding to the area number according to the number mapping table;
[0123] Migration module 340 is used to migrate the sharded data corresponding to the shard number to the data shard corresponding to the target node number;
[0124] Each data segment corresponds one-to-one with a node in the target consortium blockchain.
[0125] The data processing apparatus provided in this application improves the security of data access on consortium blockchain architecture nodes by storing target data in fragments on different nodes. This prevents attackers from obtaining the full ledger data by compromising a single node. Furthermore, by migrating the fragmented data, attackers cannot determine which node stores data on a critical chain, thus hindering targeted attacks. In addition, storing target data in fragments on different nodes improves the utilization rate of storage space on consortium blockchain architecture nodes.
[0126] In one embodiment, the migration module 340 is specifically used for:
[0127] Copy the shard data corresponding to the shard number to the data shard corresponding to the target node number;
[0128] After copying is complete, delete the original data in the data segment corresponding to the target node number.
[0129] In one embodiment, the data processing apparatus provided in this application further includes:
[0130] The update module is used to randomly arrange the area numbers and node numbers in the number mapping table according to the target time interval, and update the number mapping table.
[0131] In one embodiment, storing target data shards on the target consortium blockchain in different data shards includes:
[0132] The target state data and target block data on the target consortium blockchain are sharded according to the preset sharding rules, and the sharded data is then distributed and stored in different data shards.
[0133] In one embodiment, the target state data and target block data on the target consortium blockchain are sharded according to a preset sharding rule, including:
[0134] Based on the remainder operation rules, determine the remainder results of the target state data and the target block data;
[0135] Based on the remainder result, determine the data segment for storing the target state data and the target block data.
[0136] Figure 4 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 4As shown, the electronic device may include a processor 410, a communication interface 420, a memory 430, and a communication bus 440, wherein the processor 410, the communication interface 420, and the memory 430 communicate with each other via the communication bus 440. The processor 410 can call a computer program stored in the memory 430 to execute the steps of a data processing method, such as including:
[0137] The target data on the target consortium blockchain is sharded and stored in different data shards, and the shard number of each data shard is determined.
[0138] Based on the preset migration rules, determine the number mapping table between the node number and the area number of the target consortium chain;
[0139] Based on the number mapping table, determine the target node number corresponding to the area number;
[0140] Migrate the sharded data corresponding to the shard number to the data shard corresponding to the target node number;
[0141] Each data segment corresponds one-to-one with a node in the target consortium blockchain.
[0142] Furthermore, the logical instructions in the aforementioned memory 430 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0143] On the other hand, embodiments of this application also provide a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can perform the steps of the data processing methods provided in the above embodiments, such as including:
[0144] The target data on the target consortium blockchain is sharded and stored in different data shards, and the shard number of each data shard is determined.
[0145] Based on the preset migration rules, determine the number mapping table between the node number and the area number of the target consortium chain;
[0146] Based on the number mapping table, determine the target node number corresponding to the area number;
[0147] Migrate the sharded data corresponding to the shard number to the data shard corresponding to the target node number;
[0148] Each data segment corresponds one-to-one with a node in the target consortium blockchain.
[0149] On the other hand, embodiments of this application also provide a processor-readable storage medium storing a computer program for causing a processor to execute the steps of the data processing methods provided in the above embodiments, such as including:
[0150] The target data on the target consortium blockchain is sharded and stored in different data shards, and the shard number of each data shard is determined.
[0151] Based on the preset migration rules, determine the number mapping table between the node number and the area number of the target consortium chain;
[0152] Based on the number mapping table, determine the target node number corresponding to the area number;
[0153] Migrate the sharded data corresponding to the shard number to the data shard corresponding to the target node number;
[0154] Each data segment corresponds one-to-one with a node in the target consortium blockchain.
[0155] The processor-readable storage medium can be any available medium or data storage device that the processor can access, including but not limited to magnetic memory (e.g., floppy disk, hard disk, magnetic tape, magneto-optical disk (MO)), optical memory (e.g., CD, DVD, BD, HVD), and semiconductor memory (e.g., ROM, EPROM, EEPROM, non-volatile memory (NAND FLASH), solid-state drive (SSD)).
[0156] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0157] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0158] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A data processing method, characterized by, include: The target data on the target consortium blockchain is sharded and stored in different data shards, and the shard number of the data shards is determined. Based on preset migration rules, a number mapping table is determined between the node numbers of the target consortium chain and the region numbers; Based on the number mapping table, determine the target node number corresponding to the area number; Migrate the sharded data corresponding to the shard number to the data shard corresponding to the target node number; The data segments correspond one-to-one with the nodes of the target consortium blockchain.
2. The data processing method according to claim 1, characterized in that, The step of migrating the sharded data corresponding to the region number to the data region corresponding to the target node number includes: Copy the shard data corresponding to the shard number to the data shard corresponding to the target node number; After copying is complete, delete the original data in the data segment corresponding to the target node number.
3. The data processing method of claim 1, wherein, Also includes: Based on the target time interval, the area numbers and node numbers in the number mapping table are randomly arranged, and the number mapping table is updated.
4. The data processing method according to any one of claims 1 to 3, characterized in that, The step of storing the target data on the target consortium blockchain in different data shards includes: The target state data and target block data on the target consortium blockchain are sharded according to the preset sharding rules, and the sharded data is then distributed and stored in different data shards.
5. The data processing method according to claim 4, characterized in that, The step of sharding the target state data and target block data on the target consortium blockchain according to a preset sharding rule includes: Based on the remainder operation rules, determine the remainder result of the target state data and the target block data; Based on the remainder result, the data segment for storing the target state data and the target block data is determined.
6. A data processing apparatus, characterized by, include: The sharding module is used to shard the target data on the target consortium blockchain and store it in different data shards, and to determine the shard number of the data shards. The first determining module is used to determine the number mapping table between the node number of the target consortium chain and the area number according to the preset migration rules; The second determining module is used to determine the target node number corresponding to the area number based on the number mapping table; The migration module is used to migrate the sharded data corresponding to the shard number to the data shard corresponding to the target node number; The data segments correspond one-to-one with the nodes of the target consortium blockchain.
7. The data processing apparatus according to claim 6, characterized in that, The migration module is specifically used for: Copy the shard data corresponding to the shard number to the data shard corresponding to the target node number; After copying is complete, delete the original data in the data segment corresponding to the target node number.
8. The data processing apparatus according to claim 7, characterized in that, Also includes: An update module is used to randomly arrange the area numbers and node numbers in the number mapping table according to a target time interval, and update the number mapping table.
9. An electronic device comprising a processor and a memory having a computer program stored therein, characterized in that, When the processor executes the computer program, it implements the steps of the data processing method according to any one of claims 1 to 5.
10. A non-transitory computer-readable storage medium having stored thereon a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the data processing method as described in any one of claims 1 to 5.