Nothing Special   »   [go: up one dir, main page]

CN109947843B - Method, device and system for determining time in block chain - Google Patents

Method, device and system for determining time in block chain Download PDF

Info

Publication number
CN109947843B
CN109947843B CN201711252210.XA CN201711252210A CN109947843B CN 109947843 B CN109947843 B CN 109947843B CN 201711252210 A CN201711252210 A CN 201711252210A CN 109947843 B CN109947843 B CN 109947843B
Authority
CN
China
Prior art keywords
time
intelligent contract
block
block chain
current time
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
CN201711252210.XA
Other languages
Chinese (zh)
Other versions
CN109947843A (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 Oracle Chain Technology Co ltd
Original Assignee
Beijing Oracle Chain 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 Oracle Chain Technology Co ltd filed Critical Beijing Oracle Chain Technology Co ltd
Priority to CN201711252210.XA priority Critical patent/CN109947843B/en
Publication of CN109947843A publication Critical patent/CN109947843A/en
Application granted granted Critical
Publication of CN109947843B publication Critical patent/CN109947843B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)
  • Electric Clocks (AREA)

Abstract

The invention discloses a method, a device and a system for determining time in a block chain, relates to the technical field of data processing, and can solve the problem that the time of each node in the existing block chain is not synchronous. The method mainly comprises the following steps: an intelligent contract on a block chain receives a time acquisition request; determining the current time of the block chain according to a preset time determination rule; and returning the current time to the requester sending the time acquisition request. The method is mainly suitable for a scene of determining the block chain time based on the intelligent contract.

Description

Method, device and system for determining time in block chain
Technical Field
The present invention relates to the field of data processing technologies, and in particular, to a method, an apparatus, and a system for determining time in a block chain.
Background
The block chain technology is a decentralized and distributed data storage, transmission and certification method, and replaces the current dependence of the internet on a central server with data blocks. The nodes at the bottom of the block chain are communicated through a point-to-point network, and the nodes can maintain the synchronization of data together. However, the local time of each node may not be synchronized, for example, the local time of node 1 is 12:12:12 in 11/1/2017, and the local time of node 2 is 12:12:13 in 11/1/2017, so that the requirement of time synchronization in practical application cannot be met. For example, when a transaction needs to be associated with a particular time, different nodes may process different results, and the transaction may fail to be verified. Therefore, how to provide a unified time service mechanism is urgently needed to be solved.
Disclosure of Invention
In view of this, the present invention provides a method, an apparatus, and a system for determining time in a block chain, which aim to solve the problem of time asynchronization of each node in the existing block chain.
In order to solve the above problems, the present invention mainly provides the following technical solutions:
in a first aspect, the present invention provides a method for determining time in a block chain, where the method includes:
an intelligent contract on a block chain receives a time acquisition request;
determining the current time of the block chain according to a preset time determination rule;
and returning the current time to the requester sending the time acquisition request.
Optionally, the determining, according to a preset time determination rule, the current time of the block chain includes:
acquiring the local current time of a node of the current execution block chaining-out block;
and determining the local current time of the node of the current execution block chain-out block as the current time of the block chain.
Optionally, the obtaining the local current time of the node where the block is linked out of the current execution block includes:
when the intelligent contract is positioned on the node of the current execution block chaining-out block, reading the local current time of the node of the current execution block chaining-out block;
and when the intelligent contract is not positioned on the node of the current execution block chaining-out block, sending a time acquisition request to the node of the current execution block chaining-out block, and receiving the current time fed back by the node of the current execution block chaining-out block.
Optionally, the determining, according to a preset time determination rule, the current time of the block chain includes:
sending a time acquisition request to a time server independent of the blockchain;
receiving the current time returned by the time server;
and determining the current time returned by the time server as the current time of the block chain.
In a second aspect, the present invention provides a method for determining time in a block chain, the method including:
when the current time of a block chain needs to be determined, sending a time acquisition request to an intelligent contract providing time service so that the intelligent contract determines the current time of the block chain according to a preset time determination rule;
and receiving the current time transmitted by the intelligent contract.
Optionally, the method further includes:
and adjusting the local current time according to the current time sent by the intelligent contract so as to synchronize the time.
Optionally, before sending the time obtaining request to the intelligent contract providing the time service, the method further includes:
judging whether the elapsed time length after the local current time is adjusted according to the current time sent by the intelligent contract reaches a preset time length threshold value or not;
the sending of the time acquisition request to the intelligent contract providing the time service comprises:
and if the duration reaches the preset duration threshold, sending the time acquisition request to the intelligent contract.
Optionally, the method further includes:
and if the duration does not reach the preset duration threshold, determining the local current time as the current time of the block chain.
In a third aspect, the present invention provides an apparatus for determining time in a block chain, the apparatus comprising:
a receiving unit, configured to receive a time acquisition request by an intelligent contract on a block chain;
the determining unit is used for determining the current time of the block chain according to a preset time determining rule;
and the returning unit is used for returning the current time to the requester sending the time acquisition request.
Optionally, the determining unit includes:
the acquisition module is used for acquiring the local current time of the node of the current execution block chaining-out block;
a first determining module, configured to determine a current time local to the node that executes the block chaining out of the block as the current time of the block chain.
Optionally, the obtaining module is configured to, when the intelligent contract is located on the node of the current execution block chaining-out block, read a local current time of the node of the current execution block chaining-out block; and when the intelligent contract is not positioned on the node of the current execution block chaining-out block, sending a time acquisition request to the node of the current execution block chaining-out block, and receiving the current time fed back by the node of the current execution block chaining-out block.
Optionally, the determining unit includes:
a sending module, configured to send a time acquisition request to a time server independent of the block chain;
the receiving module is used for receiving the current time returned by the time server;
and the second determining module is used for determining the current time returned by the time server as the current time of the block chain.
In a fourth aspect, the present invention provides an apparatus for determining time in a block chain, the apparatus comprising:
the sending unit is used for sending a time acquisition request to an intelligent contract providing time service when the current time of the block chain needs to be determined, so that the intelligent contract determines the current time of the block chain according to a preset time determination rule;
and the receiving unit is used for receiving the current time sent by the intelligent contract.
Optionally, the apparatus further comprises:
and the adjusting unit is used for adjusting the local current time according to the current time sent by the intelligent contract so as to synchronize the time.
Optionally, the apparatus further comprises:
the device comprises a judging unit and a judging unit, wherein the judging unit is used for judging whether the elapsed time length after the local current time is adjusted according to the current time sent by the intelligent contract reaches a preset time length threshold value before sending a time obtaining request to the intelligent contract providing time service;
and the sending unit is used for sending the time acquisition request to the intelligent contract when the duration reaches the preset duration threshold.
Optionally, the apparatus further comprises:
and the determining unit is used for determining the local current time as the current time of the block chain when the duration does not reach the preset duration threshold.
In a fifth aspect, the present invention provides a storage medium, where the storage medium includes a stored program, and where the program is executed to control an apparatus in which the storage medium is located to perform the method for determining time in a block chain according to the first aspect.
In a sixth aspect, the present invention provides a storage medium comprising a stored program, wherein when the program runs, a device in which the storage medium is located is controlled to execute the method for determining time in a block chain according to the second aspect.
In a seventh aspect, the present invention provides an apparatus for determining time in a blockchain, the apparatus comprising a storage medium and a processor;
the processor is suitable for realizing instructions;
the storage medium adapted to store a plurality of instructions;
the instructions are adapted to be loaded by the processor and to perform the method of determining time in a blockchain as described in the first aspect.
In an eighth aspect, the present invention provides an apparatus for determining time in a blockchain, the apparatus comprising a storage medium and a processor;
the processor is suitable for realizing instructions;
the storage medium adapted to store a plurality of instructions;
the instructions are adapted to be loaded by the processor and to perform the method of determining time in a blockchain according to the second aspect.
In a ninth aspect, the present invention provides a system for determining time in a blockchain, where the system includes an intelligent contract, a requester for acquiring time; wherein the intelligent contract comprises an apparatus as described in the third aspect and the requestor comprises an apparatus as described in the fourth aspect.
By the technical scheme, the technical scheme provided by the invention at least has the following advantages:
the method, the device and the system for determining the time in the block chain can uniformly acquire the current time from the intelligent contract instead of directly acquiring the local current time when each node in the block chain needs to acquire the current time, so that each node is synchronized in time.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
fig. 1 is a flowchart illustrating a method for determining time in a block chain according to an embodiment of the present invention;
fig. 2 is a flowchart illustrating another method for determining time in a block chain according to an embodiment of the present invention;
fig. 3 is a block diagram illustrating a device for determining time in a block chain according to an embodiment of the present invention;
fig. 4 is a block diagram illustrating a time determination apparatus in another block chain according to an embodiment of the present invention;
fig. 5 is a block diagram illustrating a time determination apparatus in another block chain according to an embodiment of the present invention;
fig. 6 is a block diagram illustrating a time determination apparatus in another block chain according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
In order to provide a unified time service mechanism for a blockchain, an embodiment of the present invention provides a method for determining time in a blockchain, as shown in fig. 1, where the method includes:
101. an intelligent contract on a blockchain receives a time acquisition request.
Smart contracts refer to contracts defined in numerical form that are capable of automatically executing terms. In the field of blockchain technology, an intelligent contract refers specifically to a computer program that is triggered based on a predetermined event, is not tampered, and is automatically executed. Once an intelligent contract is generated, any node in the blockchain may invoke the intelligent contract to implement a certain service or transaction. The intelligent contract in the embodiment of the invention can be a contract specially providing time service, and can also be a contract comprising time service and other services. However, when the intelligent contract is a contract that exclusively provides a time service, the efficiency of the arithmetic time is often higher than that of a contract that includes other services, and therefore, it is preferable to use a contract that exclusively provides a time service.
When a certain node in the blockchain needs to determine the current time, a time acquisition request can be sent to an intelligent contract providing time service, so that the intelligent contract can feed back the determined current time to the node after receiving the time acquisition request.
102. And the intelligent contract determines the current time of the block chain according to a preset time determination rule.
After receiving a time acquisition request sent by a requester, the intelligent contract determines the current time of the block chain according to the processing logic of the intelligent contract (namely, a preset time determination rule), and immediately feeds back the time result to the requester after determining the time result. The preset time determination rule may include multiple types, for example, the local time of a certain node may be determined as the required time, or the time of a certain device outside the block chain may be determined as the required time.
103. And the intelligent contract returns the current time to the requester who sends the time acquisition request.
After the intelligent contract determines the current time of the blockchain, the current time may be returned to the requester so that the requester may perform subsequent logical processing according to the current time.
The method for determining time in a block chain provided by the embodiment of the invention can uniformly acquire the current time from an intelligent contract instead of directly acquiring the local current time when each node in the block chain needs to acquire the current time, so that each node is synchronized in time.
Optionally, there are many methods for determining the current time by the intelligent contract mentioned in step 102 above, and the following two determination methods are taken as examples and will be explained below.
The method comprises the following steps: acquiring the local current time of a node of the current execution block chaining-out block; and determining the local current time of the node of the current execution block chain-out block as the current time of the block chain.
There may be multiple block chaining-out nodes (also known as "mining machines") in the block chain, where each block chaining-out node writes different blocks and only one block chaining-out node generates a block (i.e., generates a block) at the same time. In order to make the current time of the block chain unique, the embodiment of the present invention uses the current time local to the node that executes block chaining at this time (i.e. the block chaining block node that has last gone out of the block) as the current time of the block chain.
In practical application, the intelligent contract may be stored in the node where the block is chained out in the current execution block, or may be stored in other nodes. Therefore, a specific implementation manner for acquiring the local current time of the node where the block is linked out of the execution block may be as follows: when an intelligent contract requested by a requester for acquiring time is positioned on a node of a linked block of the current execution block, the intelligent contract directly reads the local current time after receiving a time acquisition request; when the intelligent contract is not located on the node of the current execution block chaining-out block, after receiving the time acquisition request, the intelligent contract may send the time acquisition request to the node of the current execution block chaining-out block, and then receive the current time fed back by the node of the current execution block chaining-out block.
It should be added that, in practical application, in addition to using the local time of the node executing the block link exit block this time as the time of the block link, the local time of any other node in the block link may also be used as the time of the block link.
The second method comprises the following steps: the intelligent contract firstly sends a time acquisition request to a time server independent of the block chain, then receives the current time returned by the time server, and finally determines the current time returned by the time server as the current time of the block chain.
Compared with the local time of the node executing the block link-out block, the time calculated by the specially-timed time server is more accurate, so if an intelligent contract capable of accessing the time server independent of the block link can be created, the intelligent contract is preferentially used for acquiring the current time.
Further, according to the method described by the intelligent contract side, another embodiment of the present invention further provides a method for determining time in a blockchain, which may be applied to any node on the blockchain that requests to acquire time, as shown in fig. 2, where the method includes:
201. when the current time of the block chain needs to be determined, a time obtaining request is sent to an intelligent contract providing time service, so that the intelligent contract determines the current time of the block chain according to a preset time determining rule.
When a node needs to determine the current time of a block chain, a time acquisition request may be sent to a locally stored intelligent contract or the same intelligent contract stored on a node executing a block chain out of the block chain this time, so that after the intelligent contract receives the time acquisition request, the current time may be determined according to a preset time determination rule. The intelligent contract in the embodiment of the present invention may be a contract that specially provides a time service, or may be a contract that includes a time service and other services. However, when the intelligent contract is a contract that exclusively provides a time service, the efficiency of the arithmetic time is often higher than that of a contract that includes other services, and therefore, it is preferable to use a contract that exclusively provides a time service.
202. And receiving the current time transmitted by the intelligent contract.
After the current time fed back by the intelligent contract is received, subsequent logic processing can be carried out according to the current time, and time-related services are realized.
The method for determining time in a block chain provided by the embodiment of the invention can uniformly acquire the current time from an intelligent contract instead of directly acquiring the local current time when each node in the block chain needs to acquire the current time, so that each node is synchronized in time.
Further, in practical application, a certain node may need to frequently determine the current time within a specific time period, and in this case, if the time is acquired from the intelligent contract every time, the operation is cumbersome, and the acquisition efficiency is low. In order to improve the time obtaining efficiency, after the current time is obtained from the intelligent contract side, the local current time can be adjusted according to the current time sent by the intelligent contract, so that the time is synchronized. Thus, the time can be directly acquired from the local subsequently without acquiring the time from the intelligent contract side.
However, as time goes by, the local time of the node tends to become slow, for example, the system time (i.e. the local time) of a computer commonly used in life is synchronized with the network time, and then the system time of the computer is again not synchronized with the network time after a certain time. In order to avoid that the time used by each node is asynchronous again due to the occurrence of the above situations, before sending a time acquisition request to an intelligent contract providing time service, whether the elapsed time after the local current time is adjusted according to the current time sent by the intelligent contract reaches a preset time threshold value or not can be judged; if the duration reaches the preset duration threshold, sending the time acquisition request to the intelligent contract so as to acquire the current time from the intelligent contract side; and if the duration does not reach the preset duration threshold, directly determining the local current time as the current time of the block chain. The preset duration threshold is the shortest duration of the difference between the local time of the node determined according to actual experience and the time calculated by the intelligent contract.
Further, according to the above method embodiment, another embodiment of the present invention further provides an apparatus for determining time in a block chain, as shown in fig. 3, where the apparatus includes:
a receiving unit 31, configured to receive a time acquisition request by an intelligent contract on a block chain;
a determining unit 32, configured to determine a current time of the block chain according to a preset time determination rule;
a returning unit 33, configured to return the current time to the requester that sends the time obtaining request.
Optionally, as shown in fig. 4, the determining unit 32 includes:
an obtaining module 321, configured to obtain a local current time of a node that executes a block chaining-out block this time;
a first determining module 322, configured to determine a current time local to the node that executes the block chaining out this time as the current time of the block chain.
Optionally, the obtaining module 321 is configured to, when the intelligent contract is located on the node of the current execution block chaining-out block, read a local current time of the node of the current execution block chaining-out block; and when the intelligent contract is not positioned on the node of the current execution block chaining-out block, sending a time acquisition request to the node of the current execution block chaining-out block, and receiving the current time fed back by the node of the current execution block chaining-out block.
Optionally, as shown in fig. 4, the determining unit 32 includes:
a sending module 323, configured to send a time obtaining request to a time server independent of the block chain;
a receiving module 324, configured to receive the current time returned by the time server;
a second determining module 325, configured to determine the current time returned by the time server as the current time of the block chain.
The device for determining the time in the block chain comprises a processor and a storage medium, wherein the receiving unit, the determining unit, the returning unit and the like are stored in the storage medium as program units, and the processor executes the program units stored in the storage medium to realize corresponding functions.
The device for determining time in a block chain provided by the embodiment of the invention can uniformly acquire the current time from an intelligent contract instead of directly acquiring the local current time when each node in the block chain needs to acquire the current time, so that each node is synchronized in time.
Further, according to the above method embodiment, another embodiment of the present invention further provides an apparatus for determining time in a block chain, as shown in fig. 5, where the apparatus includes:
a sending unit 41, configured to send a time obtaining request to an intelligent contract providing time service when the current time of a block chain needs to be determined, so that the intelligent contract determines the current time of the block chain according to a preset time determination rule;
a receiving unit 42, configured to receive the current time sent by the intelligent contract.
Optionally, as shown in fig. 6, the apparatus further includes:
and an adjusting unit 43, configured to adjust the local current time according to the current time sent by the smart contract, so as to synchronize the time.
Optionally, as shown in fig. 6, the apparatus further includes:
a judging unit 44, configured to, before sending a time acquisition request to an intelligent contract providing time service, judge whether a duration for adjusting local current time according to current time sent by the intelligent contract reaches a preset duration threshold;
the sending unit 41 is configured to send the time obtaining request to the intelligent contract when the duration reaches the preset duration threshold.
Optionally, as shown in fig. 6, the apparatus further includes:
a determining unit 45, configured to determine, when the duration does not reach the preset duration threshold, a local current time as a current time of the block chain.
The device for determining the time in the block chain comprises a processor and a storage medium, wherein the sending unit, the receiving unit, the adjusting unit, the judging unit, the determining unit and the like are stored in the storage medium as program units, and the processor executes the program units stored in the storage medium to realize corresponding functions.
The device for determining time in a block chain provided by the embodiment of the invention can uniformly acquire the current time from an intelligent contract instead of directly acquiring the local current time when each node in the block chain needs to acquire the current time, so that each node is synchronized in time.
The embodiment of the invention provides a storage medium, which comprises a stored program, wherein when the program runs, a device where the storage medium is located is controlled to execute a method for determining time in a block chain as described in an intelligent contract side.
The embodiment of the invention provides a storage medium, which comprises a stored program, wherein when the program runs, a device where the storage medium is located is controlled to execute a method for determining time in a block chain as described by a requester side.
The storage medium may include volatile memory in a computer readable medium, Random Access Memory (RAM) and/or nonvolatile memory such as Read Only Memory (ROM) or flash memory (flash RAM), and the memory includes at least one memory chip.
The embodiment of the invention provides a device for determining time in a block chain, which comprises a storage medium and a processor;
the processor is suitable for realizing instructions;
the storage medium adapted to store a plurality of instructions;
the instructions are adapted to be loaded by the processor and to perform a method of determining time in a block chain as described by the intelligent contract side.
The embodiment of the invention provides a device for determining time in a block chain, which comprises a storage medium and a processor;
the processor is suitable for realizing instructions;
the storage medium adapted to store a plurality of instructions;
the instructions are adapted to be loaded by the processor and to perform the method of determining time in a block chain as described on the requester side.
The processor comprises a kernel, and the kernel calls the corresponding program unit from the storage medium. The kernel can set one or more than one, and the time of each node in the block chain is unified by adjusting the kernel parameters.
Further, another embodiment of the present invention further provides a system for determining time in a blockchain, where the system includes an intelligent contract, a requester for acquiring time; wherein the intelligent contract comprises a device as shown in fig. 3 or fig. 4, and the requester comprises a device as shown in fig. 5 or fig. 6.
The present application further provides a computer program product adapted to perform program code for initializing the following method steps when executed on a data processing device:
an intelligent contract on a block chain receives a time acquisition request;
determining the current time of the block chain according to a preset time determination rule;
and returning the current time to the requester sending the time acquisition request.
The present application further provides a computer program product adapted to perform program code for initializing the following method steps when executed on a data processing device:
when the current time of a block chain needs to be determined, sending a time acquisition request to an intelligent contract providing time service so that the intelligent contract determines the current time of the block chain according to a preset time determination rule;
and receiving the current time transmitted by the intelligent contract.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). The memory is an example of a computer-readable medium.
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 the storage medium of the computer include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM)
(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 storage or other magnetic storage devices, or any other non-transmission medium, which 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 identical elements in the process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The above are merely examples of the present application and are not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (11)

1. A method for determining time in a block chain, the method comprising:
an intelligent contract on a block chain receives a time acquisition request;
determining the current time of the block chain according to a preset time determination rule;
returning the current time to a requester who sends the time acquisition request;
wherein the determining the current time of the block chain according to the preset time determination rule includes:
acquiring the local current time of a node of the current execution block chaining-out block;
determining the local current time of the node of the current execution block chain-out block as the current time of the block chain;
wherein, the obtaining of the local current time of the node of the current execution block chaining-out block comprises:
when the intelligent contract is positioned on the node of the current execution block chaining-out block, reading the local current time of the node of the current execution block chaining-out block;
and when the intelligent contract is not positioned on the node of the current execution block chaining-out block, sending a time acquisition request to the node of the current execution block chaining-out block, and receiving the current time fed back by the node of the current execution block chaining-out block.
2. A method for determining time in a block chain, the method comprising:
when the current time of a block chain needs to be determined, sending a time acquisition request to an intelligent contract providing time service so that the intelligent contract determines the current time of the block chain according to a preset time determination rule;
receiving the current time sent by the intelligent contract;
wherein before sending the time acquisition request to the smart contract providing the time service, the method further comprises:
judging whether the elapsed time length after the local current time is adjusted according to the current time sent by the intelligent contract reaches a preset time length threshold value or not;
the sending of the time acquisition request to the intelligent contract providing the time service comprises:
and if the duration reaches the preset duration threshold, sending the time acquisition request to the intelligent contract.
3. The method of claim 2, further comprising:
and adjusting the local current time according to the current time sent by the intelligent contract so as to synchronize the time.
4. The method of claim 2, further comprising:
and if the duration does not reach the preset duration threshold, determining the local current time as the current time of the block chain.
5. An apparatus for determining time in a block chain, the apparatus comprising:
a receiving unit, configured to receive a time acquisition request by an intelligent contract on a block chain;
the determining unit is used for determining the current time of the block chain according to a preset time determining rule;
a returning unit, configured to return the current time to a requester that sends the time acquisition request;
wherein the determination unit includes:
the acquisition module is used for acquiring the local current time of the node of the current execution block chaining-out block;
a first determining module, configured to determine a current time local to the node that executes the block chaining out this time as a current time of the block chain;
the obtaining module is configured to, when the intelligent contract is located on the node of the current execution block chaining-out block, read a local current time of the node of the current execution block chaining-out block; and when the intelligent contract is not positioned on the node of the current execution block chaining-out block, sending a time acquisition request to the node of the current execution block chaining-out block, and receiving the current time fed back by the node of the current execution block chaining-out block.
6. An apparatus for determining time in a block chain, the apparatus comprising:
the sending unit is used for sending a time acquisition request to an intelligent contract providing time service when the current time of the block chain needs to be determined, so that the intelligent contract determines the current time of the block chain according to a preset time determination rule;
the receiving unit is used for receiving the current time sent by the intelligent contract;
wherein the apparatus further comprises:
the device comprises a judging unit and a judging unit, wherein the judging unit is used for judging whether the elapsed time length after the local current time is adjusted according to the current time sent by the intelligent contract reaches a preset time length threshold value before sending a time obtaining request to the intelligent contract providing time service;
and the sending unit is further configured to send the time acquisition request to the intelligent contract when the duration reaches the preset duration threshold.
7. A storage medium, characterized in that the storage medium comprises a stored program, wherein a device on which the storage medium is located is controlled to execute the method for determining time in block chain of claim 1 when the program is run.
8. A storage medium, characterized in that the storage medium comprises a stored program, wherein when the program runs, a device in which the storage medium is located is controlled to execute the method for determining time in block chain according to any one of claims 2 to 4.
9. An apparatus for determining time in a blockchain, the apparatus comprising a storage medium and a processor;
the processor is suitable for realizing instructions;
the storage medium adapted to store a plurality of instructions;
the instructions are adapted to be loaded by the processor and to perform the method of determining time in a blockchain of claim 1.
10. An apparatus for determining time in a blockchain, the apparatus comprising a storage medium and a processor;
the processor is suitable for realizing instructions;
the storage medium adapted to store a plurality of instructions;
the instructions are adapted to be loaded by the processor and to perform the method of determining time in a block chain according to any one of claims 2 to 4.
11. A system for determining time in a blockchain is characterized by comprising an intelligent contract and a requester for acquiring time; wherein the intelligent contract comprises an apparatus as claimed in claim 5 and the requestor comprises an apparatus as claimed in claim 6.
CN201711252210.XA 2017-12-01 2017-12-01 Method, device and system for determining time in block chain Active CN109947843B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711252210.XA CN109947843B (en) 2017-12-01 2017-12-01 Method, device and system for determining time in block chain

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711252210.XA CN109947843B (en) 2017-12-01 2017-12-01 Method, device and system for determining time in block chain

Publications (2)

Publication Number Publication Date
CN109947843A CN109947843A (en) 2019-06-28
CN109947843B true CN109947843B (en) 2021-06-01

Family

ID=67004042

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711252210.XA Active CN109947843B (en) 2017-12-01 2017-12-01 Method, device and system for determining time in block chain

Country Status (1)

Country Link
CN (1) CN109947843B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110601849B (en) * 2019-08-21 2021-05-11 腾讯科技(深圳)有限公司 Trusted timestamp adding method and device and storage medium
CN111339187B (en) * 2020-02-20 2023-05-09 百度在线网络技术(北京)有限公司 Data processing method, device, equipment and storage medium based on intelligent contract

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106960165A (en) * 2017-03-13 2017-07-18 广东网金控股股份有限公司 It is a kind of that the method that electronic contract is conutersigned in many ways is realized based on the intelligent contract of block chain
CN106982203A (en) * 2017-01-06 2017-07-25 中国银联股份有限公司 The ATM network system and its information processing method of robust based on block chain technology
CN107317856A (en) * 2017-06-23 2017-11-03 李波 A kind of date storage method and device based on block chain
WO2017198291A1 (en) * 2016-05-18 2017-11-23 Rwe International Se Peer-to-peer network and node of a peer-to-peer network

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2017198291A1 (en) * 2016-05-18 2017-11-23 Rwe International Se Peer-to-peer network and node of a peer-to-peer network
CN106982203A (en) * 2017-01-06 2017-07-25 中国银联股份有限公司 The ATM network system and its information processing method of robust based on block chain technology
CN106960165A (en) * 2017-03-13 2017-07-18 广东网金控股股份有限公司 It is a kind of that the method that electronic contract is conutersigned in many ways is realized based on the intelligent contract of block chain
CN107317856A (en) * 2017-06-23 2017-11-03 李波 A kind of date storage method and device based on block chain

Also Published As

Publication number Publication date
CN109947843A (en) 2019-06-28

Similar Documents

Publication Publication Date Title
CN106933534B (en) Data synchronization method and device
TW201837748A (en) Consensus method and device based on block chain
CN107968810B (en) Resource scheduling method, device and system for server cluster
CN106886434B (en) Distributed application installation method and device
CN106326309B (en) Data query method and device
CN109783157B (en) Method and related device for loading algorithm program
CN107832275A (en) The generation method of intelligent Contract ID, apparatus and system in block chain
CN106844055B (en) Task execution method and device
CN112558997A (en) Method and device for deploying applications
CN109947843B (en) Method, device and system for determining time in block chain
CN107578338B (en) Service publishing method, device and equipment
CN110674105A (en) Data backup method, system and server
CN110888922A (en) Method and device for creating target table during data synchronization
CN111756803A (en) Server-side pushing method, equipment and medium based on block chain technology
CN110716813A (en) Data stream processing method and device, readable storage medium and processor
CN109194626A (en) Data cochain judgment method based on block chain
CN109684051B (en) Method and system for asynchronously submitting hybrid big data task
CN109558249B (en) Control method and device for concurrent operation
CN110888723A (en) Timing task processing method and device
CN108228613B (en) Data reading method and device
CN110968888B (en) Data processing method and device
CN110969461B (en) Method and device for processing public number information, storage medium and processor
CN107784040B (en) File issuing method and device
CN108228145A (en) Data processing method, system and the mobile equipment of mixed type application program
CN109561123B (en) Token caching method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant