CN112148803A - Method, device, device and readable storage medium for invoking tasks in blockchain - Google Patents
Method, device, device and readable storage medium for invoking tasks in blockchain Download PDFInfo
- Publication number
- CN112148803A CN112148803A CN201910571848.2A CN201910571848A CN112148803A CN 112148803 A CN112148803 A CN 112148803A CN 201910571848 A CN201910571848 A CN 201910571848A CN 112148803 A CN112148803 A CN 112148803A
- Authority
- CN
- China
- Prior art keywords
- task
- identifier
- blockchain
- identification
- execution condition
- 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.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 143
- 238000004590 computer program Methods 0.000 claims description 13
- 230000003247 decreasing effect Effects 0.000 claims description 2
- 238000010586 diagram Methods 0.000 description 10
- 230000001960 triggered effect Effects 0.000 description 5
- 230000000694 effects Effects 0.000 description 3
- 230000005540 biological transmission Effects 0.000 description 2
- 238000013500 data storage Methods 0.000 description 2
- 230000001174 ascending effect Effects 0.000 description 1
- 125000004122 cyclic group Chemical group 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/28—Databases characterised by their database models, e.g. relational or object models
- G06F16/284—Relational databases
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4843—Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
- G06F9/4881—Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Data Mining & Analysis (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本公开提供一种区块链中任务的调用方法、装置、设备及可读存储介质,方法包括:向服务器发送任务的标识及执行条件;其中,任务的执行条件是在创建任务时确定的;接收服务器发送的目标任务标识,并根据目标任务标识执行相应的任务;目标任务标识是服务器根据任务标识、执行条件确定的。本公开提供的方法、装置、设备及可读存储介质,可以将任务的执行条件以及任务标识发送给服务器,通过服务器监控是否满足任务的执行条件,并由服务器向区块链平台反馈满足执行条件的目标任务标识,从而触发区块链平台执行该目标任务,因此,本公开提供的方法、装置、设备及可读存储介质,能够根据预设条件触发任务的执行,满足用户对任务触发机制的需求。
The present disclosure provides a method, device, device and readable storage medium for invoking a task in a blockchain, the method comprising: sending an identifier of the task and an execution condition to a server; wherein, the execution condition of the task is determined when the task is created; The target task identification sent by the server is received, and the corresponding task is executed according to the target task identification; the target task identification is determined by the server according to the task identification and execution conditions. The method, device, device and readable storage medium provided by the present disclosure can send the execution condition of the task and the task identifier to the server, monitor whether the execution condition of the task is satisfied through the server, and the server feedback to the blockchain platform that the execution condition is satisfied Therefore, the method, device, device and readable storage medium provided by the present disclosure can trigger the execution of the task according to preset conditions, and satisfy the user's requirement for the task triggering mechanism. need.
Description
技术领域technical field
本公开涉及区块链技术,尤其涉及一种区块链中任务的调用方法、装置、设备及可读存储介质。The present disclosure relates to blockchain technology, and in particular, to a method, apparatus, device and readable storage medium for invoking tasks in the blockchain.
背景技术Background technique
随着区块链技术的广泛应用,很多企业都将设置了区块链架构作为底层平台,并基于区块链平台进行业务处理。With the widespread application of blockchain technology, many enterprises will set up the blockchain architecture as the underlying platform and conduct business processing based on the blockchain platform.
现有技术中的区块链平台中的业务均是由外部服务器直接根据业务涉及的参数调用区块链平台中的方法进而触发的,例如,外部服务器向区块链平台发送交易请求,区块链平台中的各个节点可以对这一请求进行校验。The business in the blockchain platform in the prior art is triggered by the external server directly calling the method in the blockchain platform according to the parameters involved in the business. For example, the external server sends a transaction request to the blockchain platform, and the block Each node in the chain platform can verify this request.
因此,现有技术中的区块链事务触发机制单一,不能满足目前的用户需求。Therefore, the blockchain transaction triggering mechanism in the prior art is single and cannot meet current user needs.
发明内容SUMMARY OF THE INVENTION
本公开提供一种区块链中任务的调用方法、装置、设备及可读存储介质,以解决现有技术中区块链中的事务触发机制单一的技术问题。The present disclosure provides a method, device, device, and readable storage medium for invoking tasks in a blockchain, so as to solve the technical problem of a single transaction trigger mechanism in the blockchain in the prior art.
本公开的第一个方面是提供一种区块链中任务的调用方法,包括:A first aspect of the present disclosure is to provide a method for invoking tasks in a blockchain, including:
向服务器发送任务的标识及执行条件;其中,所述任务的执行条件是在创建所述任务时确定的;Send the identification of the task and the execution condition to the server; wherein, the execution condition of the task is determined when the task is created;
接收所述服务器发送的目标任务标识,并根据所述目标任务标识执行相应的任务;所述目标任务标识是所述服务器根据所述任务标识、所述执行条件确定的。The target task identifier sent by the server is received, and a corresponding task is executed according to the target task identifier; the target task identifier is determined by the server according to the task identifier and the execution condition.
本公开的第二个方面是提供一种区块链中任务的调用方法,包括:A second aspect of the present disclosure is to provide a method for invoking tasks in a blockchain, including:
接收区块链平台发送的任务标识及执行条件;其中,所述任务的执行条件是在创建所述任务时确定的;Receive the task identifier and execution condition sent by the blockchain platform; wherein, the execution condition of the task is determined when the task is created;
根据所述任务标识、所述执行条件确定目标任务标识,并向所述区块链平台发送所述目标任务标识,以使所述区块链平台执行所述目标任务标识对应的任务。The target task identifier is determined according to the task identifier and the execution condition, and the target task identifier is sent to the blockchain platform, so that the blockchain platform executes the task corresponding to the target task identifier.
本公开的第三个方面是提供一种区块链中任务的调用装置,包括:A third aspect of the present disclosure is to provide a device for invoking tasks in a blockchain, including:
发送模块,用于向服务器发送任务的标识及执行条件;其中,所述任务的执行条件是在创建所述任务时确定的;A sending module, used for sending the identification of the task and the execution condition to the server; wherein, the execution condition of the task is determined when the task is created;
第一接收模块,用于接收所述服务器发送的目标任务标识,并根据所述目标任务标识执行相应的任务;所述目标任务标识是所述服务器根据所述任务标识、所述执行条件确定的。The first receiving module is used to receive the target task identification sent by the server, and execute the corresponding task according to the target task identification; the target task identification is determined by the server according to the task identification and the execution condition. .
本公开的第四个方面是提供一种区块链中任务的调用装置,包括:A fourth aspect of the present disclosure is to provide a device for invoking tasks in a blockchain, including:
接收模块,用于接收区块链平台发送的任务标识及执行条件;其中,所述任务的执行条件是在创建所述任务时确定的;a receiving module, configured to receive the task identifier and execution condition sent by the blockchain platform; wherein, the execution condition of the task is determined when the task is created;
确定模块,用于根据所述任务标识、所述执行条件确定目标任务标识,并向所述区块链平台发送所述目标任务标识,以使所述区块链平台执行所述目标任务标识对应的任务。A determination module, configured to determine the target task identifier according to the task identifier and the execution condition, and send the target task identifier to the blockchain platform, so that the blockchain platform executes the target task identifier corresponding to the task.
本公开的第五个方面是提供一种区块链中任务的调用设备,包括:A fifth aspect of the present disclosure is to provide a device for invoking tasks in a blockchain, including:
存储器;memory;
处理器;以及processor; and
计算机程序;Computer program;
其中,所述计算机程序存储在所述存储器中,并配置为由所述处理器执行以实现如上述第一方面或第二方面所述的区块链中任务的调用方法。Wherein, the computer program is stored in the memory and configured to be executed by the processor to implement the method for invoking a task in the blockchain as described in the first aspect or the second aspect.
本公开的第六个个方面是提供一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行以实现如上述第一方面或第二方面所述的区块链中任务的调用方法。A sixth aspect of the present disclosure is to provide a computer-readable storage medium on which a computer program is stored, the computer program being executed by a processor to implement the blockchain as described in the first or second aspect above The calling method of the task in .
本公开提供的区块链中任务的调用方法、装置、设备及可读存储介质的技术效果是:The technical effects of the method, device, device and readable storage medium for invoking tasks in the blockchain provided by the present disclosure are:
本公开提供的区块链中任务的调用方法、装置、设备及可读存储介质,包括:向服务器发送任务的标识及执行条件;其中,任务的执行条件是在创建任务时确定的;接收服务器发送的目标任务标识,并根据目标任务标识执行相应的任务;目标任务标识是服务器根据任务标识、执行条件确定的。本公开提供的方法、装置、设备及可读存储介质,可以将任务的执行条件以及任务标识发送给服务器,通过服务器监控是否满足任务的执行条件,并由服务器向区块链平台反馈满足执行条件的目标任务标识,从而触发区块链平台执行该目标任务,因此,本公开提供的方法、装置、设备及可读存储介质,能够根据预设条件触发任务的执行,满足用户对任务触发机制的需求。The method, device, device and readable storage medium for invoking tasks in the blockchain provided by the present disclosure include: sending the identification of the task and execution conditions to the server; wherein, the execution conditions of the task are determined when the task is created; receiving the server Send the target task identifier, and execute the corresponding task according to the target task identifier; the target task identifier is determined by the server according to the task identifier and execution conditions. The method, device, device and readable storage medium provided by the present disclosure can send the execution condition of the task and the task identifier to the server, monitor whether the execution condition of the task is satisfied through the server, and the server feedback to the blockchain platform that the execution condition is satisfied Therefore, the method, device, device and readable storage medium provided by the present disclosure can trigger the execution of the task according to preset conditions and satisfy the user's requirement for the task triggering mechanism. need.
附图说明Description of drawings
图1为本发明一示例性实施例示出的区块链中任务的调用方法的流程图;1 is a flowchart of a method for invoking a task in a blockchain according to an exemplary embodiment of the present invention;
图2为本发明另一示例性实施例示出的区块链中任务的调用方法的流程图;2 is a flowchart of a method for invoking a task in a blockchain according to another exemplary embodiment of the present invention;
图2A为本发明一示例性实施例示出的任务标识展示图;Fig. 2A is a task identification display diagram according to an exemplary embodiment of the present invention;
图3为本发明又一示例性实施例示出的区块链中任务的调用方法的流程图;3 is a flowchart of a method for invoking a task in a blockchain according to another exemplary embodiment of the present invention;
图4为本发明再一示例性实施例示出的区块链中任务的调用方法的流程图;4 is a flowchart of a method for invoking a task in a blockchain according to yet another exemplary embodiment of the present invention;
图5为本发明一示例性实施例示出的区块链中任务的调用装置的结构图;5 is a structural diagram of an apparatus for invoking tasks in a blockchain according to an exemplary embodiment of the present invention;
图6为本发明另一示例性实施例示出的区块链中任务的调用装置的结构图;6 is a structural diagram of an apparatus for invoking tasks in a blockchain according to another exemplary embodiment of the present invention;
图7为本发明又一示例性实施例示出的区块链中任务的调用装置的结构图;7 is a structural diagram of an apparatus for invoking tasks in a blockchain according to another exemplary embodiment of the present invention;
图8为本发明再一示例性实施例示出的区块链中任务的调用装置的结构图。FIG. 8 is a structural diagram of an apparatus for invoking a task in a blockchain according to yet another exemplary embodiment of the present invention.
具体实施方式Detailed ways
现有技术中基于区块链的平台中,需要服务器向区块链平台发送执行任务的指令,从而触发区块链平台根据该指令执行相应的任务。例如,服务器可以向区块链平台发送创建交易的指令,此时,区块链平台可以根据该指令创建交易。但是,在这种机制中,触发任务的方式单一,无法根据一些预设条件执行相应的方法。例如,无法根据时间触发任务,无法根据区块链中的区块高度触发任务。In the blockchain-based platform in the prior art, the server needs to send an instruction to execute the task to the blockchain platform, thereby triggering the blockchain platform to execute the corresponding task according to the instruction. For example, the server can send an instruction to create a transaction to the blockchain platform, and at this time, the blockchain platform can create a transaction according to the instruction. However, in this mechanism, there is a single way of triggering tasks, and corresponding methods cannot be executed according to some preset conditions. For example, tasks cannot be triggered based on time, and tasks cannot be triggered based on block height in the blockchain.
本实施例提供的区块链中任务的调用方法,能够基于预设的任务触发条件执行相应的任务,从而满足用户的需求。The method for invoking a task in the blockchain provided by this embodiment can execute a corresponding task based on a preset task trigger condition, so as to meet the needs of the user.
图1为本发明一示例性实施例示出的区块链中任务的调用方法的流程图。FIG. 1 is a flowchart of a method for invoking a task in a blockchain according to an exemplary embodiment of the present invention.
如图1所示,本实施例提供的区块链中任务的调用方法包括:As shown in Figure 1, the method for invoking tasks in the blockchain provided by this embodiment includes:
步骤101,向服务器发送任务的标识及执行条件;其中,任务的执行条件是在创建任务时确定的。Step 101: Send the task identifier and execution condition to the server; wherein, the execution condition of the task is determined when the task is created.
其中,可以由区块链平台或系统执行本实施例提供的方法。区块链平台或系统中可以包括多个网络节点,这些网络节点通过网络进行连接,能够形成区块链网络。区块链本身是分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式,可以认为是一种分布式的存储方式,各个区块链节点中都可以存储相同的区块链,也就是存储有相同的数据内容。The method provided in this embodiment may be executed by a blockchain platform or system. A blockchain platform or system may include multiple network nodes, which are connected through the network to form a blockchain network. The blockchain itself is a new application mode of computer technology such as distributed data storage, point-to-point transmission, consensus mechanism, encryption algorithm, etc. It can be considered as a distributed storage method, and the same blocks can be stored in each blockchain node The chain, that is, stores the same data content.
具体的,各个网络节点中可以存储有智能合约,用于基于智能合约对区块链中的事务进行处理。开发人员可以在用户终端上编写任务,并将任务信息上传至区块链网络平台。例如,可以在用户终端上安装用于连接区块链平台的客户端,从而通过该客户端上传任务。区块链平台接收到任务后,可以在智能合约中存储任务相关信息。Specifically, each network node may store a smart contract for processing transactions in the blockchain based on the smart contract. Developers can write tasks on the user terminal and upload the task information to the blockchain network platform. For example, a client for connecting to the blockchain platform can be installed on the user terminal, thereby uploading tasks through the client. After the blockchain platform receives the task, it can store the task-related information in the smart contract.
智能合约可以认为是一个可以自动执行的计算机程序,它自己就是一个系统参与者。它对接收到的信息进行回应,它可以接收和储存价值,也可以向外发送信息和价值。A smart contract can be thought of as a computer program that can be executed automatically, which is itself a system participant. It responds to the information it receives, it can receive and store value, and it can send information and value out.
进一步的,开发人员在编写任务时,任务信息具体可以包括:调用的方法标识、任务执行条件、调用方法时所用的参数。其中,方法标识可以是智能合约中已有的方法的标识,从而在执行该任务时,可以直接调用智能合约中的方法。任务执行条件是指该任务的触发条件,当满足这一条件时,会触发区块链平台执行该任务。一般来说,调用方法时需要具有输入参数,例如,一个方法用于计算变量a与b的和,则在执行该方法时,需要获取a和b具体的值,也就是输入参数。Further, when a developer writes a task, the task information may specifically include: the method identifier to be called, the task execution condition, and the parameters used when the method is called. The method identifier can be an identifier of an existing method in the smart contract, so that when the task is performed, the method in the smart contract can be called directly. The task execution condition refers to the trigger condition of the task. When this condition is met, the blockchain platform will be triggered to execute the task. Generally speaking, when calling a method, it needs to have input parameters. For example, if a method is used to calculate the sum of variables a and b, when the method is executed, the specific values of a and b need to be obtained, that is, input parameters.
实际应用时,本实施例提供的方法可以向开发人员提供创建任务的方法,例如是“creatTimerTask()”,开发人员可以调用这个方法创建一个新的任务。In practical application, the method provided in this embodiment can provide the developer with a method for creating a task, for example, "creatTimerTask()", and the developer can call this method to create a new task.
区块链平台接收到开发者上传的任务后,可以从中获取任务的执行条件,还可以确定任务对应的任务标识。为了便于对各个任务进行区分,可以设置预设规则,用于确定各个任务对应的标识。例如,可以按照递增的规则,从1开始为任务命名,直到达到预设阈值。还可以获取任务中的信息,基于任务信息对任务进行命名。After the blockchain platform receives the task uploaded by the developer, it can obtain the execution conditions of the task from it, and can also determine the task identifier corresponding to the task. In order to facilitate the distinction of each task, a preset rule may be set for determining the identifier corresponding to each task. For example, tasks can be named according to an incremental rule, starting at 1 until a preset threshold is reached. You can also get the information in the task and name the task based on the task information.
其中,还可以根据数字设置任务标识区间,例如,将100-199的整数作为任务标识。当区块链平台接收到任务后,就按照100到199的顺序确定任务的标识,当标识到达199后,可以从100-199中确定已经执行了的任务,并将已经执行了的任务的标识确定为新任务的标识。例如,当任务标识已经达到199后,区块链平台又接收了新任务,此时,可以遍历100-199,确定出已经执行了的任务对应的标识,例如可以是120,此时,可以将120作为新任务的标识。可以将任务的执行条件、任务标识以及任务参数存储在智能合约中。The task identification interval can also be set according to numbers, for example, an integer of 100-199 is used as the task identification. When the blockchain platform receives the task, it determines the task identification in the order of 100 to 199. When the identification reaches 199, the executed task can be determined from 100-199, and the identification of the executed task can be determined. Determined as the ID of the new task. For example, when the task ID has reached 199, the blockchain platform receives a new task. At this time, it can traverse 100-199 to determine the ID corresponding to the task that has been executed. For example, it can be 120. 120 as the identifier for the new task. Task execution conditions, task identifiers, and task parameters can be stored in smart contracts.
具体的,本实施例提供的方法中,任务是具有执行条件的,当满足条件后,该任务就会被执行,此时,可以认为任务是“一次性的”,执行完毕后,可以删除相应的任务,那么其对应的标识也就被释放出来。因此,可以对任务标识多次利用,从而降低存储任务标识占用的存储空间。Specifically, in the method provided by this embodiment, the task has execution conditions, and when the conditions are met, the task will be executed. At this time, the task can be considered as "one-time", and after the execution is completed, the corresponding task can be deleted. task, then its corresponding identifier will be released. Therefore, the task identifier can be used multiple times, thereby reducing the storage space occupied by storing the task identifier.
进一步的,区块链平台可以将任务标识以及执行条件发送给服务器,从而通过服务器根据执行条件对任务进行监控。无需向服务器发送任务在执行过程中的参数,从而达到参数不会外泄的效果。本实施例的方法,将任务封在智能合约中,任务对应的参数不会被发送出去,仅将任务标识以及任务执行条件发送个服务器即可。Further, the blockchain platform can send the task identification and execution conditions to the server, so that the server can monitor the task according to the execution conditions. There is no need to send the parameters of the task during execution to the server, so as to achieve the effect that the parameters will not be leaked. In the method of this embodiment, the task is sealed in the smart contract, and the parameters corresponding to the task will not be sent out, and only the task identifier and the task execution conditions can be sent to the server.
步骤102,接收服务器发送的目标任务标识,并根据目标任务标识执行相应的任务;目标任务标识是服务器根据任务标识、执行条件确定的。Step 102: Receive the target task identification sent by the server, and execute the corresponding task according to the target task identification; the target task identification is determined by the server according to the task identification and execution conditions.
实际应用时,服务器可以存储区块链平台发送的任务标识以及任务执行条件。并基于任务执行条件,确定出满足条件的目标任务标识。例如,任务A的执行条件是时间为2018-12-17,11:29,也就是时间到达2018-12-17,11:29时,执行任务A。服务器可以监控时间,当时间满足执行条件时,就将任务A确定为目标任务标识。In practical applications, the server can store the task identifier and task execution conditions sent by the blockchain platform. And based on the task execution condition, determine the target task identifier that satisfies the condition. For example, the execution condition of task A is that the time is 2018-12-17, 11:29, that is, when the time reaches 2018-12-17, 11:29, task A is executed. The server can monitor the time, and when the time satisfies the execution condition, determines the task A as the target task identifier.
其中,服务器也可以是区块链平台中的一个节点,该节点中也可以存储区块链。当执行条件包括区块高度时,服务器可以根据存储的区块链监控区块高度,进而确定是否满足任务执行条件。The server can also be a node in the blockchain platform, and the blockchain can also be stored in the node. When the execution condition includes the block height, the server can monitor the block height according to the stored blockchain, and then determine whether the task execution condition is satisfied.
具体的,服务器还可以定时轮询存储的任务执行条件,从而及时确定满足条件的任务。Specifically, the server may also periodically poll the stored task execution conditions, so as to timely determine the tasks that meet the conditions.
进一步的,服务器确定满足任务的执行条件后,可以将满足条件的目标任务标识发送给区块链平台,从而使区块链平台能够执行相应的任务。区块链平台的智能合约中,存储有任务信息,具体包括调用的方法标识、执行方法所需的参数以及执行任务的条件。平台可以再次确定是否满足任务执行条件,若确实满足,则根据任务的参数,执行任务中包括的方法。Further, after determining that the execution conditions of the tasks are satisfied, the server can send the target task identifiers that satisfy the conditions to the blockchain platform, so that the blockchain platform can execute the corresponding tasks. In the smart contract of the blockchain platform, task information is stored, including the method identifier to be called, the parameters required to execute the method, and the conditions for executing the task. The platform can again determine whether the task execution conditions are met, and if so, execute the method included in the task according to the parameters of the task.
实际应用时,服务器可以向区块链平台发送目标任务标识,触发区块链平台执行运行任务的方法,该方法可以是runTask(),而区块链平台接收的目标任务标识就可以是执行runTask()的参数。例如,区块链平台接收到了服务器发送的目标任务标识A,则区块链平台可以针对任务A调用智能合约中的runTask()。在运行runTask()的过程中,可以先判断是否的确满足任务A的执行条件,若是,则可以获取智能合约中任务A的参数,并调用任务A中的方法标识对应的方法,例如,可能方法标识是m,则基于获取的参数运行方法m。In practical applications, the server can send the target task identifier to the blockchain platform to trigger the blockchain platform to execute the method of running the task. This method can be runTask(), and the target task identifier received by the blockchain platform can be the execution runTask. () parameter. For example, if the blockchain platform receives the target task identifier A sent by the server, the blockchain platform can call runTask() in the smart contract for task A. In the process of running runTask(), you can first determine whether the execution conditions of task A are indeed satisfied. If so, you can obtain the parameters of task A in the smart contract, and call the method in task A to identify the corresponding method, for example, the possible method The identity is m, then method m is run based on the obtained parameters.
本实施例提供的方法用于调用区块链平台中智能合约中的方法,该方法由设置有本实施例提供的方法的设备执行,该设备通常以硬件和/或软件的方式来实现。The method provided in this embodiment is used to invoke a method in a smart contract in a blockchain platform, and the method is executed by a device provided with the method provided in this embodiment, and the device is usually implemented in hardware and/or software.
本实施例提供的区块链中任务的调用方法,包括:向服务器发送任务的标识及执行条件;其中,任务的执行条件是在创建任务时确定的;接收服务器发送的目标任务标识,并根据目标任务标识执行相应的任务;目标任务标识是服务器根据任务标识、执行条件确定的。本实施例提供的方法,可以将任务的执行条件以及任务标识发送给服务器,通过服务器监控是否满足任务的执行条件,并由服务器向区块链平台反馈满足执行条件的目标任务标识,从而触发区块链平台执行该目标任务,因此,本实施例提供的方法,能够根据预设条件触发任务的执行,满足用户对任务触发机制的需求。The method for invoking a task in a blockchain provided by this embodiment includes: sending a task identifier and an execution condition to a server; wherein, the task execution condition is determined when the task is created; receiving the target task identifier sent by the server, and according to The target task identifier executes the corresponding task; the target task identifier is determined by the server according to the task identifier and execution conditions. In the method provided in this embodiment, the execution conditions of the task and the task identifier can be sent to the server, the server monitors whether the execution conditions of the task are met, and the server feeds back the target task identifier that satisfies the execution conditions to the blockchain platform, thereby triggering the block chain. The blockchain platform executes the target task. Therefore, the method provided in this embodiment can trigger the execution of the task according to the preset conditions, so as to satisfy the user's requirement for the task triggering mechanism.
图2为本发明另一示例性实施例示出的区块链中任务的调用方法的流程图。FIG. 2 is a flowchart of a method for invoking a task in a blockchain according to another exemplary embodiment of the present invention.
如图2所示,本实施例提供的区块链中任务的调用方法,包括:As shown in Figure 2, the method for invoking tasks in the blockchain provided by this embodiment includes:
步骤201,接收用户终端发送的任务对应的关键信息。Step 201: Receive key information corresponding to the task sent by the user terminal.
其中,此处的用户终端是指创建任务的用户所使用的终端,例如,可以是开发人员用的用户终端。开发人员可以在用户终端中调用用于创建任务的方法,例如调用creatTimerTask()方法,并设置任务的关键信息,具体包括该任务需要调用的方法标识、该任务的执行条件、调用方法时所需的参数。开发人员可以在确定任务信息正确的前提下,通过用户终端上传任务关键信息,从而使区块链平台能够接收到任务对应的关键信息。The user terminal here refers to the terminal used by the user who creates the task, for example, it may be the user terminal used by the developer. The developer can call the method used to create the task in the user terminal, such as calling the creatTimerTask() method, and set the key information of the task, including the method ID that the task needs to call, the execution conditions of the task, and the required information when calling the method. parameter. On the premise that the task information is correct, the developer can upload the key information of the task through the user terminal, so that the blockchain platform can receive the key information corresponding to the task.
具体的,用户终端可以通过网络与区块链平台连接,从而能够向区块链平台发送任务的关键信息。关键信息至少包括:方法标识、执行条件、执行参数。该方法标识是指执行任务时调用的方法,执行条件是指执行该任务需要满足的预设条件,执行参数是指调用方法时输入的参数。Specifically, the user terminal can be connected to the blockchain platform through the network, so that key information of the task can be sent to the blockchain platform. The key information includes at least: method identification, execution conditions, and execution parameters. The method identifier refers to the method invoked when the task is executed, the execution condition refers to the preset condition that needs to be satisfied to execute the task, and the execution parameter refers to the parameter input when the method is invoked.
步骤202,根据预设规则确定任务对应的任务标识,并将任务标识、关键信息存储在智能合约中。Step 202: Determine the task identifier corresponding to the task according to the preset rule, and store the task identifier and key information in the smart contract.
进一步的,区块链平台在接收到用户终端上传的任务信息后,可以确定该任务对应的任务标识(taskID)。可以设置用于确定任务标识的预设规则,从而根据该规则确定任务对应的任务标识。Further, after receiving the task information uploaded by the user terminal, the blockchain platform can determine the task ID (taskID) corresponding to the task. A preset rule for determining the task identifier can be set, so that the task identifier corresponding to the task is determined according to the rule.
实际应用时,可以根据任务的关键信息对其命名,例如,可以根据任务的关键信息生成哈希值,将哈希值确定为任务对应的标识。还可以利用数字确定任务的任务标识,例如,可以将第一个接收的任务的标识确定为1,将第二个接收的任务的标识确定为2。In practical application, the task can be named according to its key information. For example, a hash value can be generated according to the key information of the task, and the hash value can be determined as the identifier corresponding to the task. The task identification of the task may also be determined by numbers, for example, the identification of the first received task may be determined as 1, and the identification of the second received task may be determined as 2.
由于智能合约中的存储资源有限,因此,本实施例提供的方法可以采用循环编号的方式确定任务标识。Since the storage resources in the smart contract are limited, the method provided in this embodiment can determine the task identifier by means of circular numbering.
其中,本实施例提供的方法中,任务标识可以是数字,此时,根据预设规则确定任务对应的任务标识具体可以包括:Wherein, in the method provided by this embodiment, the task identifier may be a number, and in this case, determining the task identifier corresponding to the task according to the preset rule may specifically include:
获取智能合约中已有的最大任务标识,若最大任务标识小于预设上限值,则根据递增规则确定任务对应的任务标识。Obtain the maximum task ID existing in the smart contract. If the maximum task ID is less than the preset upper limit value, the task ID corresponding to the task is determined according to the increment rule.
具体的,可以预先设置任务标识对应的数值区间,例如可以是100-199,即100-199之间的整数可以作为任务标识。在接收用户终端发送的任务后,可以按照从小到大的顺序标识任务,例如,第一个任务的标识为100,第二个任务的标识为101,最终可以将任务标识为199。Specifically, a numerical range corresponding to the task identifier can be preset, for example, it can be 100-199, that is, an integer between 100-199 can be used as the task identifier. After receiving the tasks sent by the user terminal, the tasks can be identified in ascending order, for example, the first task is identified as 100, the second task is identified as 101, and finally the task can be identified as 199.
具体实施过程中,可以在标识任务前,可以获取智能合约中已有的最大任务标识,若最大任务标识小于预设上限值,也就是数值区间中的最大值,则可以根据递增规则确定任务对应的任务标识,具体可以在最大任务标识的基础上加1,得到任务对应的任务标识。例如,当前最大的任务标识是125,小于预设上限值199,则可以将新接收的任务的标识确定为126。In the specific implementation process, before identifying the task, the largest existing task identification in the smart contract can be obtained. If the maximum task identification is smaller than the preset upper limit value, that is, the maximum value in the numerical range, the task can be determined according to the increment rule. For the corresponding task identification, specifically, 1 may be added to the maximum task identification to obtain the task identification corresponding to the task. For example, if the current largest task identifier is 125, which is less than the preset upper limit value of 199, the identifier of the newly received task may be determined as 126.
其中,若最大任务标识等于预设上限值,例如最大任务标识等于199,获取智能合约中已有的最小任务标识,若最小任务标识大于预设下限值,则根据递减规则确定任务对应的任务标识。由于任务标识已经达到上限值,此时,就不能再在199的基础上采用递增原则确定任务标识。因此,可以获取智能合约中各个未执行的任务对应的任务标识,并在其中确定出最小任务标识,然后在最小任务标识的基础上,采用递减的原则确定出新接收的任务对应的任务标识。Among them, if the maximum task ID is equal to the preset upper limit value, for example, the maximum task ID is equal to 199, obtain the existing minimum task ID in the smart contract, and if the minimum task ID is greater than the preset lower limit value, determine the corresponding task according to the decrement rule. Task ID. Since the task identification has reached the upper limit value, at this time, the incremental principle can no longer be used to determine the task identification on the basis of 199. Therefore, the task ID corresponding to each unexecuted task in the smart contract can be obtained, and the minimum task ID is determined in it, and then on the basis of the minimum task ID, the task ID corresponding to the newly received task is determined by the principle of decreasing.
根据递减规则确定任务对应的任务标识可以包括:在最小任务标识的基础上减1,得到任务对应的任务标识。例如,最小任务标识为145,则新确定的任务标识为144。Determining the task identifier corresponding to the task according to the decrement rule may include: subtracting 1 from the minimum task identifier to obtain the task identifier corresponding to the task. For example, if the minimum task ID is 145, the newly determined task ID is 144.
具体的,本实施例提供的方法还包括:删除智能合约中已执行的任务,从而释放已执行任务对应的任务标识。因此,从智能合约中获取的任务标识,均是未执行任务对应的标识。Specifically, the method provided by this embodiment further includes: deleting the executed task in the smart contract, thereby releasing the task identifier corresponding to the executed task. Therefore, the task identifiers obtained from the smart contract are the identifiers corresponding to the unexecuted tasks.
进一步的,本实施例提供的方法还可以设置通过递增或递减方式确定任务标识的标志位。在执行步骤202之前,区块链平台可以读取智能合约中已由的任务标识,并基于这些任务标识确定标志位。可以先确定任务标识中的最大值,若最大值小于上限值,则可以将标志位确定为与递增规则对应的值,例如是1。若最大值等于预设上限值,则可以进一步的确定已有任务标识中的最小值,若最小值大于预设下限值,则将标志位确定为与递减规则对应的值,例如是0。Further, in the method provided by this embodiment, a flag bit for determining the task identifier in an incrementing or decrementing manner may also be set. Before executing
实际应用时,在执行步骤202之前,可以先读取标志位,再根据标志位确定任务对应的任务标识。例如,若标志位是1,则获取已有任务标识中的最大值,并采用递增规则确定新的任务标识。若标志位是0,则获取已有任务标识中的最小值,并采用递减规则确定新的任务标识。In practical application, before
其中,任务执行后,可以删除智能合约中的任务信息,从而释放该任务对应的任务标识。Among them, after the task is executed, the task information in the smart contract can be deleted, thereby releasing the task identifier corresponding to the task.
图2A为本发明一示例性实施例示出的任务标识展示图。FIG. 2A is a display diagram of task identification according to an exemplary embodiment of the present invention.
图2A仅是为了便于理解本实施例提供的循环编码的方式,在实际应用过程中,不需要将任务标识展现为图2A的样式。FIG. 2A is only for the convenience of understanding the cyclic coding method provided by this embodiment. In the actual application process, it is not necessary to display the task identifier in the style of FIG. 2A .
如图2A所示,标识的区间为100-199,即标识初始值可以是100,最初接收任务时,可以按照顺时针的方向对任务进行标识,当标识到达最大值(也是预设上限值)199时,可以遍历智能合约中的所有任务标识,并在其中确定尚未执行的任务标识中的最小值,例如最小值是194,则从193按照逆时针的方向对任务进行标识,当标识再到最小值100后,再读取智能合约中任务标识中的最大任务标识,然后按照顺时针的方向对任务进行标识,从而能够多次循环利用任务标识。As shown in FIG. 2A , the interval of the mark is 100-199, that is, the initial value of the mark can be 100. When the task is initially received, the task can be marked in a clockwise direction. When the mark reaches the maximum value (also the preset upper limit value) ) 199, you can traverse all the task identifiers in the smart contract, and determine the minimum value of the task identifiers that have not been executed. For example, if the minimum value is 194, the task will be identified from 193 in a counterclockwise direction. After reaching the minimum value of 100, read the largest task identification in the task identification in the smart contract, and then mark the task in a clockwise direction, so that the task identification can be recycled many times.
本实施例提供的方法在执行过程中,会不断的创建任务、执行任务、删除任务,因此,可以根据实际需求设置任务标识区间,使其不会同时被全部占用。若由于种种原因,导致任务标识均被占用,则可以自动更新任务标识,从而得到新的任务标识区间,例如,可以更新得到200-299的任务标识。During the execution of the method provided by this embodiment, tasks are continuously created, executed, and deleted. Therefore, task identification intervals can be set according to actual requirements so that they will not be all occupied at the same time. If the task identifiers are all occupied due to various reasons, the task identifiers can be automatically updated to obtain a new task identifier interval, for example, the task identifiers of 200-299 can be updated.
步骤203,接收服务器发送的目标任务标识,目标任务标识是服务器根据任务标识、执行条件确定的。Step 203: Receive a target task identifier sent by the server, where the target task identifier is determined by the server according to the task identifier and execution conditions.
步骤203与步骤102中接收目标任务标识的具体原理和实现方式类似,此处不再赘述。Step 203 is similar to the specific principle and implementation manner of receiving the target task identifier in
步骤204,在智能合约中获取与目标任务标识对应的关键信息。Step 204: Obtain key information corresponding to the target task identifier in the smart contract.
其中,区块链平台接收服务器发送的目标任务标识后,可以在智能合约中获取与该目标任务标识对应的任务关键信息。例如,在智能合约中可以存储:taskID1:taskContext1;taskID2:taskContext2;taskID3:taskContext3等。其中的taskID后的数字可以是具体的任务标识,taskContext是具体的任务关键信息。服务器可以向区块链平台发送仅包括数字的任务标识,也可以发送包括taskID以及数字的任务标识。Among them, after receiving the target task identification sent by the server, the blockchain platform can obtain the key task information corresponding to the target task identification in the smart contract. For example, in a smart contract, you can store: taskID1: taskContext1; taskID2: taskContext2; taskID3: taskContext3, etc. The number after the taskID can be a specific task identifier, and the taskContext is specific task key information. The server can send a task ID that only includes numbers to the blockchain platform, or it can send a task ID that includes both taskID and numbers.
具体的,区块链平台从智能合约中获取的方法标识、参数、执行条件等信息。Specifically, the method identification, parameters, execution conditions and other information obtained by the blockchain platform from the smart contract.
步骤205,判断是否满足关键信息中包括的执行条件。
进一步的,可以根据获取的执行条件,确定当前是否满足该执行条件。若执行条件是时间信息,则可以确定是否到达该时间,若执行条件是区块链高度信息,则可以确定区块链中的最新生成的区块高度值是否与执行条件一致。Further, according to the acquired execution condition, it can be determined whether the execution condition is currently satisfied. If the execution condition is time information, it can be determined whether the time has been reached. If the execution condition is blockchain height information, it can be determined whether the newly generated block height value in the blockchain is consistent with the execution condition.
可以在智能合约中设置runTask()方法,当服务器向区块链平台发送目标任务标识后,区块链平台可以调用runTask(),并将目标任务标识作为该方法的输入参数。例如,服务器发送的目标任务标识是taskID1,则区块链平台基于taskID1执行runTask()。在runTask()方法中,具体可以包括if判断语句,用于判断当前的条件是否满足关键信息中包括的执行条件。The runTask() method can be set in the smart contract. After the server sends the target task identifier to the blockchain platform, the blockchain platform can call runTask() and use the target task identifier as the input parameter of this method. For example, if the target task identifier sent by the server is taskID1, the blockchain platform executes runTask() based on taskID1. In the runTask() method, an if judgment statement may be specifically included to judge whether the current condition satisfies the execution condition included in the key information.
步骤206,若是,则基于关键信息中的执行参数运行关键信息中包括的方法标识对应的方法。
若步骤205中的判断结果为是,则说明符合预先设置的执行该任务的条件,因此,可以根据该任务对应的关键信息执行该任务。If the judgment result in
具体可以是基于关键信息中的执行参数运行关键信息中包括的方法标识对应的方法。例如,可以根据关键信息中包括的方法标识调用相应的方法,并将关键信息中的执行参数作为该方法的输入参数。与方法标识对应的方法可以是存储在智能合约中。Specifically, the method corresponding to the method identifier included in the key information may be run based on the execution parameters in the key information. For example, the corresponding method can be called according to the method identifier included in the key information, and the execution parameter in the key information can be used as the input parameter of the method. The method corresponding to the method identifier can be stored in the smart contract.
若步骤205中的判断结果是否,则可以认为不满足该任务的执行条件,因此,不会基于该任务的关键信息调用智能合约中的方法。If the judgment result in
进一步的,关键信息中的执行条件可以是包括时间和/或区块高度。Further, the execution condition in the key information may include time and/or block height.
图3为本发明又一示例性实施例示出的区块链中任务的调用方法的流程图。FIG. 3 is a flowchart of a method for invoking a task in a blockchain according to another exemplary embodiment of the present invention.
如图3所示,本实施例提供的区块链中任务的调用方法包括:As shown in Figure 3, the method for invoking tasks in the blockchain provided by this embodiment includes:
步骤301,接收区块链平台发送的任务标识及执行条件;其中,任务的执行条件是在创建任务时确定的。Step 301: Receive the task identifier and execution conditions sent by the blockchain platform; wherein, the execution conditions of the task are determined when the task is created.
其中,可以由与区块链平台或系统连接的服务器执行本实施例提供的方法。区块链平台或系统中可以包括多个网络节点,这些网络节点通过网络进行连接,能够形成区块链网络。区块链本身是分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式,可以认为是一种分布式的存储方式,各个区块链节点中都可以存储相同的区块链,也就是存储有相同的数据内容。The method provided in this embodiment may be executed by a server connected to the blockchain platform or system. A blockchain platform or system may include multiple network nodes, which are connected through the network to form a blockchain network. The blockchain itself is a new application mode of computer technology such as distributed data storage, point-to-point transmission, consensus mechanism, encryption algorithm, etc. It can be considered as a distributed storage method, and the same blocks can be stored in each blockchain node The chain, that is, stores the same data content.
服务器可以是具备计算功能的设备,例如计算机、平板电脑、智能手机能。A server can be a computing-capable device, such as a computer, tablet, or smartphone.
具体的,各个网络节点中可以存储有智能合约,用于基于智能合约对区块链中的事务进行处理。开发人员可以在用户终端上编写任务,并将任务信息上传至区块链网络平台。例如,可以在用户终端上安装用于连接区块链平台的客户端,从而通过该客户端上传任务。区块链平台接收到任务后,可以在智能合约中存储任务相关信息。Specifically, each network node may store a smart contract for processing transactions in the blockchain based on the smart contract. Developers can write tasks on the user terminal and upload the task information to the blockchain network platform. For example, a client for connecting to the blockchain platform can be installed on the user terminal, thereby uploading tasks through the client. After the blockchain platform receives the task, it can store the task-related information in the smart contract.
进一步的,开发人员在编写任务时,任务信息具体可以包括:调用的方法标识、任务执行条件、调用方法时所用的参数。其中,方法标识可以是智能合约中已有的方法的标识,从而在执行该任务时,可以直接调用智能合约中的方法。任务执行条件是指该任务的触发条件,当满足这一条件时,会触发区块链平台执行该任务。一般来说,调用方法时需要具有输入参数,例如,一个方法用于计算变量a与b的和,则在执行该方法时,需要获取a和b具体的值,也就是输入参数。Further, when a developer writes a task, the task information may specifically include: the method identifier to be called, the task execution condition, and the parameters used when the method is called. The method identifier can be an identifier of an existing method in the smart contract, so that when the task is performed, the method in the smart contract can be called directly. The task execution condition refers to the trigger condition of the task. When this condition is met, the blockchain platform will be triggered to execute the task. Generally speaking, when calling a method, it needs to have input parameters. For example, if a method is used to calculate the sum of variables a and b, when the method is executed, the specific values of a and b need to be obtained, that is, input parameters.
区块链平台接收到开发者上传的任务后,可以从中获取任务的执行条件,还可以确定任务对应的任务标识。区块链平台可以将任务标识以及执行条件发送给服务器,从而通过服务器根据执行条件对任务进行监控。无需向服务器发送任务在执行过程中的参数,从而达到参数不会外泄的效果。本实施例的方法,将任务封在智能合约中,任务对应的参数不会被发送出去,仅将任务标识以及任务执行条件发送个服务器即可。After the blockchain platform receives the task uploaded by the developer, it can obtain the execution conditions of the task from it, and can also determine the task identifier corresponding to the task. The blockchain platform can send the task identification and execution conditions to the server, so that the server can monitor the task according to the execution conditions. There is no need to send the parameters of the task during execution to the server, so as to achieve the effect that the parameters will not be leaked. In the method of this embodiment, the task is sealed in the smart contract, and the parameters corresponding to the task will not be sent out, and only the task identifier and the task execution conditions can be sent to the server.
步骤302,根据任务标识、执行条件确定目标任务标识,并向区块链平台发送目标任务标识,以使区块链平台执行目标任务标识对应的任务。Step 302: Determine the target task ID according to the task ID and execution conditions, and send the target task ID to the blockchain platform, so that the blockchain platform executes the task corresponding to the target task ID.
实际应用时,服务器可以存储区块链平台发送的任务标识以及任务执行条件。并基于任务执行条件,确定出满足条件的目标任务标识。例如,任务A的执行条件是时间为2018-12-17,11:29,也就是时间到达2018-12-17,11:29时,执行任务A。服务器可以监控时间,当时间满足执行条件时,就将任务A确定为目标任务标识。In practical applications, the server can store the task identifier and task execution conditions sent by the blockchain platform. And based on the task execution condition, determine the target task identifier that satisfies the condition. For example, the execution condition of task A is that the time is 2018-12-17, 11:29, that is, when the time reaches 2018-12-17, 11:29, task A is executed. The server can monitor the time, and when the time satisfies the execution condition, determines the task A as the target task identifier.
其中,服务器也可以是区块链平台中的一个节点,该节点中也可以存储区块链。当执行条件包括区块高度时,服务器可以根据存储的区块链监控区块高度,进而确定是否满足任务执行条件。The server can also be a node in the blockchain platform, and the blockchain can also be stored in the node. When the execution condition includes the block height, the server can monitor the block height according to the stored blockchain, and then determine whether the task execution condition is satisfied.
具体的,服务器还可以定时轮询存储的任务执行条件,从而及时确定满足条件的任务。Specifically, the server may also periodically poll the stored task execution conditions, so as to timely determine the tasks that meet the conditions.
进一步的,服务器确定满足任务的执行条件后,可以将满足条件的目标任务标识发送给区块链平台,从而使区块链平台能够执行相应的任务。区块链平台的智能合约中,存储有任务信息,具体包括调用的方法标识、执行方法所需的参数以及执行任务的条件。平台可以再次确定是否满足任务执行条件,若确实满足,则根据任务的参数,执行任务中包括的方法。Further, after determining that the execution conditions of the tasks are satisfied, the server can send the target task identifiers that satisfy the conditions to the blockchain platform, so that the blockchain platform can execute the corresponding tasks. In the smart contract of the blockchain platform, task information is stored, including the method identifier to be called, the parameters required to execute the method, and the conditions for executing the task. The platform can again determine whether the task execution conditions are met, and if so, execute the method included in the task according to the parameters of the task.
实际应用时,服务器可以向区块链平台发送目标任务标识,触发区块链平台执行运行任务的方法,该方法可以是runTask(),而区块链平台接收的目标任务标识就可以是执行runTask()的参数。例如,区块链平台接收到了服务器发送的目标任务标识A,则区块链平台可以针对任务A调用智能合约中的runTask()。在运行runTask()的过程中,可以先判断是否的确满足任务A的执行条件,若是,则可以获取智能合约中任务A的参数,并调用任务A中的方法标识对应的方法,例如,可能方法标识是m,则基于获取的参数运行方法m。In practical applications, the server can send the target task identifier to the blockchain platform to trigger the blockchain platform to execute the method of running the task. This method can be runTask(), and the target task identifier received by the blockchain platform can be the execution runTask. () parameter. For example, if the blockchain platform receives the target task identifier A sent by the server, the blockchain platform can call runTask() in the smart contract for task A. In the process of running runTask(), you can first determine whether the execution conditions of task A are indeed satisfied. If so, you can obtain the parameters of task A in the smart contract, and call the method in task A to identify the corresponding method, for example, the possible method The identity is m, then method m is run based on the obtained parameters.
本实施例提供的方法用于调用区块链平台中智能合约中的方法,该方法由设置有本实施例提供的方法的设备执行,该设备通常以硬件和/或软件的方式来实现。The method provided in this embodiment is used to invoke a method in a smart contract in a blockchain platform, and the method is executed by a device provided with the method provided in this embodiment, and the device is usually implemented in hardware and/or software.
本实施例提供的方法,区块链中任务的调用方法,包括:接收区块链平台发送的任务标识及执行条件;其中,任务的执行条件是在创建任务时确定的;根据任务标识、执行条件确定目标任务标识,并向区块链平台发送目标任务标识,以使区块链平台执行目标任务标识对应的任务。本实施例提供的方法,可以由服务器根据任务的执行条件以及任务标识监控是否满足任务的执行条件,并由服务器向区块链平台反馈满足执行条件的目标任务标识,从而触发区块链平台执行该目标任务,因此,本实施例提供的方法,能够根据预设条件触发任务的执行,满足用户对任务触发机制的需求。The method provided by this embodiment, the method for invoking a task in a blockchain, includes: receiving a task identifier and an execution condition sent by the blockchain platform; wherein, the execution condition of the task is determined when the task is created; The condition determines the target task identification, and sends the target task identification to the blockchain platform, so that the blockchain platform executes the task corresponding to the target task identification. In the method provided by this embodiment, the server can monitor whether the execution conditions of the task are met according to the execution conditions of the task and the task identifier, and the server can feed back the target task identifier that satisfies the execution conditions to the blockchain platform, thereby triggering the execution of the blockchain platform. For the target task, therefore, the method provided by this embodiment can trigger the execution of the task according to the preset condition, so as to satisfy the user's requirement for the task triggering mechanism.
图4为本发明再一示例性实施例示出的区块链中任务的调用方法的流程图。FIG. 4 is a flowchart of a method for invoking a task in a blockchain according to another exemplary embodiment of the present invention.
如图4所示,本实施例提供的区块链中任务的调用方法,包括:As shown in Figure 4, the method for invoking tasks in the blockchain provided by this embodiment includes:
步骤401,接收区块链平台发送的任务标识及执行条件;其中,任务的执行条件是在创建任务时确定的。Step 401: Receive the task identifier and execution conditions sent by the blockchain platform; wherein, the execution conditions of the task are determined when the task is created.
步骤401与步骤301中接收任务标识及执行条件的具体原理和实现方式类似,此处不再赘述。Step 401 is similar to the specific principle and implementation manner of receiving the task identifier and the execution condition in
步骤402,根据预设频率遍历执行条件,确定满足的执行条件,并将其对应的任务标识确定为目标任务标识。
其中,服务器可以存储接收的任务标识及其对应的执行条件,并按照预设频率遍历这些执行条件,从而确定出能够满足的执行条件。例如,可以设定固定的频率,如每0.1秒遍历一次执行条件。具体的频率可以根据需求进行设置,本实施例不对此进行限制。The server may store the received task identifiers and their corresponding execution conditions, and traverse these execution conditions according to a preset frequency, so as to determine the satisfiable execution conditions. For example, you can set a fixed frequency, such as traversing the execution condition every 0.1 seconds. The specific frequency can be set according to requirements, which is not limited in this embodiment.
具体的,执行条件可以包括执行时间和/或区块高度。Specifically, the execution condition may include execution time and/or block height.
步骤403,向区块链平台发送目标任务标识,以使区块链平台执行目标任务标识对应的任务。Step 403: Send the target task identifier to the blockchain platform, so that the blockchain platform executes the task corresponding to the target task identifier.
步骤401与步骤302中发送目标任务标识的具体原理和实现方式类似,此处不再赘述。Step 401 is similar to the specific principle and implementation manner of sending the target task identifier in
图5为本发明一示例性实施例示出的区块链中任务的调用装置的结构图。FIG. 5 is a structural diagram of an apparatus for invoking tasks in a blockchain according to an exemplary embodiment of the present invention.
如图5所示,本实施例提供的区块链中任务的调用装置,包括:As shown in Figure 5, the invoking device for tasks in the blockchain provided by this embodiment includes:
发送模块51,用于向服务器发送任务的标识及执行条件;其中,所述任务的执行条件是在创建所述任务时确定的;The sending
第一接收模块52,用于接收所述服务器发送的目标任务标识,并根据所述目标任务标识执行相应的任务;所述目标任务标识是所述服务器根据所述任务标识、所述执行条件确定的。The
本实施例提供的区块链中任务的调用装置,包括:发送模块,用于向服务器发送任务的标识及执行条件;其中,任务的执行条件是在创建任务时确定的;第一接收模块,用于接收服务器发送的目标任务标识,并根据目标任务标识执行相应的任务;目标任务标识是服务器根据任务标识、执行条件确定的。本实施例提供的装置,可以将任务的执行条件以及任务标识发送给服务器,通过服务器监控是否满足任务的执行条件,并由服务器向区块链平台反馈满足执行条件的目标任务标识,从而触发区块链平台执行该目标任务,因此,本实施例提供的装置,能够根据预设条件触发任务的执行,满足用户对任务触发机制的需求。The device for invoking a task in the blockchain provided by this embodiment includes: a sending module for sending the identification of the task and the execution condition to the server; wherein, the execution condition of the task is determined when the task is created; the first receiving module, It is used to receive the target task identification sent by the server, and execute the corresponding task according to the target task identification; the target task identification is determined by the server according to the task identification and execution conditions. The device provided in this embodiment can send the execution conditions of the task and the task identification to the server, monitor whether the execution conditions of the task are met through the server, and the server feeds back the identification of the target task that meets the execution conditions to the blockchain platform, thereby triggering the zone The blockchain platform executes the target task. Therefore, the device provided in this embodiment can trigger the execution of the task according to a preset condition, so as to satisfy the user's requirement for the task triggering mechanism.
本实施例提供的区块链中任务的调用装置的具体原理和实现方式均与图1所示的实施例类似,此处不再赘述。The specific principles and implementation manners of the apparatus for invoking tasks in the blockchain provided by this embodiment are similar to the embodiment shown in FIG. 1 , and details are not described herein again.
图6为本发明另一示例性实施例示出的区块链中任务的调用装置的结构图。FIG. 6 is a structural diagram of an apparatus for invoking a task in a blockchain according to another exemplary embodiment of the present invention.
如图6所示,在上述实施例的基础上,本实施例提供的区块链中任务的调用装置,还包括:As shown in FIG. 6 , on the basis of the above embodiment, the invoking device for tasks in the blockchain provided by this embodiment further includes:
第二接收模块53,用于接收用户终端发送的所述任务对应的关键信息;The
存储模块54,用于根据预设规则确定所述任务对应的所述任务标识,并将所述任务标识、所述关键信息存储在智能合约中。The
可选的,所述关键信息至少包括:Optionally, the key information includes at least:
装置标识、所述执行条件、执行参数。Device identification, the execution conditions, and execution parameters.
可选的,所述任务标识为数字;所述存储模块54具体用于:Optionally, the task identifier is a number; the
获取所述智能合约中已有的最大任务标识,若所述最大任务标识小于预设上限值,则根据递增规则确定所述任务对应的所述任务标识。Acquire the existing maximum task identification in the smart contract, and if the maximum task identification is less than a preset upper limit value, determine the task identification corresponding to the task according to an increment rule.
所述存储模块54具体用于在所述最大任务标识的基础上加1,得到所述任务对应的任务标识。The
可选的,若所述最大任务标识等于预设上限值,则所述存储模块54还用于:Optionally, if the maximum task identifier is equal to a preset upper limit value, the
获取所述智能合约中已有的最小任务标识,若所述最小任务标识大于预设下限值,则根据递减规则确定所述任务对应的所述任务标识。Obtain the existing minimum task identifier in the smart contract, and if the minimum task identifier is greater than a preset lower limit value, determine the task identifier corresponding to the task according to the decrement rule.
可选的,所述存储模块54具体用于:Optionally, the
在所述最小任务标识的基础上减1,得到所述任务对应的任务标识。The task identifier corresponding to the task is obtained by subtracting 1 from the minimum task identifier.
可选的,所述第一接收模块52具体用于:Optionally, the
在所述智能合约中获取与所述目标任务标识对应的所述关键信息;Acquire the key information corresponding to the target task identifier in the smart contract;
判断是否满足所述关键信息中包括的所述执行条件;judging whether the execution conditions included in the key information are satisfied;
若是,则基于所述关键信息中的所述执行参数运行所述关键信息中包括的所述装置标识对应的装置。If so, run the device corresponding to the device identifier included in the key information based on the execution parameter in the key information.
可选的,所述执行条件包括执行时间和/或区块高度。Optionally, the execution condition includes execution time and/or block height.
本实施例提供的区块链中任务的调用装置的具体原理和实现方式均与图2所示的实施例类似,此处不再赘述。The specific principles and implementation manners of the apparatus for invoking tasks in the blockchain provided by this embodiment are similar to the embodiment shown in FIG. 2 , and details are not described herein again.
图7为本发明又一示例性实施例示出的区块链中任务的调用装置的结构图。FIG. 7 is a structural diagram of an apparatus for invoking a task in a blockchain according to another exemplary embodiment of the present invention.
如图7所示,本实施例提供的区块链中任务的调用装置包括:As shown in FIG. 7 , the invoking device for tasks in the blockchain provided by this embodiment includes:
接收模块71,用于接收区块链平台发送的任务标识及执行条件;其中,所述任务的执行条件是在创建所述任务时确定的;The receiving
确定模块72,用于根据所述任务标识、所述执行条件确定目标任务标识,并向所述区块链平台发送所述目标任务标识,以使所述区块链平台执行所述目标任务标识对应的任务。A
本实施例提供的区块链中任务的调用装置,包括接收模块,用于接收区块链平台发送的任务标识及执行条件;其中,任务的执行条件是在创建任务时确定的;确定模块,用于根据任务标识、执行条件确定目标任务标识,并向区块链平台发送目标任务标识,以使区块链平台执行目标任务标识对应的任务。本实施例提供的装置,可以由服务器根据任务的执行条件以及任务标识监控是否满足任务的执行条件,并由服务器向区块链平台反馈满足执行条件的目标任务标识,从而触发区块链平台执行该目标任务,因此,本实施例提供的装置,能够根据预设条件触发任务的执行,满足用户对任务触发机制的需求。The device for invoking tasks in the blockchain provided by this embodiment includes a receiving module for receiving the task identifier and execution conditions sent by the blockchain platform; wherein, the execution conditions of the task are determined when the task is created; the determining module, It is used to determine the target task identification according to the task identification and execution conditions, and send the target task identification to the blockchain platform, so that the blockchain platform executes the task corresponding to the target task identification. With the device provided in this embodiment, the server can monitor whether the execution conditions of the task are met according to the execution conditions of the task and the task identifier, and the server can feed back the target task identifier that satisfies the execution conditions to the blockchain platform, thereby triggering the execution of the blockchain platform. For the target task, therefore, the device provided in this embodiment can trigger the execution of the task according to a preset condition, so as to satisfy the user's requirement for the task triggering mechanism.
本实施例提供的区块链中任务的调用装置的具体原理和实现方式均与图3所示的实施例类似,此处不再赘述。The specific principles and implementation manners of the apparatus for invoking tasks in the blockchain provided in this embodiment are similar to the embodiment shown in FIG. 3 , and details are not described herein again.
在上述实施例的基础上,本实施例提供的区块链中任务的调用装置,所述根确定模块72具体用于:On the basis of the above embodiment, in the apparatus for invoking tasks in the blockchain provided by this embodiment, the
根据预设频率遍历所述执行条件,确定满足的所述执行条件,并将其对应的所述任务标识确定为所述目标任务标识。The execution conditions are traversed according to the preset frequency, the satisfied execution conditions are determined, and the corresponding task identifier is determined as the target task identifier.
可选的,所述执行条件包括执行时间和/或区块高度。Optionally, the execution condition includes execution time and/or block height.
图8为本发明一示例性实施例示出的区块链中任务的调用设备的结构图。FIG. 8 is a structural diagram of a device invoking a task in a blockchain according to an exemplary embodiment of the present invention.
如图8所示,本实施例提供的区块链中任务的调用设备包括:As shown in FIG. 8 , the calling device of the task in the blockchain provided by this embodiment includes:
存储器81;
处理器82;以及
计算机程序;Computer program;
其中,所述计算机程序存储在所述存储器81中,并配置为由所述处理器82执行以实现如上所述的任一种区块链中任务的调用方法。Wherein, the computer program is stored in the
本实施例还提供一种计算机可读存储介质,其上存储有计算机程序,This embodiment also provides a computer-readable storage medium on which a computer program is stored,
所述计算机程序被处理器执行以实现如上所述的任一种区块链中任务的调用方法。The computer program is executed by the processor to implement any method for invoking tasks in the blockchain as described above.
本领域普通技术人员可以理解:实现上述各方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成。前述的程序可以存储于一计算机可读取存储介质中。该程序在执行时,执行包括上述各方法实施例的步骤;而前述的存储介质包括:ROM、RAM、磁碟或者光盘等各种可以存储程序代码的介质。Those of ordinary skill in the art can understand that all or part of the steps of implementing the above method embodiments may be completed by program instructions related to hardware. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps including the above method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk and other media that can store program codes.
最后应说明的是:以上各实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述各实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分或者全部技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的范围。Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, but not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: The technical solutions described in the foregoing embodiments can still be modified, or some or all of the technical features thereof can be equivalently replaced; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the technical solutions of the embodiments of the present invention. scope.
Claims (16)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910571848.2A CN112148803A (en) | 2019-06-28 | 2019-06-28 | Method, device, device and readable storage medium for invoking tasks in blockchain |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910571848.2A CN112148803A (en) | 2019-06-28 | 2019-06-28 | Method, device, device and readable storage medium for invoking tasks in blockchain |
Publications (1)
Publication Number | Publication Date |
---|---|
CN112148803A true CN112148803A (en) | 2020-12-29 |
Family
ID=73869052
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910571848.2A Pending CN112148803A (en) | 2019-06-28 | 2019-06-28 | Method, device, device and readable storage medium for invoking tasks in blockchain |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112148803A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115623518A (en) * | 2022-12-15 | 2023-01-17 | 阿里巴巴达摩院(杭州)科技有限公司 | Task processing method, platform, system, device and storage medium |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109033814A (en) * | 2018-07-18 | 2018-12-18 | 百度在线网络技术(北京)有限公司 | intelligent contract triggering method, device, equipment and storage medium |
CN109150943A (en) * | 2017-06-27 | 2019-01-04 | 华为技术有限公司 | The transmission method of information, device and system |
US20190018947A1 (en) * | 2017-07-14 | 2019-01-17 | Alibaba Group Holding Limited | Login information data processing |
-
2019
- 2019-06-28 CN CN201910571848.2A patent/CN112148803A/en active Pending
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109150943A (en) * | 2017-06-27 | 2019-01-04 | 华为技术有限公司 | The transmission method of information, device and system |
US20190018947A1 (en) * | 2017-07-14 | 2019-01-17 | Alibaba Group Holding Limited | Login information data processing |
CN109033814A (en) * | 2018-07-18 | 2018-12-18 | 百度在线网络技术(北京)有限公司 | intelligent contract triggering method, device, equipment and storage medium |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115623518A (en) * | 2022-12-15 | 2023-01-17 | 阿里巴巴达摩院(杭州)科技有限公司 | Task processing method, platform, system, device and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112650576B (en) | Resource scheduling method, device, equipment, storage medium and computer program product | |
US11509743B2 (en) | Provisioning multi-tenant, microservice architecture-based integration service in a cloud computing environment | |
US10033816B2 (en) | Workflow service using state transfer | |
US9684534B2 (en) | Monitoring and modifying allocated computing resources | |
CN110880100A (en) | Business approval processing method, device and system | |
US10803413B1 (en) | Workflow service with translator | |
CN108196959B (en) | Resource management method and device of ETL system | |
WO2017067392A1 (en) | Method and system for handling work flow exception | |
WO2020216077A1 (en) | Blockchain event deduplication method and apparatus, and computer device and storage medium | |
CN113742109A (en) | Third-party service docking method, device, equipment and storage medium | |
CN109034603B (en) | Business process execution method, device and computer readable storage medium | |
US9141423B2 (en) | Optimized datacenter management by centralized task execution through dependency inversion | |
CN108667864B (en) | Method and device for scheduling resources | |
CN112148803A (en) | Method, device, device and readable storage medium for invoking tasks in blockchain | |
CN114090113A (en) | Method, device and equipment for dynamically loading data source processing plug-in and storage medium | |
CN113791876A (en) | System, method and apparatus for processing tasks | |
CN113342885B (en) | Data import method, apparatus, apparatus and computer program product | |
JP5884566B2 (en) | Batch processing system, progress confirmation device, progress confirmation method, and program | |
WO2023185137A1 (en) | Task management method and apparatus, and device and storage medium | |
CN115271861A (en) | Request filtering method, device, equipment and storage medium | |
CN110716972A (en) | Method and device for processing error of high-frequency calling external interface | |
CN118101768B (en) | Transaction method and system based on blockchain, electronic device and storage medium | |
CN111338792A (en) | A cluster resource release method, device and medium | |
CN111324368A (en) | A data sharing method and server | |
CN115562884B (en) | Message transmission method, device, electronic device and storage medium |
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 |