CN111063092A - Lottery drawing method and device based on block chain, electronic equipment and storage medium - Google Patents

Lottery drawing method and device based on block chain, electronic equipment and storage medium Download PDF

Info

Publication number
CN111063092A
CN111063092A CN201910979232.9A CN201910979232A CN111063092A CN 111063092 A CN111063092 A CN 111063092A CN 201910979232 A CN201910979232 A CN 201910979232A CN 111063092 A CN111063092 A CN 111063092A
Authority
CN
China
Prior art keywords
lottery
lottery drawing
node
nodes
result
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
Application number
CN201910979232.9A
Other languages
Chinese (zh)
Other versions
CN111063092B (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.)
Beijing Haiyi Tongzhan Information Technology Co Ltd
Original Assignee
Beijing Haiyi Tongzhan Information Technology 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 Beijing Haiyi Tongzhan Information Technology Co Ltd filed Critical Beijing Haiyi Tongzhan Information Technology Co Ltd
Priority to CN201910979232.9A priority Critical patent/CN111063092B/en
Publication of CN111063092A publication Critical patent/CN111063092A/en
Application granted granted Critical
Publication of CN111063092B publication Critical patent/CN111063092B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G07CHECKING-DEVICES
    • G07CTIME OR ATTENDANCE REGISTERS; REGISTERING OR INDICATING THE WORKING OF MACHINES; GENERATING RANDOM NUMBERS; VOTING OR LOTTERY APPARATUS; ARRANGEMENTS, SYSTEMS OR APPARATUS FOR CHECKING NOT PROVIDED FOR ELSEWHERE
    • G07C15/00Generating random numbers; Lottery apparatus
    • 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/389Keeping log of transactions for guaranteeing non-repudiation of a transaction
    • 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
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/06Asset management; Financial planning or analysis
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/02Details
    • H04L12/16Arrangements for providing special services to substations
    • H04L12/18Arrangements for providing special services to substations for broadcast or conference, e.g. multicast
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]

Abstract

The invention relates to a lottery drawing method and device based on a block chain, electronic equipment and a storage medium, wherein the method comprises the following steps: if the intelligent contract to be executed exists, calling the intelligent contract to generate a node lottery drawing result aiming at the lottery drawing; determining lottery drawing information of the lottery drawing, and adding node lottery drawing results and signature information of the node lottery drawing results in the lottery drawing information; summarizing the node lottery drawing results of all nodes of the block chain to obtain a summarized result; broadcasting a broadcast message containing summary information of the summary results and lottery information to other nodes in the blockchain so as to summarize the lottery results with the nodes of the other nodes in the blockchain; and processing the summarized broadcast messages according to a consensus mechanism to obtain a consensus lottery result. The embodiment of the invention can effectively avoid centralized lottery drawing results, so that the lottery drawing results are more convincing; and the problem that the server cannot draw lottery caused by abnormal conditions such as restarting and the like during centralized lottery drawing can be avoided.

Description

Lottery drawing method and device based on block chain, electronic equipment and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a lottery drawing method and apparatus based on a blockchain, an electronic device, and a storage medium.
Background
At present, a plurality of timing lottery activities exist, the processes of the timing lottery activities are not disclosed, the timing lottery activities are easily interfered by people, and cheating behaviors are easily generated under the condition of lack of strict and effective supervision; even if the supervision is strengthened, the problems of fairness, justness and efficiency still cannot be fundamentally solved because the opaqueness and randomness of the lottery operation mode are not ideal, and the trust of users cannot be obtained due to the opaque lottery rules and the lottery process of the camera bellows. Including the currently disputed lottery system, etc., the opaqueness is a problem, which will inevitably cause public doubt.
Disclosure of Invention
In order to solve the technical problems described above or at least partially solve the technical problems, the present invention provides a lottery method based on a blockchain, an apparatus, an electronic device, and a storage medium.
In a first aspect, the present invention provides a lottery method based on a blockchain, which is applied to a node of the blockchain, and includes:
if the intelligent contract to be executed exists, calling the intelligent contract to generate a node lottery drawing result aiming at the lottery drawing;
determining lottery drawing information of the lottery drawing, and adding node lottery drawing results and signature information of the node lottery drawing results in the lottery drawing information;
summarizing the node lottery drawing results of all nodes of the block chain to obtain a summarized result;
broadcasting a broadcast message containing summary information of the summary results and lottery information to other nodes in the blockchain so as to summarize the lottery results with the nodes of the other nodes in the blockchain;
and processing the summarized broadcast messages according to a consensus mechanism to obtain a consensus lottery result.
Optionally, the method further comprises:
determining whether the node is a lottery drawing node participating in the lottery drawing according to preset node weight information;
and if the self is the lottery node, executing the step of calling the intelligent contract.
Optionally, the method further comprises:
detecting whether the current time reaches the execution time of the intelligent contract or not at fixed time by using a timer;
and if the current time reaches the execution time of the intelligent contract, determining that the intelligent contract to be executed exists.
Optionally, the method further comprises:
if the node is a non-lottery node which does not participate in lottery, receiving broadcast messages sent by other nodes;
verifying the broadcast message;
if the broadcast message fails to be verified, discarding the broadcast message;
if the broadcast message is successfully verified, determining whether the node lottery drawing results of all the nodes of the block chain are collected according to the broadcast message;
if the node lottery drawing result summarization of all the nodes of the block chain is not finished, broadcasting a broadcast message;
and if the node lottery drawing results of all the nodes of the block chain are collected, broadcasting the broadcast message, storing the broadcast message into a local transaction buffer pool, and waiting for the consensus with other nodes.
Optionally, verifying the broadcast message includes:
extracting lottery contents and lottery marks from the received lottery information of the broadcast message;
generating a lottery drawing identifier according to the contract address, the lottery drawing time and the lottery drawing times in the lottery drawing content;
if the generated lottery drawing identification is different from the extracted lottery drawing identification, determining that the verification fails;
alternatively, the first and second electrodes may be,
determining whether the extracted lottery drawing identification is written into a transaction buffer pool or an account book;
if the extracted lottery drawing identification is written into a transaction buffer pool or an account book, determining that the verification fails;
alternatively, the first and second electrodes may be,
acquiring signature information in the broadcast message;
determining whether the signature information is correct according to a preset public key;
if the signature information is wrong, determining that the verification fails;
alternatively, the first and second electrodes may be,
acquiring weight information of other nodes sending broadcast messages;
determining whether the other nodes are lottery drawing nodes participating in the lottery drawing according to the weight information;
if the other nodes are not lottery drawing nodes participating in the lottery drawing, determining that the verification fails;
alternatively, the first and second electrodes may be,
summarizing the node lottery drawing results of all nodes of the block chain to obtain a summarized result;
comparing the summary result obtained by summarizing with the summary result in the received broadcast message;
and if the summarized result obtained by the summarization is different from the summarized result in the received broadcast message, determining that the verification fails.
Optionally, verifying the broadcast message includes:
and if the generated lottery drawing identification is the same as the extracted lottery drawing identification, the extracted lottery drawing identification is written into a transaction buffer pool or an account book, if the signature information is correct, if the other nodes are the lottery drawing nodes participating in the lottery drawing, and the summarized result obtained by summarizing is the same as the summarized result in the received broadcast message, the verification is determined to be successful.
Optionally, before invoking the intelligent contract and generating the node lottery result for the current lottery, the method further comprises:
if receiving the broadcast message sent by other nodes, verifying the broadcast message;
if the broadcast message fails to be verified, discarding the received broadcast message;
if the broadcast message is successfully verified, executing a step of calling an intelligent contract to generate a node lottery result aiming at the lottery;
adding the lottery drawing information and the summary result of the lottery drawing to the broadcast message;
determining whether the node lottery drawing results of all nodes of the block chain are collected;
if the node lottery drawing results of all nodes of the block chain are not completely summarized, broadcasting additional lottery drawing information and a broadcast message after the result is summarized;
if the node lottery drawing results of all the nodes of the block chain are collected, broadcasting additional lottery drawing information and the broadcast information after the results are collected, storing the broadcast information into a local transaction buffer pool, and waiting for consensus with other nodes.
Optionally, after invoking the intelligent contract to generate the node lottery result for the current lottery, the method further includes:
if receiving the broadcast message sent by other nodes, verifying the broadcast message;
if the broadcast message fails to be verified, discarding the received broadcast message;
if the broadcast message is successfully verified, determining whether the node lottery drawing result is located in the received broadcast message;
if the node lottery drawing result is not located in the broadcast message, adding the lottery drawing information and the summary result of the lottery drawing to the broadcast message;
determining whether the node lottery drawing results of all nodes of the block chain are collected;
if the node lottery drawing results of all nodes of the block chain are not completely summarized, broadcasting additional lottery drawing information and a broadcast message after the result is summarized;
if the node lottery drawing results of all the nodes of the block chain are collected, broadcasting additional lottery drawing information and the broadcast information after the results are collected, storing the broadcast information into a local transaction buffer pool, and waiting for consensus with other nodes.
Optionally, the processing the summarized broadcast message according to a consensus mechanism to obtain a consensus lottery result, including:
acquiring node lottery drawing results of each node in the broadcast message of the transaction buffer pool;
counting the number of nodes with the same number extracted aiming at each digital bit in the node lottery result of each node;
determining the number extracted from the maximum number of nodes as the common identification number of the digital bit;
and obtaining the consensus lottery result based on the consensus numbers of the digital bits.
In a second aspect, the present invention provides a lottery device based on a blockchain, applied to a node of the blockchain, including:
the calling module is used for calling the intelligent contract if the intelligent contract to be executed exists, and generating a node lottery drawing result aiming at the lottery drawing;
the determining module is used for determining the lottery drawing information of the lottery drawing, and adding node lottery drawing results and signature information of the node lottery drawing results in the lottery drawing information;
the summarizing module is used for summarizing the node lottery drawing results of all the nodes of the block chain to obtain a summarizing result;
the broadcasting module is used for broadcasting a broadcasting message containing the summary information of the summary results and the lottery drawing information to other nodes in the blockchain so as to summarize the lottery drawing results of the nodes of the blockchain;
and the consensus processing module is used for processing the summarized broadcast message according to a consensus mechanism to obtain a consensus lottery result.
In a third aspect, the present invention provides an electronic device, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete mutual communication through the communication bus;
a memory for storing a computer program;
and a processor configured to implement the block chain-based lottery method according to any one of the first aspect when executing the program stored in the memory.
In a fourth aspect, the present invention provides a computer-readable storage medium having stored thereon a program for a blockchain-based lottery method, the program for a blockchain-based lottery method implementing the steps of the blockchain-based lottery method of any one of the first aspect when executed by a processor.
Compared with the prior art, the technical scheme provided by the embodiment of the invention has the following advantages:
the method comprises the steps of firstly calling the intelligent contract when the intelligent contract to be executed exists, generating a node lottery result aiming at the lottery, then determining the lottery information of the lottery, adding the node lottery result and signature information of the node lottery result in the lottery information, summarizing the node lottery results of all nodes in a block chain to obtain a summarized result, broadcasting the summarized information containing the summarized result and the broadcast message of the lottery information to other nodes in the block chain so as to summarize the node lottery results of other nodes in the block chain, and finally processing the summarized broadcast message according to a consensus mechanism to obtain a consensus result.
According to the embodiment of the invention, through a decentralized mechanism of the blockchain system, each lottery is participated by a plurality of nodes, and finally the lottery results of the nodes are collected; moreover, the lottery result of the plurality of nodes in the blockchain is collected to obtain the consensus lottery result, so that when any node is abnormal, the lottery result can be still obtained by collecting the lottery results of the other nodes, and the embodiment of the invention can also avoid the problem that the lottery cannot be drawn when the server is abnormal, such as restarting and the like, during centralized lottery.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention.
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without inventive exercise.
Fig. 1 is a block chain deployment diagram according to an embodiment of the present invention;
fig. 2 is a schematic flowchart of a lottery method based on a blockchain according to an embodiment of the present invention;
fig. 3 is a diagram illustrating a data structure of lottery information and additional lottery results and lottery signatures according to an embodiment of the present invention;
FIG. 4 is a data structure diagram of a summary result provided in accordance with an embodiment of the present invention;
FIG. 5 is a data structure diagram of summary information provided in accordance with an embodiment of the present invention;
fig. 6 is another schematic flow chart of a lottery method based on a blockchain according to an embodiment of the present invention;
fig. 7 is another schematic flow chart of a lottery method based on a blockchain according to an embodiment of the present invention;
fig. 8 is another schematic flow chart of a lottery method based on a blockchain according to an embodiment of the present invention;
fig. 9 is another schematic flow chart of a lottery method based on a blockchain according to an embodiment of the present invention;
fig. 10 is a block diagram of a lottery apparatus based on a blockchain according to an embodiment of the present invention;
fig. 11 is a block diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be obtained by a person skilled in the art without any inventive step based on the embodiments of the present invention, are within the scope of the present invention.
The invention provides a lottery method, a device, an electronic device and a storage medium based on a block chain, the lottery method based on the block chain is applied to nodes of the block chain, all the nodes contained in the block chain are lottery nodes, but each lottery node has own preset weight information, and the preset weight information is used for distinguishing the roles of different nodes in the lottery process, such as: which nodes participate in the lottery at a certain lottery time point, which nodes do not participate in the lottery, and so on.
One possible lottery drawing method is that eight points in the morning and eight points in the evening each day perform a lottery drawing task, and the lottery drawing tasks are mapped to the blockchain deployment diagram shown in fig. 1, wherein the nodes at the upper right corner and the lower left corner perform the lottery drawing tasks at eight points in the morning, and the nodes at the upper left corner and the lower right corner perform the lottery drawing tasks at eight points in the evening. How to set the specific preset weight information can be independently defined by the service party, and the weight can be stored by adopting various schemes, such as: the weight of each node is hard coded into the node (meaning that the weight of the node is fixed after it is created); or writing the weights of the nodes into the blockchain network.
As shown in fig. 2, the lottery method based on the blockchain may include the steps of:
step S101, if an intelligent contract to be executed exists, the intelligent contract is called, and a node lottery result aiming at the lottery is generated;
in the embodiment of the invention, the intelligent contract refers to a lottery drawing rule realized by using codes, for example, 6 numbers are randomly selected from 1 to 33, and 1 number is randomly selected from 1 to 16.
The intelligent contract is public, can be effectively judged by a third party mechanism or an experienced person, and the whole lottery drawing process is transparent, so that the question of the public on the lottery drawing activity is reduced.
Before the step, a timer can be used for detecting whether the current time reaches the execution time of the intelligent contract or not; and if the current time reaches the execution time of the intelligent contract, determining that the intelligent contract to be executed exists.
In the embodiment of the invention, each node is correspondingly provided with a timer which is used for checking when the contract stored in the account book is executed or whether the contract needs to be executed, the service system is simpler through the timed execution of the intelligent contract, the maintenance is basically not needed after the contract is issued once, the execution is fully automatic, and the operation cost is effectively reduced.
Before the intelligent contract is called, whether the intelligent contract is a lottery drawing node participating in the lottery drawing can be determined according to preset node weight information; and if the intelligent contract is the lottery drawing node, executing the step of calling the intelligent contract. Whether different nodes participate in lottery or not is distinguished by utilizing preset weight information, so that the problem that final results are too average to reflect lottery results due to too many participating nodes can be solved.
Step S102, determining lottery drawing information of the lottery drawing, and adding the node lottery drawing result and signature information of the node lottery drawing result in the lottery drawing information;
the node automatically calculates a lottery identifier in each lottery, which may be, for example, a lottery ID, and the lottery ID is generated by calculating (e.g., hash algorithm) the intelligent contract address, the lottery time, and the number of lottery performed by the node, and the lottery IDs generated by all the lottery nodes at the same time are consistent in order to distinguish different rounds of lottery, so that the lottery IDs of different rounds of lottery are different, and the problem of repeated execution of lottery can be effectively handled by the lottery ID.
As shown in fig. 3, the lottery information may include lottery contents, lottery ID, etc., and the lottery contents may refer to lottery names, lottery period numbers, etc., for example: SS ball, phase 062, etc.
The addition of the node lottery result and the signature information of the result in the lottery information means that the lottery result, the lottery signature and the lottery information are broadcasted together, and the lottery result and the lottery signature contained in fig. 3 are accumulated in the continuous broadcasting process of each node in a block chain, so that the subsequent collection is more convenient.
Step S103, summarizing the node lottery drawing results of all the nodes of the block chain to obtain a summarized result;
in the embodiment of the present invention, the summarizing refers to adding together the number of certain values extracted by all nodes for a certain bit to generate a Map result, that is, a Map (lottery result, which corresponds to the number of nodes), where Key of the Map is a lottery result (often a number, such as the lottery result X or the lottery result Y in fig. 4), and Value is the number extracted to the Value (such as the number of nodes corresponding to X or the number of nodes corresponding to Y in fig. 4).
The lottery results are then aggregated for easier aggregation by other nodes in the future. The following is a data structure of the lottery result with a plurality of signature nodes attached:
when the contract draw is first generated, whether it is done collectively is no (we need multiple nodes to be summed to collect the final result).
Step S104, broadcasting the summary information containing the summary results and the broadcast information of the lottery drawing information to other nodes in the block chain so as to summarize the lottery drawing results of the nodes of other nodes in the block chain;
the summary information is shown in fig. 5, and includes a summary result, a summary time, a summary node signature, and a field of whether to complete summary, where when a contract lottery is first generated, since it is necessary that lottery results of a plurality of nodes are summarized before a final consensus lottery result is collected, whether to complete summary field is default to no, and only after summary is completed, it is modified to yes.
The transmission process of the broadcast message among different nodes participating in the lottery is accompanied by the summary of the lottery results.
And step S105, processing the summarized broadcast messages according to a consensus mechanism to obtain a consensus lottery result.
In this step, the nodes may agree with the lottery drawing results of the plurality of nodes participating in the lottery drawing according to an agreement mechanism, and after the agreement is completed, each node writes the agreement lottery drawing results into the local account book of its own node, so far, the lottery drawing process of this round is finished.
In the embodiment of the invention, when an intelligent contract to be executed exists, the intelligent contract is called first to generate a node lottery result for the lottery, then the lottery information for the lottery is determined, the node lottery result and signature information of the node lottery result are added to the lottery information, then the node lottery results of all nodes of the block chain are summarized to obtain a summarized result, the summarized information containing the summarized result and the broadcast message of the lottery information are broadcast to other nodes in the block chain so as to be summarized with the node lottery results of other nodes of the block chain, and finally the summarized broadcast message can be processed according to a consensus mechanism to obtain a consensus result.
According to the embodiment of the invention, through a decentralized mechanism of the blockchain system, each lottery is participated by a plurality of nodes, and finally the lottery results of the nodes are collected; moreover, the lottery result of the plurality of nodes in the blockchain is collected to obtain the consensus lottery result, so that when any node is abnormal, the lottery result can be still obtained by collecting the lottery results of the other nodes, and the embodiment of the invention can also avoid the problem that the lottery cannot be drawn when the server is abnormal, such as restarting and the like, during centralized lottery.
In yet another embodiment of the present invention, as shown in fig. 6, the method further includes:
step S301, if the node itself is a non-lottery node which does not participate in lottery, receiving broadcast messages sent by other nodes;
in the embodiment of the present invention, the non-lottery node which is not involved in the lottery by itself means a node which does not participate in the lottery according to the preset weight information for the lottery in this round.
Step S302, verifying the broadcast message;
in one embodiment of the present invention, the lottery contents and the lottery identifiers are extracted from the received lottery information of the broadcast message; generating a lottery drawing identifier according to the contract address, the lottery drawing time and the lottery drawing times in the lottery drawing content; if the generated lottery drawing identification is different from the extracted lottery drawing identification, determining that the verification fails;
alternatively, the first and second electrodes may be,
in yet another embodiment of the present invention, it is determined whether the extracted lottery ticket identifier is written into a transaction buffer pool or an account book; if the extracted lottery drawing identification is written into a transaction buffer pool or an account book, determining that the verification fails;
alternatively, the first and second electrodes may be,
in yet another embodiment of the present invention, signature information in the broadcast message is obtained; determining whether the signature information is correct according to a preset public key; if the signature information is wrong, determining that the verification fails;
alternatively, the first and second electrodes may be,
in another embodiment of the present invention, weight information of other nodes that transmit the broadcast message is obtained; determining whether the other nodes are lottery drawing nodes participating in the lottery drawing according to the weight information; if the other nodes are not lottery drawing nodes participating in the lottery drawing, determining that the verification fails;
alternatively, the first and second electrodes may be,
in another embodiment of the present invention, the node lottery results of all nodes of the blockchain are summarized to obtain a summarized result; comparing the summarized result obtained by summarizing with the summarized result in the received broadcast message; and if the summarized result obtained by the summarization is different from the summarized result in the received broadcast message, determining that the verification fails.
The above are all cases of verification failure, and only when the above procedures are all verified, that is: and if the generated lottery drawing identification is the same as the extracted lottery drawing identification, writing the extracted lottery drawing identification into a transaction buffer pool or an account book, and if the signature information is correct, if the other nodes are lottery drawing nodes participating in the lottery drawing, and the summarized result obtained by summarizing is the same as the summarized result in the received broadcast message, determining that the verification is successful.
Step S303, if the broadcast message fails to be verified, discarding the broadcast message;
step S304, if the broadcast message is successfully verified, determining whether the node lottery drawing results of all the nodes of the block chain are collected according to the broadcast message;
in this step, whether the summary is completed may be determined according to a whether summary completion field of the summary information in the broadcast message.
Step S305, if the node lottery drawing result summarization of all the nodes of the block chain is not finished, broadcasting the broadcast message;
step S306, if the node lottery drawing results of all the nodes of the block chain are collected, broadcasting the broadcast message, storing the broadcast message into a local transaction buffer pool, and waiting for the agreement with other nodes.
The embodiment of the invention can receive the broadcast message when the node is a non-lottery node which does not participate in lottery in the current round, verify the broadcast message, discard the broadcast message when the verification fails, store the broadcast message into the transaction buffer pool if the collection is completed when the verification succeeds, wait for consensus, and broadcast the received broadcast message if the collection is not completed, which is equivalent to the function of a transfer node, thereby helping to realize the collection of lottery results among a plurality of lottery-participating nodes.
In another embodiment of the present invention, before invoking the intelligent contract to generate the node lottery result for the current lottery in step S101, as shown in fig. 7, the method further includes:
step S401, if receiving broadcast messages sent by other nodes, verifying the broadcast messages;
step S402, if the broadcast message fails to be verified, discarding the received broadcast message;
step S403, if the broadcast message is successfully verified, executing the step of calling the intelligent contract to generate a node lottery result aiming at the lottery;
step S404, adding the lottery drawing information and the summary result of the lottery drawing to the broadcast message;
step S405, determining whether the node lottery drawing results of all the nodes of the block chain are collected;
step S406, if the node lottery result summarization of all the nodes of the block chain is not finished, broadcasting additional lottery information and the broadcast message after summarizing the result;
step S407, if the node lottery drawing results of all the nodes of the block chain are collected, broadcasting additional lottery drawing information and the broadcast message after the result is collected, storing the broadcast message into a local transaction buffer pool, and waiting for consensus with other nodes.
For each lottery node, the broadcast message sent by other nodes for many times is received, when the lottery node receives the broadcast message (the second stage of the lottery node in the flow chart), the condition of finishing summarizing the result is judged in addition to partial verification, if the condition is finished, the summarizing result is summarized, the state of the summarizing result is modified to be finished, and the transaction is written into a transaction pool; and if the condition judgment of the summary result is not met, directly broadcasting the broadcast message.
In another embodiment of the present invention, after invoking the intelligent contract to generate the node lottery result for the current lottery, as shown in fig. 8, the method further comprises:
step S501, if receiving broadcast messages sent by other nodes, verifying the broadcast messages;
step S502, if the broadcast message fails to be verified, discarding the received broadcast message;
step S503, if the broadcast message is successfully verified, determining whether the node lottery drawing result is located in the received broadcast message;
step S504, if the node lottery drawing result is not located in the broadcast message, adding the lottery drawing information and the summary result of the lottery drawing to the broadcast message;
step S505, determining whether the node lottery drawing results of all the nodes of the block chain are collected;
step S506, if the node lottery result summarization of all the nodes of the block chain is not finished, broadcasting additional lottery information and the broadcast message after summarizing the result;
step S507, if the node lottery drawing results of all nodes in the block chain are collected, broadcasting the additional lottery drawing information and the broadcast message after collecting the results, storing the broadcast message in a local transaction buffer pool, and waiting for consensus with other nodes.
For each lottery node, the broadcast message sent by other nodes for many times is received, when the lottery node receives the broadcast message (the second stage of the lottery node in the flow chart), the condition of finishing summarizing the result is judged in addition to partial verification, if the condition is finished, the summarizing result is summarized, the state of the summarizing result is modified to be finished, and the transaction is written into a transaction pool; and if the condition judgment of the summary result is not met, directly broadcasting the broadcast message.
As shown in fig. 9, the step S105 may include the steps of:
step S601, obtaining node lottery drawing results of each node in the broadcast message of the transaction buffer pool;
step S602, counting the number of nodes with the same number extracted according to each digital bit in the node lottery result of each node;
step S603, determining the extracted number with the largest number of nodes as the consensus number of the digital bit;
in step S604, a consensus drawing result is obtained based on the consensus numbers of the respective number bits.
According to the embodiment of the invention, through a consensus mechanism, the result of the lottery drawing based on a plurality of nodes can be obtained, so that a decentralized lottery drawing mode can be realized, each lottery drawing is participated by a plurality of nodes, and the lottery drawing results of each node are finally summarized; moreover, the lottery result of the plurality of nodes in the blockchain is collected to obtain the consensus lottery result, so that when any node is abnormal, the lottery result can be still obtained by collecting the lottery results of the other nodes, and the embodiment of the invention can also avoid the problem that the lottery cannot be drawn when the server is abnormal, such as restarting and the like, during centralized lottery.
In another embodiment of the present invention, there is also provided a lottery device based on a blockchain, applied to a node of the blockchain, as shown in fig. 10, including:
the calling module 11 is configured to call the intelligent contract if an intelligent contract to be executed exists, and generate a node lottery result for the current lottery;
a determining module 12, configured to determine lottery drawing information of the lottery drawing, and add the node lottery drawing result and signature information of the node lottery drawing result to the lottery drawing information;
the summarizing module 13 is configured to summarize node lottery results of all nodes of the blockchain to obtain a summarizing result;
a broadcasting module 14, configured to broadcast a broadcast message including the summary information of the summary results and the lottery information to other nodes in the blockchain so as to summarize the lottery results of the nodes in the blockchain;
and the consensus processing module 15 is configured to process the summarized broadcast message according to a consensus mechanism to obtain a consensus lottery result.
In another embodiment of the present invention, an electronic device is further provided, which includes a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
and the processor is used for realizing the lottery method based on the block chain in the embodiment of the method when executing the program stored in the memory.
In the electronic device provided by the embodiment of the invention, the processor executes the program stored in the memory to realize that if the intelligent contract to be executed exists, the intelligent contract is called to generate a node lottery result aiming at the lottery; determining lottery drawing information of the lottery drawing, and adding the node lottery drawing result and signature information of the node lottery drawing result in the lottery drawing information; summarizing the node lottery drawing results of all the nodes of the block chain to obtain a summarized result; broadcasting a broadcast message containing the summary information of the summary results and the lottery information to other nodes in the blockchain so as to summarize the lottery results with the nodes of other nodes in the blockchain; and processing the summarized broadcast messages according to a consensus mechanism to obtain a consensus lottery result. Through a decentralized mechanism of a blockchain system, each lottery is participated by a plurality of nodes, and finally the lottery results of the nodes are collected; moreover, the lottery result of the plurality of nodes in the blockchain is collected to obtain the consensus lottery result, so that when any node is abnormal, the lottery result can be still obtained by collecting the lottery results of the other nodes, and the embodiment of the invention can also avoid the problem that the lottery cannot be drawn when the server is abnormal, such as restarting and the like, during centralized lottery.
The communication bus 1140 mentioned in the above electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus 1140 may be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one thick line is shown in FIG. 11, but this is not intended to represent only one bus or type of bus.
The communication interface 1120 is used for communication between the electronic device and other devices.
The memory 1130 may include a Random Access Memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The processor 1110 may be a general-purpose processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the integrated circuit may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic device, or discrete hardware components.
In still another embodiment of the present invention, there is also provided a computer-readable storage medium having stored thereon a program for a blockchain-based lottery method, the program for a blockchain-based lottery method being executed by a processor to implement the steps of the blockchain-based lottery method described in the aforementioned method embodiments.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. The procedures or functions according to the embodiments of the invention are brought about in whole or in part when the computer program instructions are loaded and executed on a computer. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by wire (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wirelessly (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid state disk (ssd)), among others.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (12)

1. A lottery method based on a block chain is characterized in that a node applied to the block chain comprises the following steps:
if the intelligent contract to be executed exists, calling the intelligent contract to generate a node lottery drawing result aiming at the lottery drawing;
determining lottery drawing information of the lottery drawing, and adding the node lottery drawing result and signature information of the node lottery drawing result in the lottery drawing information;
summarizing the node lottery drawing results of all the nodes of the block chain to obtain a summarized result;
broadcasting a broadcast message containing the summary information of the summary results and the lottery information to other nodes in the blockchain so as to summarize the lottery results with the nodes of other nodes in the blockchain;
and processing the summarized broadcast messages according to a consensus mechanism to obtain a consensus lottery result.
2. The blockchain-based lottery method according to claim 1, further comprising:
determining whether the node is a lottery drawing node participating in the lottery drawing according to preset node weight information;
and if the intelligent contract is the lottery drawing node, executing the step of calling the intelligent contract.
3. The blockchain-based lottery method according to claim 1, further comprising:
detecting whether the current time reaches the execution time of the intelligent contract or not at fixed time by using a timer;
and if the current time reaches the execution time of the intelligent contract, determining that the intelligent contract to be executed exists.
4. The blockchain-based lottery method according to claim 1, further comprising:
if the node is a non-lottery node which does not participate in lottery, receiving broadcast messages sent by other nodes;
verifying the broadcast message;
if the broadcast message fails to be verified, discarding the broadcast message;
if the broadcast message is successfully verified, determining whether node lottery drawing results of all nodes of the block chain are collected according to the broadcast message;
if the node lottery drawing result summarization of all the nodes of the block chain is not finished, broadcasting the broadcast message;
and if the node lottery drawing results of all the nodes of the block chain are collected, broadcasting the broadcast message, storing the broadcast message into a local transaction buffer pool, and waiting for consensus with other nodes.
5. The blockchain-based lottery method of claim 4, wherein verifying the broadcast message comprises:
extracting lottery contents and lottery marks from the received lottery information of the broadcast message;
generating a lottery drawing identifier according to the contract address, the lottery drawing time and the lottery drawing times in the lottery drawing content;
if the generated lottery drawing identification is different from the extracted lottery drawing identification, determining that the verification fails;
alternatively, the first and second electrodes may be,
determining whether the extracted lottery drawing identification is written into a transaction buffer pool or an account book;
if the extracted lottery drawing identification is written into a transaction buffer pool or an account book, determining that the verification fails;
alternatively, the first and second electrodes may be,
acquiring signature information in the broadcast message;
determining whether the signature information is correct according to a preset public key;
if the signature information is wrong, determining that the verification fails;
alternatively, the first and second electrodes may be,
acquiring weight information of other nodes sending the broadcast message;
determining whether the other nodes are lottery drawing nodes participating in the lottery drawing according to the weight information;
if the other nodes are not lottery drawing nodes participating in the lottery drawing, determining that the verification fails;
alternatively, the first and second electrodes may be,
summarizing the node lottery drawing results of all the nodes of the block chain to obtain a summarized result;
comparing the summarized result obtained by summarizing with the summarized result in the received broadcast message;
and if the summarized result obtained by the summarization is different from the summarized result in the received broadcast message, determining that the verification fails.
6. The blockchain-based lottery method of claim 5, wherein verifying the broadcast message comprises:
and if the generated lottery drawing identification is the same as the extracted lottery drawing identification, writing the extracted lottery drawing identification into a transaction buffer pool or an account book, and if the signature information is correct, if the other nodes are lottery drawing nodes participating in the lottery drawing, and the summarized result obtained by summarizing is the same as the summarized result in the received broadcast message, determining that the verification is successful.
7. The blockchain-based lottery method according to claim 1, wherein before the intelligent contract is invoked to generate a node lottery result for the current lottery, the method further comprises:
if receiving broadcast messages sent by other nodes, verifying the broadcast messages;
if the broadcast message fails to be verified, discarding the received broadcast message;
if the broadcast message is successfully verified, executing the step of calling the intelligent contract to generate a node lottery result aiming at the lottery;
adding the lottery drawing information and the summary result of the lottery drawing to the broadcast message;
determining whether the node lottery drawing results of all nodes of the block chain are collected;
if the node lottery drawing results of all nodes of the block chain are not completely summarized, broadcasting additional lottery drawing information and the broadcast message after the result is summarized;
if the node lottery drawing results of all the nodes of the block chain are collected, broadcasting additional lottery drawing information and the broadcast information after the results are collected, storing the broadcast information into a local transaction buffer pool, and waiting for consensus with other nodes.
8. The blockchain-based lottery method according to claim 1, wherein after the intelligent contract is invoked to generate a node lottery result for the current lottery, the method further comprises:
if receiving broadcast messages sent by other nodes, verifying the broadcast messages;
if the broadcast message fails to be verified, discarding the received broadcast message;
if the broadcast message is successfully verified, determining whether the node lottery drawing result is located in the received broadcast message;
if the node lottery drawing result is not located in the broadcast message, adding the lottery drawing information and the summary result of the lottery drawing to the broadcast message;
determining whether the node lottery drawing results of all nodes of the block chain are collected;
if the node lottery drawing results of all nodes of the block chain are not completely summarized, broadcasting additional lottery drawing information and the broadcast message after the result is summarized;
if the node lottery drawing results of all the nodes of the block chain are collected, broadcasting additional lottery drawing information and the broadcast information after the results are collected, storing the broadcast information into a local transaction buffer pool, and waiting for consensus with other nodes.
9. The blockchain-based lottery method according to claim 4, 8 or 7, wherein the step of processing the aggregated broadcast messages according to a consensus mechanism to obtain a consensus lottery result comprises:
acquiring node lottery drawing results of each node in the broadcast message of the transaction buffer pool;
counting the number of nodes with the same number extracted aiming at each digital bit in the node lottery result of each node;
determining the number extracted from the maximum number of nodes as the common identification number of the digital bit;
and obtaining the consensus lottery result based on the consensus numbers of the digital bits.
10. A lottery device based on block chain, which is applied to the node of the block chain, includes:
the calling module is used for calling the intelligent contract to generate a node lottery drawing result aiming at the lottery drawing if the intelligent contract to be executed exists;
the determination module is used for determining the lottery drawing information of the lottery drawing, and adding the node lottery drawing result and the signature information of the node lottery drawing result in the lottery drawing information;
the summarizing module is used for summarizing the node lottery drawing results of all the nodes of the block chain to obtain a summarizing result;
a broadcasting module, configured to broadcast a broadcast message including the summary information of the summary result and the lottery drawing information to other nodes in the blockchain, so as to summarize the lottery drawing results with the nodes of other nodes in the blockchain;
and the consensus processing module is used for processing the summarized broadcast message according to a consensus mechanism to obtain a consensus lottery result.
11. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing mutual communication by the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the lottery method based on the blockchain according to any one of claims 1 to 9 when executing the program stored in the memory.
12. A computer-readable storage medium, characterized in that the computer-readable storage medium has stored thereon a program of a blockchain-based lottery method, which when executed by a processor, implements the steps of the blockchain-based lottery method of any one of claims 1 to 9.
CN201910979232.9A 2019-10-15 2019-10-15 Lottery drawing method and device based on block chain, electronic equipment and storage medium Active CN111063092B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910979232.9A CN111063092B (en) 2019-10-15 2019-10-15 Lottery drawing method and device based on block chain, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910979232.9A CN111063092B (en) 2019-10-15 2019-10-15 Lottery drawing method and device based on block chain, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111063092A true CN111063092A (en) 2020-04-24
CN111063092B CN111063092B (en) 2022-02-01

Family

ID=70297725

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910979232.9A Active CN111063092B (en) 2019-10-15 2019-10-15 Lottery drawing method and device based on block chain, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111063092B (en)

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107103405A (en) * 2017-03-22 2017-08-29 暨南大学 A kind of mass-rent system and its building method based on block chain technology
CN107220130A (en) * 2017-05-12 2017-09-29 北京众享比特科技有限公司 A kind of information common recognition method realized at the node of block chain, apparatus and system
CN108074177A (en) * 2017-12-05 2018-05-25 深圳前海微众银行股份有限公司 Data account checking method, system and computer readable storage medium
CN108230047A (en) * 2018-02-05 2018-06-29 武汉斗鱼网络科技有限公司 Data processing method of drawing a lottery and device
CN108600161A (en) * 2018-03-12 2018-09-28 成都零光量子科技有限公司 A kind of fair efficient block chain common recognition method
CN108769173A (en) * 2018-05-21 2018-11-06 阿里体育有限公司 The block chain implementation method and equipment of the intelligent contract of operation
CN109767271A (en) * 2019-01-18 2019-05-17 众安信息技术服务有限公司 Lottery drawing method and equipment based on block chain
CN110084651A (en) * 2019-05-07 2019-08-02 百度在线网络技术(北京)有限公司 A kind of lottery drawing method based on block chain, device and terminal
CN110233852A (en) * 2019-06-24 2019-09-13 北京艾摩瑞策科技有限公司 Prize drawing data cochain method and its equipment based on block chain
CN110310115A (en) * 2019-05-23 2019-10-08 杭州云象网络技术有限公司 A method of realizing that distributed account book is extending transversely based on fragment mechanism

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107103405A (en) * 2017-03-22 2017-08-29 暨南大学 A kind of mass-rent system and its building method based on block chain technology
CN107220130A (en) * 2017-05-12 2017-09-29 北京众享比特科技有限公司 A kind of information common recognition method realized at the node of block chain, apparatus and system
CN108074177A (en) * 2017-12-05 2018-05-25 深圳前海微众银行股份有限公司 Data account checking method, system and computer readable storage medium
CN108230047A (en) * 2018-02-05 2018-06-29 武汉斗鱼网络科技有限公司 Data processing method of drawing a lottery and device
CN108600161A (en) * 2018-03-12 2018-09-28 成都零光量子科技有限公司 A kind of fair efficient block chain common recognition method
CN108769173A (en) * 2018-05-21 2018-11-06 阿里体育有限公司 The block chain implementation method and equipment of the intelligent contract of operation
CN109767271A (en) * 2019-01-18 2019-05-17 众安信息技术服务有限公司 Lottery drawing method and equipment based on block chain
CN110084651A (en) * 2019-05-07 2019-08-02 百度在线网络技术(北京)有限公司 A kind of lottery drawing method based on block chain, device and terminal
CN110310115A (en) * 2019-05-23 2019-10-08 杭州云象网络技术有限公司 A method of realizing that distributed account book is extending transversely based on fragment mechanism
CN110233852A (en) * 2019-06-24 2019-09-13 北京艾摩瑞策科技有限公司 Prize drawing data cochain method and its equipment based on block chain

Also Published As

Publication number Publication date
CN111063092B (en) 2022-02-01

Similar Documents

Publication Publication Date Title
KR102469267B1 (en) Blockchain consensus method, accounting node and node
CN111343208B (en) Block chain-based data detection method and device and computer-readable storage medium
CN109802941A (en) A kind of login validation method, device, storage medium and server
CN110602056B (en) Service parameter transmission method and device
CN111163130B (en) Network service system and data transmission method thereof
WO2020248658A1 (en) Abnormal account detection method and apparatus
CN110134528A (en) Interface message storage call method, device and the terminal device of micro services frame
CN104618316A (en) Method, device and system of safety verification
CN112184436B (en) Data synchronization method, electronic device and readable storage medium
CN112866282A (en) Method and device for verifying time information in block chain
CN110022534B (en) Data transmission method and device based on multicast
US11341842B2 (en) Metering data management system and computer readable recording medium
CN108280024B (en) Flow distribution strategy testing method and device and electronic equipment
CN111063092B (en) Lottery drawing method and device based on block chain, electronic equipment and storage medium
CN104348815A (en) Method and device for verifying verification code
CN111371801A (en) Block chain node scanning method, equipment and storage medium
CN106411660A (en) Call quality detection method and terminal
CN103326892B (en) The operating method and device of web interface
CN112258184B (en) Method, apparatus, electronic device and readable storage medium for freezing blockchain network
WO2015143629A1 (en) Information transmission method and device
US20180197362A1 (en) Method for generating winning numbers and apparatus
CN113315676B (en) Method and device for detecting broken link and electronic equipment
CN110876852A (en) Network game data processing method and system of micro-service
CN112261051B (en) User registration method, device and system
CN113891385B (en) Method, device and equipment for detecting link state of network equipment

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
CB02 Change of applicant information

Address after: 601, 6 / F, building 2, No. 18, Kechuang 11th Street, Daxing District, Beijing, 100176

Applicant after: Jingdong Technology Information Technology Co.,Ltd.

Address before: 601, 6 / F, building 2, No. 18, Kechuang 11th Street, Daxing District, Beijing, 100176

Applicant before: Jingdong Shuke Haiyi Information Technology Co.,Ltd.

Address after: 601, 6 / F, building 2, No. 18, Kechuang 11th Street, Daxing District, Beijing, 100176

Applicant after: Jingdong Shuke Haiyi Information Technology Co.,Ltd.

Address before: 601, 6 / F, building 2, No. 18, Kechuang 11th Street, Beijing Economic and Technological Development Zone, Beijing 100176

Applicant before: BEIJING HAIYI TONGZHAN INFORMATION TECHNOLOGY Co.,Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant