CN111475572A - Block generation method, device, equipment and medium - Google Patents
Block generation method, device, equipment and medium Download PDFInfo
- Publication number
- CN111475572A CN111475572A CN202010254531.9A CN202010254531A CN111475572A CN 111475572 A CN111475572 A CN 111475572A CN 202010254531 A CN202010254531 A CN 202010254531A CN 111475572 A CN111475572 A CN 111475572A
- Authority
- CN
- China
- Prior art keywords
- block
- parallel
- basic
- transaction data
- current
- Prior art date
- Legal status (The legal status 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 status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 65
- 238000012545 processing Methods 0.000 claims abstract description 36
- 230000015654 memory Effects 0.000 claims description 24
- 230000008569 process Effects 0.000 claims description 20
- 238000010276 construction Methods 0.000 claims description 15
- 238000012544 monitoring process Methods 0.000 claims description 6
- 238000004364 calculation method Methods 0.000 claims description 5
- 230000007246 mechanism Effects 0.000 claims description 4
- 238000013500 data storage Methods 0.000 abstract description 7
- 238000005516 engineering process Methods 0.000 abstract description 3
- 238000010586 diagram Methods 0.000 description 10
- 230000003071 parasitic effect Effects 0.000 description 8
- 230000002452 interceptive effect Effects 0.000 description 6
- 230000003993 interaction Effects 0.000 description 5
- 230000006870 function Effects 0.000 description 4
- 238000004422 calculation algorithm Methods 0.000 description 3
- 238000004590 computer program Methods 0.000 description 3
- 238000012986 modification Methods 0.000 description 3
- 230000004048 modification Effects 0.000 description 3
- 239000003999 initiator Substances 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000001413 cellular effect Effects 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 239000013078 crystal Substances 0.000 description 1
- 230000001419 dependent effect Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000005286 illumination Methods 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 238000010295 mobile communication Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000012856 packing Methods 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 238000012795 verification Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/27—Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/22—Indexing; Data structures therefor; Storage structures
- G06F16/2228—Indexing structures
- G06F16/2255—Hash tables
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/60—Protecting data
- G06F21/64—Protecting data integrity, e.g. using checksums, certificates or signatures
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Software Systems (AREA)
- Computer Security & Cryptography (AREA)
- Health & Medical Sciences (AREA)
- Bioethics (AREA)
- General Health & Medical Sciences (AREA)
- Computer Hardware Design (AREA)
- Computing Systems (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The embodiment of the application discloses a block generation method, a block generation device, block generation equipment and a block generation medium, and relates to a block chain technology. Wherein, the method comprises the following steps: processing the basic transaction request in the basic block chain to obtain basic transaction data, and processing the parallel transaction request in the parallel block chain to obtain parallel transaction data; constructing a current parallel block according to the parallel transaction data; and constructing the current basic block according to the basic transaction data, the parallel transaction data and the current parallel block. According to the method and the device, the block data storage mode under the multi-chain scene can be optimized.
Description
Technical Field
The present application relates to computer technologies, and in particular, to a block chain technology, and in particular, to a block generation method, apparatus, device, and medium.
Background
Currently, in terms of block data storage, an independent database is usually set for each block chain, so as to store block data, that is, the account book and the state of each chain are stored separately.
However, as the number of blockchains deployed at blockchain link points increases, the number of databases increases, and the consumption of memory space for blockchain nodes is very large. This also limits the number of blockchains that can be deployed on a blockchain node in cases where memory space is limited.
Disclosure of Invention
The embodiment of the application discloses a block generation method, a block generation device, a block generation equipment and a block generation medium, which are used for optimizing a block data storage mode under a multi-chain scene.
In a first aspect, an embodiment of the present application discloses a block generation method, which is applied to a block chain node, where a basic block chain and a parallel block chain are deployed on the block chain node, and the method includes:
processing the basic transaction request in the basic block chain to obtain basic transaction data, and processing the parallel transaction request in the parallel block chain to obtain parallel transaction data;
constructing a current parallel block according to the parallel transaction data;
and constructing a current basic block according to the basic transaction data, the parallel transaction data and the current parallel block.
In a second aspect, an embodiment of the present application discloses a block generation apparatus configured at a block chain node, where a basic block chain and a parallel block chain are deployed at the block chain node, the apparatus including:
the transaction data determining module is used for processing the basic transaction request in the basic block chain to obtain basic transaction data and processing the parallel transaction request in the parallel block chain to obtain parallel transaction data;
the parallel block construction module is used for constructing a current parallel block according to the parallel transaction data;
and the basic block building module is used for building a current basic block according to the basic transaction data, the parallel transaction data and the current parallel block.
In a third aspect, an embodiment of the present application further discloses an electronic device, including:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform a block generation method according to any of the embodiments of the present application.
In a fourth aspect, this application further discloses a non-transitory computer-readable storage medium storing computer instructions for causing a computer to execute the block generation method according to any one of the embodiments of the application.
According to the technical scheme of the embodiment of the application, for the condition that the basic block chain and the parallel block chain are simultaneously deployed on the block chain node, the block data storage mode under the multi-chain scene is optimized by nesting the current parallel block in the current basic block, so that even if the number of the block chains deployed on the block chain node is increased, the number of the bottom-layer databases is not required to be increased, the cost of newly creating the block chain on the block chain node is reduced, and the number of the block chains which can be deployed on each block chain node can also get rid of the limitation of storage space.
It should be understood that the statements in this section do not necessarily identify key or critical features of the embodiments of the present application, nor do they limit the scope of the present application. Other features of the present application will become apparent from the following description.
Drawings
The drawings are included to provide a better understanding of the present solution and are not intended to limit the present application. Wherein:
fig. 1 is a schematic structural diagram of a blockchain network according to an embodiment of the present disclosure;
FIG. 2 is a flow chart of a block generation method disclosed in accordance with an embodiment of the present application;
FIG. 3 is a block chain structure according to an embodiment of the present disclosure;
fig. 4 is a flowchart of another block generation method disclosed in an embodiment of the present application;
FIG. 5 is a block diagram according to an embodiment of the present disclosure;
fig. 6 is a schematic structural diagram of a block generation apparatus according to an embodiment of the present application;
fig. 7 is a block diagram of an electronic device disclosed according to an embodiment of the present application.
Detailed Description
The following description of the exemplary embodiments of the present application, taken in conjunction with the accompanying drawings, includes various details of the embodiments of the application for the understanding of the same, which are to be considered exemplary only. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the present application. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Fig. 1 is a schematic structural diagram of a blockchain network according to an embodiment of the present disclosure. The network structure shown in fig. 1 is only used for illustrating the embodiments of the present application, and should not be understood as a specific limitation to the embodiments of the present application. The number of nodes participating in the blockchain network may be determined according to requirements. Fig. 1 shows, as an example, a block chain network structure diagram including 3 block chain nodes. A base blockchain and at least one parallel blockchain may be deployed on each blockchain node. The basic blockchain may also be referred to as a parent blockchain or a master blockchain, and the parallel blockchain may also be referred to as a sub-blockchain. Based on the division of the service processing requirement, the basic block chain and the parallel block chain may be used to process different service logics, and the specific division of the basic block chain and the parallel block chain is not specifically limited in the embodiments of the present application. In addition, for different block chain nodes, except that basic block chains need to be deployed, parallel block chains to be deployed may be selected according to actual conditions, that is, the number of parallel block chains deployed at each block chain link point may be the same or different.
Optionally, in this embodiment of the present application, the same consensus mechanism may be deployed on the basic block chain and the parallel block chain, and there may be no independent consensus algorithm on the parallel block chain, that is, the excavated blocks of the parallel block chain may reuse miners of the basic block chain, so as to ensure that the same block chain link point may generate a block based on transaction data on multiple chains at the same time.
Fig. 2 is a flowchart of a block generation method disclosed in an embodiment of the present application, which may be applied to a case how to pack blocks when a plurality of block chains are simultaneously deployed on a block chain node, for example, when a base block chain and at least one parallel block chain are deployed at the same time. The method disclosed in the embodiments of the present application may be performed by a block generation apparatus, which may be implemented by software and/or hardware and may be configured in a block chain node. Blockchain nodes may be deployed on any electronic device having computing capabilities.
As shown in fig. 2, the block generation method disclosed in the embodiment of the present application may include:
s101, processing the basic transaction request in the basic block chain to obtain basic transaction data, and processing the parallel transaction request in the parallel block chain to obtain parallel transaction data.
The basic transaction request can be any transaction request initiated by any initiator and transmitted in the basic block chain, and the parallel transaction request can be any transaction request initiated by any initiator and transmitted in the parallel block chain. The types of transaction requests handled by native nodes (i.e., referring to blockchain nodes currently used to perform methods of embodiments of the present application) include, but are not limited to, transaction requests based on smart contracts. When the transaction requests exist in both the basic block chain and the at least one parallel block chain, the local node needs to process the transaction requests to obtain corresponding transaction data.
Optionally, processing the basic transaction request in the basic block chain to obtain basic transaction data, and processing the parallel transaction request in the parallel block chain to obtain parallel transaction data includes:
monitoring whether a parallel transaction request in a parallel block chain exists on a local node in the process of processing a basic transaction request in the basic block chain to obtain basic transaction data;
and if so, processing the parallel transaction request in the parallel block chain to obtain parallel transaction data. That is, in the process of executing the basic transaction request, the local node may utilize a monitoring program pre-deployed in the block chain network to monitor at least one parallel block chain, so as to determine whether a parallel transaction request to be processed exists in the at least one parallel block chain, and if it is currently monitored that a target parallel block chain of the parallel transaction request to be processed exists, the parallel transaction request in the target parallel block chain is processed to obtain parallel transaction data, thereby avoiding missing transaction data in the parallel block chain in the process of generating the current block. If the existence of the target parallel block chain of the parallel transaction request to be processed is not monitored currently, parallel transaction data does not need to be used in the process of generating the current block.
And S102, constructing the current parallel block according to the parallel transaction data.
S103, constructing a current basic block according to the basic transaction data, the parallel transaction data and the current parallel block.
In order to ensure the logical integrity of each chain and the non-tamper-ability of data on multiple chains, during the block packing process, the local node may first generate at least one current parallel block based on parallel transaction data obtained by processing a parallel transaction request in at least one parallel block chain, and then use the at least one current parallel block in the generation process of the current basic block, thereby achieving the effect of placing the at least one current parallel block in the current basic block. Of course, in the process of generating the current parallel chunk, data related to the current parallel chunk, such as the chunk height of the current basic chunk and the hash value of the parallel transaction data, may also be flexibly selected for use in the chunk generating process, so as to further ensure the data association between the basic chunk and the parallel chunk and the uncollapsibility of the data. Different parallel block chains correspond to respective parallel blocks. Parallel blocks may also be referred to as sub-blocks, micro-blocks or dependent blocks with respect to the base block.
It should be noted that, in the process of constructing the current base block and the current parallel block, the generation of the current base block and the current parallel block may be respectively completed by adding other related block data, such as a block height, a timestamp, a block hash value, and the like, based on the existing transaction data by using a preset block generation policy. The block generation policy may be used to define the data required in the block generation process and the block structure. The data required in the block generation process can be flexibly adjusted according to the actual situation.
Because the current parallel block is parasitic or nested in the current basic block, only one database is needed to store the current basic block in the data storage layer, and the data in the basic block chain and the parallel block chain can be stored simultaneously. Every time a parallel block chain is added on a block chain node, only a few Key-Value pair (Key-Value) storage entries need to be added in an existing database, a database does not need to be newly built along with the increase of the number of the chains, and then a new parallel block chain can be created almost without cost.
Generally, a database is newly built, node memory and file handle overhead is large, for example, new folders, files and database instances all need to occupy more memory, by adopting the technical scheme of the embodiment of the application, the number of the database can be reduced, the number of block chains which can be deployed on each block chain node can be eliminated from the limitation of storage space, the problems that one chain corresponds to one database, the storage space of the block chain node is seriously occupied, and further the number of chains which can be supported on the block chain node is limited are solved, the number of block chains supported by each block chain node is larger, and the multi-core computing capability of a fully utilized processor is facilitated.
Meanwhile, according to the technical scheme of the embodiment of the application, data of a plurality of block chains can be stored in one database, namely the plurality of block chains can access the same database together, atomicity of cross-chain interaction operation is easier to realize, batch processing writing of the database can be completed, complex protocols such as Hash time lock and two-stage submission are not needed to realize when a plurality of databases exist in the bottom layer, and therefore the problems that cross-chain data interaction is difficult to realize and high in complexity when one chain corresponds to one database are solved.
Fig. 3 is a schematic diagram of a block chain structure according to an embodiment of the disclosure. Fig. 3 is intended as an example and should not be construed as a specific limitation on the embodiments of the present application. As shown in fig. 3, the parallel block a1 and the parallel block C1 are parasitic in one basic block at the same time, the parallel block a2 and the parallel block C2 are parasitic in different basic blocks, and the parallel block A3 and the parallel block C3 are parasitic in another basic block at the same time; a plurality of basic blocks may constitute one basic block chain structure, parallel blocks a1, a2, and A3 may constitute one parallel block chain structure, and parallel blocks C1, C2, and C3 may constitute another parallel block chain structure. As can also be seen from fig. 3, the number of parallel blocks included in each basic block may be different, that is, when there is a basic transaction request to be processed in a basic block chain, there may be no parallel transaction request or a partial parallel transaction request in at least one parallel block chain; the parallel blocks generated by the parallel transaction data need to be correspondingly parasitic in the current basic block according to the generation sequence of the current basic block.
Fig. 4 is a flowchart of another block generation method disclosed in an embodiment of the present application, which is further optimized and expanded based on the above technical solution, and can be combined with the above optional embodiments. As shown in fig. 4, the method may include:
s201, processing the basic transaction request in the basic block chain to obtain basic transaction data, and processing the parallel transaction request in the parallel block chain to obtain parallel transaction data.
S202, constructing the current parallel block according to the parallel transaction data.
The block comprises a block head and a block body, and data in the block head and the block body can be flexibly set. The native node may construct a block header and a block body, respectively, for the current parallel block based on the parallel transaction data. The block header of the current parallel block may include at least one of data such as a merkel root (Merkle root) of the current parallel block, a current parallel block ID (e.g., hash value), a hash value (prelash) of a previous parallel block, a current parallel block height, and a Timestamp (Timestamp); the block of current parallel blocks may include, but is not limited to, parallel transaction data. If one or more transaction requests form a transaction, the block may include, but is not limited to, transaction data and the like. Regarding the specific calculation manner of the mekerr root and the hash value, the present related algorithm may be adopted to implement, and the embodiment of the present application is not specifically limited.
Illustratively, constructing the current parallel block from the parallel transaction data includes:
calculating the Merkel root of the current parallel block according to the parallel transaction data;
and constructing a block header of the current parallel block according to the Merkel root of the current parallel block and the hash value of the previous parallel block, and taking the parallel transaction data as the block body of the current parallel block. The computation of the merkel root ensures that the parallel transaction data in the current block can not be tampered, and the current parallel block can point to the previous parallel block through the hash value of the previous parallel block, thereby ensuring that the parallel block chain is logically an independent and complete chain structure even if the parallel block is parasitic in the basic block.
S203, building a block head of the current basic block according to the basic transaction data and the parallel transaction data.
Since the parallel block is parasitic in the basic block, in order to ensure the non-tamper property of the data in the basic block chain and the parallel block chain, the block header of the current basic block is constructed based on both the basic transaction data and the parallel transaction data. The block header of the current basic block may include at least one of a merkel root (Merkle root) of the current basic block, a current basic block ID (e.g., hash value), a hash value (prelash) of a previous basic block, a current basic block height, a Timestamp (Timestamp), and the like. The specific calculation method of the merkel root and the hash value may be implemented by using an existing correlation algorithm, and the embodiment of the present application is not particularly limited.
Illustratively, constructing a block header for the current base block based on the base transaction data and the parallel transaction data includes:
calculating the Meckel root of the current basic block according to the basic transaction data and the parallel transaction data;
and constructing the block head of the current basic block according to the Merkel root of the current basic block and the hash value of the last basic block. The calculation of the merkel root ensures that the basic transaction data and the parallel transaction data in the current block are not able to be tampered, and the current basic block can be pointed to the previous basic block by the hash value of the previous basic block, thereby ensuring the logical integrity of the basic block chain.
And S204, constructing a block body of the current basic block according to the basic transaction data and the current parallel block.
The current parallel block is located in the current basic block, so that the local node can locally utilize one database to realize the simultaneous storage of the data in the basic block chain and the parallel block chain. In addition, there is no strict execution sequence limitation between the operation S203 and the operation S204, and the logic sequence shown in fig. 4 should not be understood as a specific limitation to the embodiment of the present application.
Fig. 5 is a schematic structural diagram of a block disclosed in an embodiment of the present application, which is taken as an example and should not be construed as a specific limitation to the embodiment of the present application. As shown in fig. 5, the current basic block 52 includes a block header 521 and a block body, and the block body includes a basic transaction data (or called transaction data) storage area 522, a first parallel block 53 and a second parallel block 54; the first parallel block 53 includes a block header 531 and a block body 532, where the block body 532 is used to store parallel transaction data obtained by processing a parallel transaction request in a parallel block chain a corresponding to the first parallel block 53; the second parallel block 54 includes a block header 541 and a block body 542, and the block body 542 is used for storing parallel transaction data obtained by processing a parallel transaction request in the parallel block chain B corresponding to the second parallel block 54. The first and second ones of the first and second parallel blocks 53 and 54 are not defined in any order, but are used only for the purpose of naming the distinction between the different parallel blocks.
In addition, after the local node generates the current basic block, the local node may sign the current basic block by using its own key, for example, a private key, and then transmit the signed current basic block to the block chain network for verification and storage by other block chain nodes. Since in the embodiment of the present application, the parallel block chains disposed on each block link point may be different, when the other block link points verify the basic block sent by the local node, and it is found that there is transaction data or transaction data that does not participate in or is not interested in the block of the basic block, the transaction data or transaction data may be discarded, that is, data in the block of the basic block is selectively stored, which is not specifically limited in the embodiment of the present application.
According to the technical scheme of the embodiment of the application, the current parallel block is constructed based on the parallel transaction data, then the block header of the current basic block is constructed according to the basic transaction data and the parallel transaction data, so that the non-tamper property of data on a basic block chain and a parallel block chain is ensured, the block body of the current basic block is constructed according to the basic transaction data and the current parallel block, and the current parallel block is parasitic in the block body of the current basic block. According to the method, the block data storage mode under the multi-chain scene is optimized, so that even if the number of the block chains deployed on the block chain link points is increased, the number of bottom databases is not required to be increased, a new parallel block chain can be created almost without cost, and the number of the block chains which can be deployed on each block chain node can also get rid of the limitation of storage space, so that the problems that the storage space of the block chain link points is seriously occupied due to the fact that one chain corresponds to one database, and the number of chains which can be supported on the block chain nodes is limited are solved; meanwhile, through the technical scheme of the embodiment of the application, atomicity of cross-chain interactive operation is easier to realize, the cross-chain interactive operation can be completed through batch processing and writing of the database, and complex protocols such as Hash time lock and two-stage submission are not needed to realize the cross-chain interactive operation when a plurality of databases exist in the bottom layer, so that the problems of high difficulty and high complexity in cross-chain data interaction realization when one chain corresponds to one database are solved.
Fig. 6 is a schematic structural diagram of a block generation apparatus according to an embodiment of the present application. The embodiment of the application can be applied to the situation of how to pack the blocks when a plurality of block chains are deployed on the block chain nodes at the same time, for example, when a basic block chain and at least one parallel block chain are deployed at the same time. The apparatus disclosed in the embodiments of the present application may be implemented by software and/or hardware, and may be configured in a blockchain node. Blockchain nodes may be deployed on any electronic device having computing capabilities.
As shown in fig. 6, the block generating apparatus 300 disclosed in this embodiment of the present application may include a transaction data determining module 301, a parallel block building module 302, and a basic block building module 303, where:
the transaction data determining module 301 is configured to process a basic transaction request in a basic block chain to obtain basic transaction data, and process a parallel transaction request in a parallel block chain to obtain parallel transaction data;
a parallel block construction module 302, configured to construct a current parallel block according to the parallel transaction data;
a basic block construction module 303, configured to construct a current basic block according to the basic transaction data, the parallel transaction data, and the current parallel block.
Optionally, the basic block building module 303 includes:
the block head construction unit is used for constructing the block head of the current basic block according to the basic transaction data and the parallel transaction data;
and the block body construction unit is used for constructing the block body of the current basic block according to the basic transaction data and the current parallel block.
Optionally, the block header constructing unit includes:
the calculation subunit is used for calculating the Merkel root of the current basic block according to the basic transaction data and the parallel transaction data;
and the constructing subunit is used for constructing the block head of the current basic block according to the Merkel root of the current basic block and the hash value of the last basic block.
Optionally, the parallel block building module 302 includes:
the computing unit is used for computing the Merkel root of the current parallel block according to the parallel transaction data;
and the construction unit is used for constructing the block head of the current parallel block according to the Merkel root of the current parallel block and the hash value of the previous parallel block, and taking the parallel transaction data as the block body of the current parallel block.
Optionally, the transaction data determining module 301 includes:
the basic transaction data determining unit is used for processing the basic transaction request in the basic block chain to obtain basic transaction data;
the monitoring unit is used for monitoring whether the parallel transaction request in the parallel block chain exists on the local node in the process of processing the basic transaction request in the basic block chain to obtain the basic transaction data;
and the parallel transaction data determining unit is used for processing the parallel transaction request in the parallel block chain if the parallel transaction data exists, so as to obtain the parallel transaction data.
Optionally, the same consensus mechanism is deployed on the base blockchain and the parallel blockchain.
The block generation apparatus 300 disclosed in the embodiment of the present application can execute any block generation method disclosed in the embodiment of the present application, and has functional modules and beneficial effects corresponding to the execution method. Reference may be made to the description in any method embodiment of the present application for details not explicitly described in the embodiments of the present application.
According to an embodiment of the present application, an electronic device and a readable storage medium are also provided.
As shown in fig. 7, fig. 7 is a block diagram of an electronic device for implementing the block generation method in the embodiment of the present application. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be examples only, and are not meant to limit implementations of embodiments of the present application described and/or claimed herein.
As shown in fig. 7, the electronic apparatus includes: one or more processors 401, memory 402, and interfaces for connecting the various components, including high-speed interfaces and low-speed interfaces. The various components are interconnected using different buses and may be mounted on a common motherboard or in other manners as desired. The processor may process instructions for execution within the electronic device, including instructions stored in or on the memory to display Graphical information for a Graphical User Interface (GUI) on an external input/output device, such as a display device coupled to the Interface. In other embodiments, multiple processors and/or multiple buses may be used, along with multiple memories and multiple memories, as desired. Also, multiple electronic devices may be connected, with each device providing portions of the necessary operations, e.g., as a server array, a group of blade servers, or a multi-processor system. In fig. 7, one processor 401 is taken as an example.
The memory 402 is a non-transitory computer readable storage medium provided by the embodiments of the present application. The memory stores instructions executable by at least one processor, so that the at least one processor executes the block generation method provided by the embodiment of the application. The non-transitory computer-readable storage medium of the embodiments of the present application stores computer instructions for causing a computer to execute the block generation method provided by the embodiments of the present application.
The memory 402, which is a non-transitory computer readable storage medium, may be used to store non-transitory software programs, non-transitory computer executable programs, and modules, such as program instructions/modules corresponding to the block generation method in the embodiment of the present application, for example, the transaction data determination module 301, the parallel block construction module 302, and the basic block construction module 303 shown in fig. 6. The processor 401 executes various functional applications and data processing of the electronic device by running non-transitory software programs, instructions and modules stored in the memory 402, that is, implements the block generation method in the above-described method embodiments.
The memory 402 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to use of the electronic device, and the like. Further, the memory 402 may include high speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, the memory 402 may optionally include a memory remotely located from the processor 401, and these remote memories may be connected via a network to an electronic device for implementing the tile generation method of the embodiments of the present application. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The electronic device for implementing the block generation method in the embodiment of the present application may further include: an input device 403 and an output device 404. The processor 401, the memory 402, the input device 403 and the output device 404 may be connected by a bus or other means, and fig. 7 illustrates an example of a connection by a bus.
The input device 403 may receive input numeric or character information and generate key signal inputs related to user settings and function controls of an electronic device used to implement the tile generation method in embodiments of the present application, such as a touch screen, keypad, mouse, trackpad, touchpad, pointer stick, one or more mouse buttons, trackball, joystick, or like input device the output device 404 may include a Display device, an auxiliary illumination device, such as a light Emitting Diode (L lighting Diode, L ED), a tactile feedback device, such as a vibrating motor, or the like, the Display device may include, but is not limited to, a liquid Crystal Display (L iquid Crystal Display, L CD), a L ED Display, and a plasma Display.
Various implementations of the systems and techniques described here can be realized in digital electronic circuitry, Integrated circuitry, Application Specific Integrated Circuits (ASICs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, receiving data and instructions from, and transmitting data and instructions to, a storage system, at least one input device, and at least one output device.
As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, apparatus, and/or Device for providing machine instructions and/or data to a Programmable processor, such as a magnetic disk, optical disk, memory, Programmable logic Device (P L D), including a machine-readable medium that receives machine instructions as a machine-readable signal.
The systems and techniques described here can be implemented on a computer having a display device, e.g., a Cathode Ray Tube (CRT) or L CD monitor, for displaying information to the user and a keyboard and a pointing device, e.g., a mouse or a trackball, by which the user can provide input to the computer for providing interaction with the user.
The systems and techniques described here can be implemented in a computing system that includes a back-end component, e.g., as a data server, or that includes a middleware component, e.g., AN application server, or that includes a front-end component, e.g., a user computer having a graphical user interface or a web browser through which a user can interact with AN implementation of the systems and techniques described here, or any combination of such back-end, middleware, or front-end components.
The computer system may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other.
According to the technical scheme of the embodiment of the application, aiming at the condition that a basic block chain and a parallel block chain are simultaneously deployed on a block chain node, a block data storage mode under a multi-chain scene is optimized by constructing the current parallel block according to parallel transaction data and nesting the current parallel block according to the basic transaction data and the parallel transaction data, so that even if the number of the block chains deployed on the block chain node is increased, the number of bottom databases is not required to be increased, a new parallel block chain can be created almost without cost, and the number of the block chains which can be deployed on each block chain node can be free from the limitation of storage space, thereby solving the problems that the storage space of the block chain node is seriously occupied by one corresponding database to one chain, and the number of chains which can be supported on the block chain node is limited; meanwhile, through the technical scheme of the embodiment of the application, atomicity of cross-chain interactive operation is easier to realize, the cross-chain interactive operation can be completed through batch processing and writing of the database, and complex protocols such as Hash time lock and two-stage submission are not needed to realize the cross-chain interactive operation when a plurality of databases exist in the bottom layer, so that the problems of high difficulty and high complexity in cross-chain data interaction realization when one chain corresponds to one database are solved.
It should be understood that various forms of the flows shown above may be used, with steps reordered, added, or deleted. For example, the steps described in the present application may be executed in parallel, sequentially, or in different orders, as long as the desired results of the technical solutions disclosed in the present application can be achieved, and the present invention is not limited herein.
The above-described embodiments should not be construed as limiting the scope of the present application. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may be made in accordance with design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims (14)
1. A block generation method is applied to a block chain node, wherein a basic block chain and a parallel block chain are deployed on the block chain node, and the method comprises the following steps:
processing the basic transaction request in the basic block chain to obtain basic transaction data, and processing the parallel transaction request in the parallel block chain to obtain parallel transaction data;
constructing a current parallel block according to the parallel transaction data;
and constructing a current basic block according to the basic transaction data, the parallel transaction data and the current parallel block.
2. The method of claim 1, wherein constructing a current base block from the base transaction data, the parallel transaction data, and the current parallel block comprises:
constructing a block head of the current basic block according to the basic transaction data and the parallel transaction data;
and constructing a block body of the current basic block according to the basic transaction data and the current parallel block.
3. The method of claim 2, wherein constructing a block header for the current base block based on the base transaction data and the parallel transaction data comprises:
calculating a Merker root of the current basic block according to the basic transaction data and the parallel transaction data;
and constructing the block head of the current basic block according to the Merkel root of the current basic block and the hash value of the last basic block.
4. The method of claim 1, wherein constructing a current parallel block from the parallel transaction data comprises:
calculating the Merkel root of the current parallel block according to the parallel transaction data;
and constructing a block header of the current parallel block according to the Merkel root of the current parallel block and the hash value of the last parallel block, and taking the parallel transaction data as the block body of the current parallel block.
5. The method of claim 1, wherein processing a base transaction request in the base blockchain to obtain base transaction data and processing a parallel transaction request in the parallel blockchain to obtain parallel transaction data comprises:
monitoring whether a parallel transaction request in the parallel block chain exists on a local node in the process of processing the basic transaction request in the basic block chain to obtain basic transaction data;
and if so, processing the parallel transaction request in the parallel block chain to obtain the parallel transaction data.
6. The method of claim 1, wherein the same consensus mechanism is deployed on the base blockchain and the parallel blockchain.
7. An apparatus for block generation configured at a block chain node, the block chain node having a base block chain and a parallel block chain deployed thereon, the apparatus comprising:
the transaction data determining module is used for processing the basic transaction request in the basic block chain to obtain basic transaction data and processing the parallel transaction request in the parallel block chain to obtain parallel transaction data;
the parallel block construction module is used for constructing a current parallel block according to the parallel transaction data;
and the basic block building module is used for building a current basic block according to the basic transaction data, the parallel transaction data and the current parallel block.
8. The apparatus of claim 7, wherein the base block construction module comprises:
a block header construction unit, configured to construct a block header of the current basic block according to the basic transaction data and the parallel transaction data;
and the block body construction unit is used for constructing a block body of the current basic block according to the basic transaction data and the current parallel block.
9. The apparatus of claim 8, wherein the block header building unit comprises:
the calculation subunit is configured to calculate a mekerr root of the current basic block according to the basic transaction data and the parallel transaction data;
and the constructing subunit is used for constructing the block head of the current basic block according to the Merkel root of the current basic block and the hash value of the last basic block.
10. The apparatus of claim 7, wherein the parallel block construction module comprises:
the computing unit is used for computing the Merkel root of the current parallel block according to the parallel transaction data;
and the construction unit is used for constructing the block head of the current parallel block according to the Merkel root of the current parallel block and the hash value of the previous parallel block, and using the parallel transaction data as the block body of the current parallel block.
11. The apparatus of claim 7, wherein the transaction data determination module comprises:
a basic transaction data determining unit, configured to process a basic transaction request in the basic block chain to obtain the basic transaction data;
the monitoring unit is used for monitoring whether the parallel transaction request in the parallel block chain exists on a local node in the process of processing the basic transaction request in the basic block chain to obtain basic transaction data;
and the parallel transaction data determining unit is used for processing the parallel transaction request in the parallel block chain if the parallel transaction data exists, so as to obtain the parallel transaction data.
12. The apparatus of claim 7, wherein the same consensus mechanism is deployed on the base blockchain and the parallel blockchain.
13. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the block generation method of any one of claims 1-6.
14. A non-transitory computer readable storage medium storing computer instructions for causing a computer to perform the block generating method of any one of claims 1 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010254531.9A CN111475572B (en) | 2020-04-02 | 2020-04-02 | Block generation method, device, equipment and medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010254531.9A CN111475572B (en) | 2020-04-02 | 2020-04-02 | Block generation method, device, equipment and medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111475572A true CN111475572A (en) | 2020-07-31 |
CN111475572B CN111475572B (en) | 2023-08-29 |
Family
ID=71749855
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010254531.9A Active CN111475572B (en) | 2020-04-02 | 2020-04-02 | Block generation method, device, equipment and medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111475572B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113439424A (en) * | 2018-12-14 | 2021-09-24 | 西门子股份公司 | Building a blockchain having blocks including an adjustable number of transaction blocks and a plurality of intermediate blocks |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107909369A (en) * | 2017-10-13 | 2018-04-13 | 布比(北京)网络技术有限公司 | Based on the common recognition method, apparatus merchandised across chain and storage medium |
WO2018076760A1 (en) * | 2016-10-27 | 2018-05-03 | 上海亿账通区块链科技有限公司 | Block chain-based transaction processing method, system, electronic device, and storage medium |
CN108959621A (en) * | 2018-07-18 | 2018-12-07 | 百度在线网络技术(北京)有限公司 | A kind of implementation method, device, equipment and the storage medium of block chain network |
CN108985774A (en) * | 2018-07-18 | 2018-12-11 | 百度在线网络技术(北京)有限公司 | A kind of motivational techniques, device, equipment and the storage medium of block chain network |
US20190081793A1 (en) * | 2017-09-12 | 2019-03-14 | Kadena, LLC | Parallel-chain architecture for blockchain systems |
CN109858285A (en) * | 2018-12-07 | 2019-06-07 | 上海异势信息科技有限公司 | Processing method, device, equipment and the medium of block chain data |
CN110516006A (en) * | 2019-08-26 | 2019-11-29 | 杭州复杂美科技有限公司 | Parallel chain block generation method, equipment and storage medium |
-
2020
- 2020-04-02 CN CN202010254531.9A patent/CN111475572B/en active Active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2018076760A1 (en) * | 2016-10-27 | 2018-05-03 | 上海亿账通区块链科技有限公司 | Block chain-based transaction processing method, system, electronic device, and storage medium |
US20190081793A1 (en) * | 2017-09-12 | 2019-03-14 | Kadena, LLC | Parallel-chain architecture for blockchain systems |
CN107909369A (en) * | 2017-10-13 | 2018-04-13 | 布比(北京)网络技术有限公司 | Based on the common recognition method, apparatus merchandised across chain and storage medium |
CN108959621A (en) * | 2018-07-18 | 2018-12-07 | 百度在线网络技术(北京)有限公司 | A kind of implementation method, device, equipment and the storage medium of block chain network |
CN108985774A (en) * | 2018-07-18 | 2018-12-11 | 百度在线网络技术(北京)有限公司 | A kind of motivational techniques, device, equipment and the storage medium of block chain network |
CN109858285A (en) * | 2018-12-07 | 2019-06-07 | 上海异势信息科技有限公司 | Processing method, device, equipment and the medium of block chain data |
CN110516006A (en) * | 2019-08-26 | 2019-11-29 | 杭州复杂美科技有限公司 | Parallel chain block generation method, equipment and storage medium |
Non-Patent Citations (3)
Title |
---|
NGUYEN VAN TOAN,UNG PARK,GEUNWOONG RYU: ""RCANE: Semi-Centralized Network of Parallel Blockchain and APoS"" * |
小艺: ""其实你需要的不是公链,而是平行链 "", pages 1 - 2 * |
袁勇;王飞跃;: "平行区块链:概念、方法与内涵解析", no. 10 * |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113439424A (en) * | 2018-12-14 | 2021-09-24 | 西门子股份公司 | Building a blockchain having blocks including an adjustable number of transaction blocks and a plurality of intermediate blocks |
CN113439424B (en) * | 2018-12-14 | 2023-11-24 | 西门子股份公司 | Establishing a blockchain having blocks including an adjustable number of transaction blocks and a plurality of intermediate blocks |
Also Published As
Publication number | Publication date |
---|---|
CN111475572B (en) | 2023-08-29 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11657091B2 (en) | Method and apparatus for querying shortest path of graph, and storage medium | |
EP3822777A1 (en) | Methods for processing mini program, and related devices | |
CN111368326B (en) | Vehicle data processing method and device, electronic equipment and storage medium | |
US20230153811A1 (en) | Blockchain-based data storage method, system and apparatus | |
JP2022008781A (en) | Decentralized training method, system, device, storage medium and program | |
EP3832493B1 (en) | Method, apparatus, electronic device and readable storage medium for data query | |
CN111277647B (en) | Block chain network member management method, device, equipment and medium | |
EP3862951A2 (en) | Method and apparatus of processing deposit, device and storage medium | |
EP3832574A2 (en) | Method and apparatus for processing transaction requests in blockchain, device and medium | |
EP3869377A1 (en) | Method and apparatus for data processing based on smart contract, device and storage medium | |
EP3869339B1 (en) | Data storage method and apparatus for blockchain, device, and medium | |
EP3825865A2 (en) | Method and apparatus for processing data | |
CN112565356B (en) | Data storage method and device and electronic equipment | |
CN110688229B (en) | Task processing method and device | |
CN111625949A (en) | Simulation engine system, simulation processing method, device and medium | |
EP3859529B1 (en) | Backup management method and system, electronic device and medium | |
CN104580428A (en) | Data routing method, data management device and distributed storage system | |
CN111475572B (en) | Block generation method, device, equipment and medium | |
WO2021203635A1 (en) | Distributed system running state monitoring method and apparatus, device, and storage medium | |
JP7316305B2 (en) | Graph calculation processing method, device, electronic device, and storage medium | |
JP2021101579A (en) | Block chain execution method, device, facility, storage medium and program | |
CN112925482B (en) | Data processing method, device, system, electronic equipment and computer storage medium | |
CN116610751A (en) | Metadata processing method and device | |
CN111506420B (en) | Memory synchronization method and device, electronic equipment and storage medium | |
CN116048417A (en) | Information generation method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |