CN109409889B - Block determining method and device in block chain and electronic equipment - Google Patents

Block determining method and device in block chain and electronic equipment Download PDF

Info

Publication number
CN109409889B
CN109409889B CN201811346466.1A CN201811346466A CN109409889B CN 109409889 B CN109409889 B CN 109409889B CN 201811346466 A CN201811346466 A CN 201811346466A CN 109409889 B CN109409889 B CN 109409889B
Authority
CN
China
Prior art keywords
block
tree
node
determining
contained
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.)
Active
Application number
CN201811346466.1A
Other languages
Chinese (zh)
Other versions
CN109409889A (en
Inventor
万涔涔
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Rivtower Technology Co Ltd
Original Assignee
Cryptape Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Cryptape Co ltd filed Critical Cryptape Co ltd
Priority to CN201811346466.1A priority Critical patent/CN109409889B/en
Publication of CN109409889A publication Critical patent/CN109409889A/en
Application granted granted Critical
Publication of CN109409889B publication Critical patent/CN109409889B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction
    • G06Q20/3829Payment protocols; Details thereof insuring higher security of transaction involving key management

Landscapes

  • Business, Economics & Management (AREA)
  • Engineering & Computer Science (AREA)
  • Accounting & Taxation (AREA)
  • Computer Security & Cryptography (AREA)
  • Finance (AREA)
  • Strategic Management (AREA)
  • Physics & Mathematics (AREA)
  • General Business, Economics & Management (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Storage Device Security (AREA)

Abstract

The embodiment of the specification relates to a method and a device for determining a block in a block chain and an electronic device, and the method comprises the following steps: the consensus node determines the root hash value of the Mercker tree corresponding to the transaction units to be contained in all the blocks at this time according to a preset Mercker tree, and the difference between the total number of leaf nodes of the Mercker tree and the number of the transaction units to be contained in the blocks is within a preset threshold range; storing the root hash value into a block header; and determining the block to be broadcasted according to the block header and the transaction unit to be contained in the block. By adopting the scheme, the calculation amount of the hash value of the root node of the Mercker tree is reduced, the processing speed of the consensus node for determining the block to be broadcasted is increased, and the transaction processing performance of the block chain is improved.

Description

Block determining method and device in block chain and electronic equipment
Technical Field
The embodiment of the present specification relates to the field of network technologies, and in particular, to a method and an apparatus for determining a block in a block chain, and an electronic device.
Background
The blockchain is a solution for solving the multi-party trust problem by using a distributed account book technology, and is a decentralized database. The blockchain network is composed of a plurality of nodes maintaining a complete blockchain account book, any node can at least correspond to one blockchain, and any blockchain can comprise at least one block. The block is composed of a block head and a block body.
The existing block chain technology generally uses a Merkle tree (Merkle tree) as an organization form of transaction, and Simple Payment Verification (SPV) can be performed by using the Merkle tree, so that a convenient door is opened for a common user to use the block chain technology. Ordinary users do not need to maintain a huge and complete blockchain, and only need to store all blockheads and simple payment proofs of own transactions.
In the blockchain technology, the consensus algorithm is used to ensure that the distributed ledger is finally consistent, and nodes participating in the consensus process (i.e. consensus nodes) have the right to broadcast the block, which is also called accounting right. The consensus node collects the transactions broadcast in the network and places them in a local transaction pool, broadcasting blocks when billing rights need to be fulfilled. The block to be broadcast contains a certain number of transaction units taken out of the transaction pool, and each transaction unit contains specific service data. The transaction units are constructed into a Mercker tree, the hash values of the transaction units form leaf nodes of the Mercker tree, hash operation is carried out from the leaf nodes layer by layer upwards, the hash values of the root nodes are finally calculated and put into the block headers, and the service data of the transaction units are put into the block bodies. The block header and block body constitute a block to be broadcast.
Assuming that the degree of the Merck tree (degree is the maximum branch number of nodes in the Merck tree) is m (m is a positive integer greater than or equal to 2), the number of leaf nodes of a full m-fork Merck tree is nmAnd (4) respectively. In most cases, the number of transaction units is not exactly equal to nmThe currently widely used method is to repeatedly copy the hash value of the last transaction unit so that the total number of transaction units is exactly equal to nmOne constituting a full m-ary merkel tree.
As shown in FIG. 1, a full 2-fork Merck tree is shown, leaf nodes are leaf1-leaf8, if the number of transaction units is 6, the original leaf7 and leaf8 have no corresponding hash value, and the hash value v of the root node is calculatedrootThen, the hash value v of the leaf node leaf6 is added6Copied into leaf nodes leaf7 and leaf 8. However, the hash value calculation is a very time-consuming operation, and the number of hash calculations is greatly increased by adopting a repeated copy mode, so that the calculation amount of the hash value for determining the root node is increased, the common node of the block chain spends more time in determining the block to be broadcasted, and the transaction performance of the block chain is reduced.
Disclosure of Invention
Embodiments of the present disclosure provide a method and an apparatus for determining a block in a blockchain, and an electronic device, so as to solve the problems of a low speed for determining a block to be broadcasted and a low performance of processing blockchain transactions of a common node in the prior art.
In order to solve the above technical problem, the embodiments of the present specification adopt the following technical solutions:
in a first aspect, a method for determining a block in a block chain is provided, where the method includes: the consensus node determines root hash values of the Mercker trees corresponding to the transaction units to be contained in all the blocks at this time according to a preset Mercker tree, and the difference between the total number of leaf nodes of the Mercker trees and the number of the transaction units to be contained in the blocks is within a preset threshold range;
storing the root hash value into a block header;
and determining a block to be broadcasted according to the block header and a transaction unit to be contained in the block.
In a second aspect, an apparatus for determining a block in a block chain is provided, the apparatus comprising:
the root hash value determining module is used for determining root hash values of the Mercker trees corresponding to the transaction units to be contained in all the blocks at this time according to preset Mercker trees, and the difference between the total number of leaf nodes of the m-fork Mercker trees and the number of the transaction units to be contained in the blocks is within a preset threshold range;
a block header determining module, configured to place the root hash value in the block header;
and the block to be broadcasted determining module is used for determining the block to be broadcasted according to the block header and the transaction units to be contained in the block.
In a third aspect, an electronic device is provided, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the computer program being executed by the processor to:
determining root hash values of the Mercker trees corresponding to the transaction units to be contained in all the blocks at this time according to a preset Mercker tree, wherein the difference between the total number of leaf nodes of the Mercker trees and the number of the transaction units to be contained in the blocks is within a preset threshold range;
storing the root hash value into a block header;
and determining a block to be broadcasted according to the block header and a transaction unit to be contained in the block.
In a fourth aspect, a computer-readable storage medium is provided that stores one or more programs that, when executed by an electronic device that includes a plurality of application programs, cause the electronic device to:
determining root hash values of the Mercker trees corresponding to the transaction units to be contained in all the blocks at this time according to a preset Mercker tree, wherein the difference between the total number of leaf nodes of the Mercker trees and the number of the transaction units to be contained in the blocks is within a preset threshold range;
storing the root hash value into a block header;
and determining a block to be broadcasted according to the block header and a transaction unit to be contained in the block.
The embodiment of the specification adopts at least one technical scheme which can achieve the following beneficial effects:
according to the technical scheme, the difference between the number of leaf nodes of the Mercker tree adopted by the transaction organization form in the block chain and the number of the transaction units to be broadcasted is within the preset threshold range, so that the calculation amount of the root node hash value of the Mercker tree is reduced, the processing speed of determining the blocks to be broadcasted by the consensus node is improved, and the transaction processing performance of the block chain is improved.
Drawings
In order to more clearly illustrate the embodiments of the present specification or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, it is obvious that the drawings in the following description are only some embodiments described in the embodiments of the present specification, and for those skilled in the art, other drawings can be obtained according to the drawings without any creative efforts.
FIG. 1 is a schematic diagram of the structure of a full 2-fork Merck tree;
fig. 2 is a schematic diagram illustrating a step of a block determination method in a block chain according to an embodiment of the present disclosure;
FIG. 3 is one of the schematic diagrams of the steps for constructing the Mercker tree provided in the embodiments of the present disclosure;
FIG. 4 is a schematic structural diagram of a Mercker tree provided in an embodiment of the present disclosure;
FIG. 5 is a second schematic diagram of the steps for building a Merck tree provided in the embodiments of the present disclosure;
FIG. 6 is a second schematic structural diagram of a Mercker tree provided in the embodiments of the present disclosure;
fig. 7 is a schematic structural diagram of an electronic device provided in an embodiment of the present specification;
fig. 8 is a schematic structural diagram of a block determination apparatus in a block chain according to an embodiment of the present disclosure.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present disclosure more clear, the technical solutions of the embodiments of the present disclosure will be clearly and completely described below with reference to the specific embodiments of the present disclosure and the accompanying drawings. It is to be understood that the embodiments described are only a few embodiments of the present disclosure, and not all embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the present specification without any creative effort belong to the protection scope of the embodiments in the present specification.
The technical solutions provided by the embodiments of the present description are described in detail below with reference to the accompanying drawings.
It should be noted that, in the embodiment of the present specification, a difference between the number of leaf nodes of the mercker tree and the number of transaction units to be broadcasted, which are used in an organization form of transactions in a blockchain, is within a preset threshold range, so that a calculation amount of hash values of root nodes of the mercker tree is reduced, a processing speed of determining a to-be-broadcasted block by a consensus node is increased, and a transaction processing performance of the blockchain is improved.
In this embodiment, the consensus node is a node participating in consensus in the blockchain network, and can broadcast transaction data and a block, and the right to broadcast the block is also called a billing right. The consensus node collects the transactions broadcast in the network and places them in a local transaction pool, broadcasting blocks when billing rights need to be fulfilled. The block to be broadcast contains a certain number of transactions taken from the transaction pool. The transactions are constructed into a Merck tree, a root node and leaf nodes are constituent units of the Merck tree, the value of each leaf node is the hash value of a transaction unit to be contained in a block, hash operation is carried out layer by layer upwards from the leaf nodes, and finally the hash value of the root node of the Merck tree is calculated. And the hash value of the root node is put into the block head, and the transaction unit to be broadcasted is put into the block body to form the block to be broadcasted.
Example one
Referring to fig. 2, a schematic step diagram of a method for determining a block in a blockchain according to an embodiment of the present disclosure is shown. The method mainly comprises the following steps:
step 202: the consensus node selects the transaction units to be included in the block to be broadcasted from the local transaction pool.
In the blockchain network, when a blockchain node broadcasts transactions in the network, a consensus node receives the broadcasted transactions and stores the broadcasted transactions into a local transaction pool, and when the consensus node needs to fulfill the accounting right, a transaction unit to be included in the block to be broadcasted is selected from the local transaction pool.
Step 204: and the consensus node determines the root hash value of the Mercker tree corresponding to the transaction units to be contained in all the blocks at the time according to the preset Mercker tree.
In the blockchain technology, a merkel tree is generally used as an organization form of a transaction, a leaf node of the merkel tree has a hash value of a transaction unit in a block to be broadcasted, and a root node of the merkel tree has a hash value called a root hash value.
Step 206: the root hash value is stored in a block header.
Step 208: and determining the block to be broadcasted according to the block header and the transaction unit to be contained in the block to be broadcasted.
According to the pre-constructed Mercker tree model, the difference between the total number of leaf nodes of the Mercker tree and the number of transaction units to be contained in the block is within a preset threshold range, and the preset threshold can be logmn, m is the degree of the default Mercker tree, and n is the total number of transaction units to be included in the block.
In this embodiment, the step 202 of constructing the mercker tree specifically includes the following steps, as shown in fig. 3:
step 302: and determining the depth i of the Mercker tree to be constructed according to the number S of the transaction units to be contained in the block to be broadcasted and the degree m of the Mercker tree preset.
S, m knowing that the degree of the merkel tree is the maximum branch number of the nodes in the merkel tree, determining the depth i of the merkel tree to be constructed according to the following formula, wherein the depth represents the layer number of the nodes of the merkel tree, the direction is from the root node to the leaf node, and the root node is the 0 th layer:
Figure BDA0001863867750000061
wherein,
Figure BDA0001863867750000062
indicating rounding up.
Step 304: constructing a full m-fork Merck tree with a depth of i.
Step 306: starting from the leaf node of the merkel tree with the starting number, the following leaf nodes including the (S +1) th number are deleted.
Wherein the start number may start with 1.
Step 308: starting from the depth i-j (j ═ 1, …, i) of the merkel tree, if the child nodes of the node of that depth are all empty, deleting that node; if any child node of the node with the depth is not empty, presetting the rest empty child nodes of the node as a node X; and repeating the processing steps of the child nodes of the node until the depth is 0.
Where X is a value used to fill in the node contents, and may be preset.
Step 310: and according to the constructed Mercker tree, determining the root hash value of the Mercker tree corresponding to the transaction units to be contained in all the blocks at this time according to the hash value of the transaction unit to be contained in each block.
In step 310, the value of the leaf node of the mercker tree is the hash value of the transaction unit to be included in the block to be broadcasted, and the root hash value of the root node of the mercker tree is calculated according to a hash algorithm, where the hash algorithm may be processed according to a method in the prior art, and is not described herein again.
The following explanation specifically takes the transaction number S of the block to be broadcast to be included as 5, and the degree m of the merkel tree as 2 as an example.
According to the formula 1, the process is carried out,
Figure BDA0001863867750000063
the depth of the Merck tree is 3, from the root node down to the leafAnd the depths of the child nodes are 0, 1, 2 and 3 respectively.
Firstly, a full 2-fork merkel tree (see fig. 1) with the depth of 3 is constructed, and then 8 leaf nodes are respectively leaf1 and leaf2 … … leaf8, and the depth of the leaf node of the layer is 3; the depth of the layer of the nodes Node9, Node10, Node11 and Node12 is 2, the depth of the layer of the nodes Node13 and Node14 is 1, and the depth of the Root Node Tree Root is 0.
Starting from the leaf node leaf1, the following leaf nodes are deleted, i.e., leaf nodes leaf6, leaf7, leaf8, including the S +1 th ═ 6 th.
Starting from depth i-1-2, it is determined whether the child nodes of each node of that depth are empty. Since the Node11 has a child Node leaf5, and the child Node leaf6 has been deleted, the deleted child Node leaf6 is set to Node X, where X is a value for filling the Node contents and can be preset, and the value of the Node in this embodiment is set to Vx. If the child nodes leaf7 and leaf8 of the Node12 have been deleted and are all empty, the Node12 is deleted.
When the Node condition is judged to be 1 at the depth i-2, the child Node12 of the Node14 is deleted, and the Node X is set at the position of the deleted child Node 12.
And (3) judging the situation that the depth i-3 is 0, namely the Root node Tree Root and all the child nodes of the Root node are not empty, completing the construction of the Mercker Tree, wherein the structural schematic diagram of the constructed Mercker Tree is shown in figure 4.
Referring to FIG. 5, another method for constructing the Mercker tree in step 202 of this embodiment is shown. The method mainly comprises the following steps:
step 502: according to
Figure BDA0001863867750000071
Determining a coefficient ki
Wherein S is the number of the transaction units to be broadcast, m is the degree of the preset Mercker tree,
Figure BDA0001863867750000072
indicating a rounding down.
Step 504: determining a set G comprising non-zero ki
Step 506: according to the sequence from the big to the small of i, respectively taking k corresponding to i in the set GiConstruction of kiA full m-fork Merck tree of height i as the top k of the root node X to be constructed of the Merck treeiThe branch of each child node is the (k) th branch of the root node Xi+1) child node set as node x to be constructedi. Continuing to take k corresponding to i from the set GiBuilding node xiUntil the smallest i.
The height represents the number of layers of the node of the Merck tree, the direction is from the leaf node to the root node, and the leaf node is the 0 th layer.
Step 508: and according to the constructed Merckel tree, determining the root hash value of the transaction unit transaction units to be contained in all the blocks at this time according to the hash value of the transaction unit to be contained in each block.
In this step 508, the value of the leaf node of the mercker tree is the hash value of the transaction unit to be included in the block, and the root hash value of the root node of the mercker tree is calculated according to the hash algorithm, where the hash algorithm may be processed according to a method in the prior art, and is not described herein again.
The following explanation specifically takes the number S of transaction units to be included in a block as 5, and the degree m of the merkel tree as 2 as an example.
According to the formula
Figure BDA0001863867750000081
K can be determined0=1,k1=0,k2=1。
Determining a set G ═ k0=1,k2=1]。
K corresponding to i-2 in the set G 21 full 2 fork merck tree with height 2 is constructed as the branch of the 1 st child Node of the merck tree root Node R, as shown in fig. 6, namely full 2 fork merck tree with height 2 composed of Node8, Node7, Node7, Leaf1, Leaf2, Leaf3 and Leaf4 as one of the root nodes RAnd (4) branching. The k-th of the root node2+ 1-2 child nodes Node9 set as the Node x to be constructedi
K corresponding to i ═ 0 in the set G 01, construct 1 merkel tree with height 0 as the first sub-Node branch of the merkel tree Node9, and then only one leaf Node as the branch of the 1 st sub-Node of the Node9, i.e. leaf5, will be the k-th sub-Node of the root Node0And the + 1-2 child nodes are set as the nodes leafX to be constructed. No other parameters exist in the set G, and the construction of the Mercker tree is completed.
Since the Node8 Node branch is constructed to include leaf nodes leaf1-leaf4, the Node8 Node includes one leaf5, the number of transaction units to be contained in the block S is 5, the leaf nodes with height i of 0 are only 4, and there is no need to copy leaf4 repeatedly to the leaf nodes with height i of 0 below the Node9 branch.
In this embodiment, the number of leaf nodes of the constructed merkel tree is equal to the number of transaction units to be included in the block to be broadcasted plus one, and the difference between the numbers of the leaf nodes and the transaction units is within the preset threshold range, and the hash value of the last transaction unit does not need to be copied repeatedly, so that the calculation amount of the hash value is reduced, the time spent by the consensus node for determining the block to be broadcasted is reduced, the processing speed of the consensus node for determining the block to be broadcasted is improved, and the transaction processing performance of the block chain is improved.
Example two
An electronic apparatus according to an embodiment of the present specification is described below with reference to fig. 7. Referring to fig. 7, at a hardware level, the electronic device includes a processor, and optionally further includes an internal bus, a network interface, and a memory. The Memory may include a Memory, such as a Random-Access Memory (RAM), and may further include a Non-Volatile Memory (Non-Volatile Memory), such as at least 1 disk Memory. Of course, the electronic device may also include hardware required for other services.
The processor, the network interface, and the memory may be interconnected by an internal bus, which may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended ISA (EISA) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one double-headed arrow is shown in FIG. 7, but this does not indicate only one bus or one type of bus.
And the memory is used for storing programs. In particular, the program may include program code comprising computer operating instructions. The memory may include both memory and non-volatile storage and provides instructions and data to the processor.
The processor reads the corresponding computer program from the nonvolatile memory into the memory and then runs the computer program to form the content recommendation device on a logic level. And the processor is used for executing the program stored in the memory and is specifically used for executing the method operation executed when the server is taken as an execution main body.
The methods disclosed in the embodiments of fig. 2, fig. 3, and fig. 5 in the present specification may be applied to or implemented by a processor. The processor may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in a processor or instructions in the form of software. The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components. The various methods, steps and logic blocks disclosed in the embodiments of the present specification may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in connection with the embodiments of the present specification may be embodied directly in a hardware decoding processor, or in a combination of hardware and software modules in the decoding processor. The software module may be located in ram, flash memory, rom, prom, or eprom, registers, etc. storage media as is well known in the art. The storage medium is located in a memory, and a processor reads information in the memory and completes the steps of the method in combination with hardware of the processor.
The electronic device may further execute the method shown in fig. 2, and implement the functions of the block determining apparatus in the block chain in the embodiment shown in fig. 2, which are not described herein again in this specification.
Of course, besides the software implementation, the electronic device of the embodiment of the present disclosure does not exclude other implementations, such as a logic device or a combination of software and hardware, and the like, that is, the execution subject of the following processing flow is not limited to each logic unit, and may also be hardware or a logic device.
EXAMPLE III
The present specification embodiments also provide a computer-readable storage medium storing one or more programs that, when executed by an electronic device including a plurality of application programs, cause the electronic device to perform operations comprising:
determining root hash values of the Mercker trees corresponding to the transaction units to be contained in all the blocks at this time according to a preset Mercker tree, wherein the difference between the total number of leaf nodes of the Mercker trees and the number of the transaction units to be contained in the blocks is within a preset threshold range;
storing the root hash value into a block header;
and determining a block to be broadcasted according to the block header and a transaction unit to be contained in the block.
The computer-readable storage medium may be a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk.
Example four
Referring to fig. 8, a schematic structural diagram of an apparatus for determining a block in a block chain according to an embodiment of the present disclosure is shown, where the apparatus mainly includes:
a root hash value determining module 802, configured to determine, according to a preset merkel tree, a root hash value of the merkel tree corresponding to the transaction units to be included in all the blocks at this time, where a difference between a total number of leaf nodes of the m-ary merkel tree and a number of the transaction units to be included in the block is within a preset threshold range;
a block header determining module 804, configured to place the root hash value in the block header;
a block to be broadcasted determining module 806, configured to determine a block to be broadcasted according to the block header and the transaction unit to be included in the block.
In the embodiment of the present specification, since the difference between the number of leaf nodes of the mercker tree and the number of transaction units to be broadcasted, which are adopted in the organizational form of transactions in the block chain, is within the preset threshold range, the calculation amount of the hash value of the root node of the mercker tree is reduced, the processing speed of determining the block to be broadcasted by the consensus node is increased, and the transaction processing performance of the block chain is improved.
In short, the above description is only a preferred embodiment of the present disclosure, and is not intended to limit the scope of the present disclosure. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the embodiments of the present disclosure should be included in the protection scope of the embodiments of the present disclosure.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. One typical implementation device is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The embodiments in the present specification are all described in a progressive manner, and the same and similar parts among the embodiments can be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.

Claims (7)

1. A method of block determination in a chain of blocks, the method comprising:
the consensus node determines root hash values of the Mercker trees corresponding to the transaction units to be contained in all the blocks at this time according to a preset Mercker tree, and the difference between the total number of leaf nodes of the Mercker trees and the number of the transaction units to be contained in the blocks is within a preset threshold range;
determining the root hash value of the Mercker tree corresponding to the transaction units to be contained in all the blocks at this time according to a preset Mercker tree, wherein the determining comprises the following steps:
determining the depth i of the Mercker tree to be constructed according to the number S of transaction units to be contained in the block and the degree m of the preset Mercker tree, wherein the degree of the Mercker tree is the maximum branch number of nodes in the Mercker tree; constructing a full m-fork Merck tree with the depth of i; deleting the subsequent leaf nodes including the (S +1) th number from the leaf nodes of the initial numbered Merckel tree; starting from the depth i-j (j ═ 1, …, i) of the merkel tree, if the child nodes of the node of said depth are all empty, deleting said node; if any child node of the node with the depth is not empty, presetting the rest empty child nodes of the node as a node X; repeating the processing steps of the child nodes of the node until the depth is 0; according to the constructed Mercker tree, determining the root hash value of the Mercker tree corresponding to the transaction units to be contained in all the blocks at this time according to the hash value of the transaction unit to be contained in each block; or,
according to
Figure FDA0003046677240000011
Determining a coefficient kiWherein S is the number of transaction units to be contained in the block, m is the degree of the default Mercker tree,
Figure FDA0003046677240000012
represents rounding down; determining a set G comprising non-zero ki(ii) a According to the sequence from the big to the small of i, respectively taking k corresponding to i in the set GiConstruction of kiA full m-fork Merck tree of height i as the top k of the root node R of the Merck treeiThe branch of each child node is the (k) th branch of the root node Ri+1) child nodes set as nodes to be constructedPoint xi(ii) a Continuing to take k corresponding to i from the set GiBuilding node xiUntil the smallest i; according to the constructed Mercker tree, determining the root hash value of the Mercker tree corresponding to the transaction units to be contained in all the blocks at this time according to the hash value of the transaction unit to be contained in each block;
storing the root hash value into a block header;
and determining a block to be broadcasted according to the block header and a transaction unit to be contained in the block.
2. The method of claim 1, wherein the predetermined threshold is logmn, m is the degree of the default Mercker tree, and n is the total number of transaction units to be included in the block.
3. The method of claim 1, wherein determining the depth i of the merkel tree to be constructed according to the number S of transaction units to be contained in the block and the degree m of the merkel tree, comprises:
according to the formula
Figure FDA0003046677240000021
Determining the depth i of the Mercker tree to be constructed, wherein S is the number of transaction units to be contained in the block, m is the degree of the Mercker tree which is preset,
Figure FDA0003046677240000022
indicating rounding up.
4. An apparatus for determining blocks in a block chain, the apparatus comprising:
the root hash value determining module is used for determining root hash values of the Mercker trees corresponding to the transaction units to be contained in all the blocks at this time according to preset Mercker trees, and the difference between the total number of leaf nodes of the m-fork Mercker trees and the number of the transaction units to be contained in the blocks is within a preset threshold range;
the root hash value determining module is specifically configured to determine a depth i of a merkel tree to be constructed according to the number S of transaction units to be included in a block and a preset degree m of the merkel tree, where the degree of the merkel tree is a maximum number of branches of nodes in the merkel tree; constructing a full m-fork Merck tree with the depth of i; deleting the subsequent leaf nodes including the (S +1) th number from the leaf nodes of the initial numbered Merckel tree; starting from the depth i-j (j ═ 1, …, i) of the merkel tree, if the child nodes of the node of said depth are all empty, deleting said node; if any child node of the node with the depth is not empty, presetting the rest empty child nodes of the node as a node X; repeating the processing steps of the child nodes of the node until the depth is 0; according to the constructed Mercker tree, determining the root hash value of the Mercker tree corresponding to the transaction units to be contained in all the blocks at this time according to the hash value of the transaction unit to be contained in each block; or,
in particular for according to
Figure FDA0003046677240000023
Determining a coefficient kiWherein S is the number of transaction units to be contained in the block, m is the degree of the default Mercker tree,
Figure FDA0003046677240000024
represents rounding down; determining a set G comprising non-zero ki(ii) a According to the sequence from the big to the small of i, respectively taking k corresponding to i in the set GiConstruction of kiA full m-fork Merck tree of height i as the top k of the root node R of the Merck treeiThe branch of each child node is the (k) th branch of the root node Ri+1) child node set as node x to be constructedi(ii) a Continuing to take k corresponding to i from the set GiBuilding node xiUntil the smallest i; according to the constructed Mercker tree, determining the root hash value of the Mercker tree corresponding to the transaction units to be contained in all the blocks at this time according to the hash value of the transaction unit to be contained in each block;
a block header determining module, configured to place the root hash value in the block header;
and the block to be broadcasted determining module is used for determining the block to be broadcasted according to the block header and the transaction units to be contained in the block.
5. The apparatus according to claim 4, wherein the root hash value determining module, when determining the depth i of the merkel tree to be constructed according to the number S of transaction units to be included in the block and the degree m of the merkel tree preset, is specifically configured to:
according to the formula
Figure FDA0003046677240000031
Determining the depth i of the Mercker tree to be constructed, wherein S is the number of transaction units to be contained in the block, m is the degree of the Mercker tree which is preset,
Figure FDA0003046677240000032
indicating rounding up.
6. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the computer program being executed by the processor to perform the method of claim 1.
7. A computer readable storage medium storing one or more programs which, when executed by an electronic device including a plurality of application programs, cause the electronic device to perform the method of claim 1.
CN201811346466.1A 2018-11-13 2018-11-13 Block determining method and device in block chain and electronic equipment Active CN109409889B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811346466.1A CN109409889B (en) 2018-11-13 2018-11-13 Block determining method and device in block chain and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811346466.1A CN109409889B (en) 2018-11-13 2018-11-13 Block determining method and device in block chain and electronic equipment

Publications (2)

Publication Number Publication Date
CN109409889A CN109409889A (en) 2019-03-01
CN109409889B true CN109409889B (en) 2021-11-12

Family

ID=65472989

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811346466.1A Active CN109409889B (en) 2018-11-13 2018-11-13 Block determining method and device in block chain and electronic equipment

Country Status (1)

Country Link
CN (1) CN109409889B (en)

Families Citing this family (18)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110113186A (en) * 2019-04-19 2019-08-09 浙江万胜智能科技股份有限公司 A kind of mixing smart city network structure based on block chain
CN112019586B (en) * 2019-05-29 2023-04-07 国际商业机器公司 Method and system for verification of blockchains
WO2019179539A2 (en) * 2019-07-11 2019-09-26 Alibaba Group Holding Limited Shared blockchain data storage
WO2019179540A2 (en) 2019-07-11 2019-09-26 Alibaba Group Holding Limited Shared blockchain data storage
CN111837115B (en) 2019-07-11 2024-09-10 创新先进技术有限公司 Shared blockchain data storage
CN110602239B (en) * 2019-09-20 2023-09-19 腾讯科技(深圳)有限公司 Block chain information storage method and related equipment
CN110784521B (en) * 2019-09-30 2022-05-27 远光软件股份有限公司 Block chain consensus method, electronic device and storage medium
CN110602148B (en) * 2019-10-10 2021-07-06 深圳前海微众银行股份有限公司 Method and device for generating state tree of block and verifying data on chain
CN110941613B (en) * 2019-11-19 2023-07-18 北京工业大学 Block chain consensus method and device and electronic equipment
CN111045892A (en) * 2019-12-11 2020-04-21 北京菲林方德科技有限公司 Method and device for detecting process state of intelligent contract execution
CN111275552B (en) * 2020-01-20 2023-09-08 广州亚美信息科技有限公司 Block chain-based data processing method and device and computer equipment
CN111314086A (en) * 2020-02-11 2020-06-19 上海宓猿信息技术有限公司 Method for implementing block chain privacy protocol
CN111447069B (en) * 2020-03-23 2021-10-26 腾讯科技(深圳)有限公司 Low-frequency access data processing method based on block chain
CN111553669B (en) * 2020-04-28 2021-09-10 腾讯科技(深圳)有限公司 Transaction routing method, device and computer readable storage medium
CN111553670B (en) * 2020-04-28 2021-10-15 腾讯科技(深圳)有限公司 Transaction processing method and device and computer readable storage medium
CN111523897B (en) * 2020-05-06 2023-04-07 杭州复杂美科技有限公司 Anti-attack method, device and storage medium
CN111651300B (en) * 2020-06-05 2023-03-21 成都质数斯达克科技有限公司 Block chain data recovery method, device, equipment and medium
CN112702400A (en) * 2020-12-15 2021-04-23 北京链飞未来科技有限公司 Block chain cross-chain transaction verification method based on multi-stage Mercker tree

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107657438A (en) * 2017-09-18 2018-02-02 联动优势科技有限公司 A kind of block chain generation method, data verification method, node and system
CN107807951A (en) * 2017-09-18 2018-03-16 联动优势科技有限公司 A kind of block chain generation method, data verification method, node and system
CN107909369A (en) * 2017-10-13 2018-04-13 布比(北京)网络技术有限公司 Based on the common recognition method, apparatus merchandised across chain and storage medium
CN108604336A (en) * 2016-02-02 2018-09-28 科因普拉格株式会社 The method and server of file are serviced and recorded by notarization service verification for providing the notarization to file

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108604336A (en) * 2016-02-02 2018-09-28 科因普拉格株式会社 The method and server of file are serviced and recorded by notarization service verification for providing the notarization to file
CN107657438A (en) * 2017-09-18 2018-02-02 联动优势科技有限公司 A kind of block chain generation method, data verification method, node and system
CN107807951A (en) * 2017-09-18 2018-03-16 联动优势科技有限公司 A kind of block chain generation method, data verification method, node and system
CN107909369A (en) * 2017-10-13 2018-04-13 布比(北京)网络技术有限公司 Based on the common recognition method, apparatus merchandised across chain and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
区块链技术与应用前瞻综述;何蒲 等;《计算机科学》;20170430;第44卷(第4期);全文 *

Also Published As

Publication number Publication date
CN109409889A (en) 2019-03-01

Similar Documents

Publication Publication Date Title
CN109409889B (en) Block determining method and device in block chain and electronic equipment
CN109447810B (en) Parallel block chain consensus method, system, electronic device and computer-readable storage medium
CN108648078B (en) Transaction preprocessing method and device and electronic equipment
US11626972B2 (en) Data processing method and apparatus
JP6804668B2 (en) Block data validation method and equipment
CN109669709B (en) Data migration method and data migration system for block chain upgrading
CN108521328B (en) Block chain consensus method and device and electronic equipment
CN109474682B (en) Block chain network transmission method and device and electronic equipment
CN111522833B (en) Updating method and device of MPT tree in block chain and electronic equipment
CN108881120B (en) Data processing method and device based on block chain
CN110020859B (en) Parallel execution block chain consensus method and device and electronic equipment
CN108846749B (en) Partitioned transaction execution system and method based on block chain technology
CN108765159B (en) Block chain-based uplink and state processing method and device and interconnection system
CN110061930B (en) Method and device for determining data flow limitation and flow limiting values
CN112598321B (en) Risk prevention and control method, system and terminal equipment
CN115190078B (en) Access flow control method, device, equipment and storage medium
CN110659905A (en) Transaction verification method, device, terminal equipment and storage medium
CN111698244A (en) Method and device for rapidly participating in consensus of newly added nodes and electronic equipment
CN112860758B (en) Searching method, searching device, electronic equipment and computer storage medium
CN109345081B (en) Data acquisition method and device and electronic equipment
CN111861744A (en) Method for realizing parallelization of block chain transaction and block chain link point
CN110648125A (en) Packaging transaction method and device and electronic equipment
CN117271571A (en) Database uniqueness constraint processing method, device, equipment and storage medium
CN112199450A (en) Relation graph building method and device and electronic equipment
CN111769984A (en) Method for adding nodes in block chain network and block chain system

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
EE01 Entry into force of recordation of patent licensing contract

Application publication date: 20190301

Assignee: Hangzhou Xita Technology Co.,Ltd.

Assignor: CRYPTAPE Co.,Ltd.

Contract record no.: X2021980015760

Denomination of invention: A block determination method, device and electronic equipment in blockchain

Granted publication date: 20211112

License type: Common License

Record date: 20211229

EE01 Entry into force of recordation of patent licensing contract
TR01 Transfer of patent right

Effective date of registration: 20231221

Address after: 10/F, Guotou Building, No. 398 Shaoxing Road, Gongshu District, Hangzhou City, Zhejiang Province, 310000

Patentee after: Hangzhou Xita Technology Co.,Ltd.

Address before: Room 1301, block a, Huaxing Times Square, 478 Wensan Road, Xihu District, Hangzhou City, Zhejiang Province, 310013

Patentee before: CRYPTAPE Co.,Ltd.

TR01 Transfer of patent right