技术领域Technical Field
本申请涉及信息技术领域,尤其涉及一种区块链业务受理及业务共识方法及装置。The present application relates to the field of information technology, and in particular to a method and device for blockchain business acceptance and business consensus.
背景技术Background Art
随着信息技术的发展,区块链技术作为新兴技术,由于具有的开放性、不可篡改性、去中心化等优点,已成为人们重点关注的技术。With the development of information technology, blockchain technology, as an emerging technology, has become a technology that people focus on due to its advantages such as openness, immutability and decentralization.
在现有区块链技术中,区块链网络中的每个共识节点,均可受理客户端发送的业务请求。以一个共识节点为例进行说明,当共识节点接收到业务请求后,可先根据该业务请求,确定对应的业务数据。之后共识节点可将业务数据广播给其他共识节点。当共识节点接收到其他共识节点发送的预处理块后,还可对该预处理快进行共识校验,并可在校验通过后存储该预处理块。In existing blockchain technology, every consensus node in a blockchain network can accept service requests from clients. For example, when a consensus node receives a service request, it first determines the corresponding service data based on the request. It then broadcasts the service data to other consensus nodes. When a consensus node receives a pre-processed block from another consensus node, it performs a consensus check on the pre-processed block and, if the check passes, stores the pre-processed block.
其中,共识节点在受理业务请求后,通常将业务请求对应的业务数据存储在该共识节点的缓存中。在后续对业务数据进行共识校验通过后,从缓存中释放该业务数据。类似的,对于其他共识节点发送的业务数据,也可同样存储在缓存中,并在通过共识校验后释放。After accepting a service request, a consensus node typically stores the corresponding business data in its cache. After the business data passes a subsequent consensus check, it is released from the cache. Similarly, business data sent by other consensus nodes can also be stored in the cache and released after passing the consensus check.
对于共识节点来说,未存储在区块链中的数据通常均暂存在共识节点的缓存中,导致进行共识校验时,可校验的业务数据的数量受该共识节点缓存容量的限制,使得共识校验的效率受限。并且,当共识节点的缓存空间不足时,共识节点也难以对接收到的业务请求进行处理。For consensus nodes, data not stored in the blockchain is usually temporarily stored in the consensus node's cache. As a result, the amount of business data that can be verified during consensus verification is limited by the consensus node's cache capacity, which limits the efficiency of consensus verification. Moreover, when the consensus node's cache space is insufficient, it is difficult for the consensus node to process received business requests.
发明内容Summary of the Invention
本申请实施例提供一种区块链业务受理及业务共识方法,用于解决在现有区块链技术中业务执行效率低的问题。The embodiments of the present application provide a blockchain business acceptance and business consensus method for solving the problem of low business execution efficiency in existing blockchain technology.
本申请实施例提供一种区块链业务受理及业务共识装置,用于解决在现有区块链技术中业务执行效率低的问题。The embodiment of the present application provides a blockchain business acceptance and business consensus device for solving the problem of low business execution efficiency in existing blockchain technology.
本申请实施例采用下述技术方案:The embodiments of this application adopt the following technical solutions:
一种区块链业务受理方法,共识节点中包括第一应用、第二应用以及数据库,包括:A blockchain business acceptance method, wherein a consensus node includes a first application, a second application, and a database, including:
所述第一应用接收客户端发送的业务请求,并根据该业务请求确定对应的待发送的业务数据;The first application receives a service request sent by a client, and determines corresponding service data to be sent according to the service request;
所述第一应用将所述待发送的业务数据存储在所述数据库中;The first application stores the service data to be sent in the database;
当满足预设条件时,所述第二应用或者所述第一应用,从所述数据库中捞取待发送的业务数据发送至其他共识节点存储。When the preset conditions are met, the second application or the first application retrieves the business data to be sent from the database and sends it to other consensus nodes for storage.
一种区块链业务共识方法,第一共识节点中包括第一应用、第二应用以及第一数据库,包括:A blockchain business consensus method, wherein a first consensus node includes a first application, a second application, and a first database, including:
所述第一应用接收共识数据,并存储在所述第一数据库中;The first application receives the consensus data and stores it in the first database;
所述第二应用从所述第一数据库中捞取所述共识数据,进行共识校验;The second application retrieves the consensus data from the first database and performs consensus verification;
所述第二应用将校验结果添加到所述共识数据中并存储至所述第一数据库,并将所述校验结果发送至其他共识节点继续进行共识校验。The second application adds the verification result to the consensus data and stores it in the first database, and sends the verification result to other consensus nodes to continue consensus verification.
一种区块链业务受理装置,共识节点中包括所述装置,第二应用以及数据库,所述装置包括:A blockchain business acceptance device, wherein a consensus node includes the device, a second application, and a database, and the device includes:
接收模块,接收客户端发送的业务请求,并根据该业务请求确定对应的待发送的业务数据;The receiving module receives the service request sent by the client and determines the corresponding service data to be sent according to the service request;
存储模块,将所述待发送的业务数据存储在所述数据库中;A storage module, storing the service data to be sent in the database;
当满足预设条件时,所述第二应用或者发送模块,从所述数据库中捞取待发送的业务数据发送至其他共识节点存储。When the preset conditions are met, the second application or sending module retrieves the business data to be sent from the database and sends it to other consensus nodes for storage.
一种区块链业务共识装置,第一共识节点中包括接收模块、处理发送模块以及第一数据库,所述装置包括:A blockchain business consensus device, wherein a first consensus node includes a receiving module, a processing and sending module, and a first database, and the device includes:
所述接收模块,接收共识数据,并存储在所述第一数据库中;The receiving module receives the consensus data and stores it in the first database;
所述处理发送模块,从所述第一数据库中捞取所述共识数据,进行共识校验;The processing and sending module retrieves the consensus data from the first database and performs consensus verification;
所述处理发送模块,将校验结果添加到所述共识数据中并存储至所述第一数据库,并将所述校验结果发送至其他共识节点继续进行共识校验。The processing and sending module adds the verification result to the consensus data and stores it in the first database, and sends the verification result to other consensus nodes to continue consensus verification.
本申请实施例采用的上述至少一个技术方案能够达到以下有益效果:At least one of the above technical solutions adopted in the embodiments of the present application can achieve the following beneficial effects:
共识节点中存在第一应用、第二应用以及数据库。该数据库用于存储由第一应用以及第二应用处理后的业务数据,以便减少共识节点的缓存压力。可见,通过本申请实施例提供的方法,由于共识节点只要确定业务请求对应的业务数据,便可将该业务数据存储在数据库中,等待发送给其他共识节点,所以共识节点的缓存的占用率较低。使得共识节点在单位时间内可处理的业务的数量增加,从而提高了共识节点进行共识校验以及对业务请求进行处理的效率。The consensus node contains a first application, a second application, and a database. The database is used to store the business data processed by the first application and the second application in order to reduce the cache pressure of the consensus node. It can be seen that through the method provided by the embodiment of the present application, since the consensus node can store the business data corresponding to the business request in the database as long as it determines the business data, waiting to be sent to other consensus nodes, the cache occupancy rate of the consensus node is low. This increases the number of businesses that the consensus node can process per unit time, thereby improving the efficiency of the consensus node in performing consensus verification and processing business requests.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
此处所说明的附图用来提供对本申请的进一步理解,构成本申请的一部分,本申请的示意性实施例及其说明用于解释本申请,并不构成对本申请的不当限定。在附图中:The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
图1为本申请实施例提供的一种区块链业务受理过程;FIG1 is a blockchain business acceptance process provided by an embodiment of the present application;
图2为本申请实施例提供的一种区块链业务共识过程;FIG2 is a blockchain business consensus process provided by an embodiment of the present application;
图3为本申请实施例提供的一种区块链业务受理装置的结构示意图;FIG3 is a schematic diagram of the structure of a blockchain business acceptance device provided in an embodiment of the present application;
图4为本申请实施例提供的一种区块链业务共识装置的结构示意图。FIG4 is a schematic diagram of the structure of a blockchain business consensus device provided in an embodiment of the present application.
具体实施方式DETAILED DESCRIPTION
为使本申请的目的、技术方案和优点更加清楚,下面将结合本申请具体实施例及相应的附图对本申请技术方案进行清楚、完整地描述。显然,所描述的实施例仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。To make the purpose, technical solutions, and advantages of this application more clear, the technical solutions of this application will be clearly and completely described below in conjunction with the specific embodiments of this application and the corresponding drawings. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
以下结合附图,详细说明本申请各实施例提供的技术方案。The following describes in detail the technical solutions provided by various embodiments of the present application in conjunction with the accompanying drawings.
图1为本申请实施例提供的一种区块链共识过程,其中,共识节点中包括第一应用、第二应用以及数据库,具体可包括以下步骤:FIG1 illustrates a blockchain consensus process according to an embodiment of the present application, wherein the consensus node includes a first application, a second application, and a database, and specifically may include the following steps:
S101:所述第一应用接收客户端发送的业务请求,并根据业务请求确定对应的待发送的业务数据。S101: The first application receives a service request sent by a client, and determines corresponding service data to be sent according to the service request.
在本申请实施例中,对于区块链网络中的各共识节点,共识节点中可以包含一个或者多个区块链应用以及数据库。其中,区块链应用可受理业务请求并对预处理块进行共识校验,数据库用于存储区块链应用确定的业务数据(如,进行共识校验过程中产生的数据、受理业务请求后产生的数据等等)。In an embodiment of the present application, each consensus node in a blockchain network may include one or more blockchain applications and a database. The blockchain application may accept service requests and perform consensus verification on pre-processed blocks, and the database may store service data determined by the blockchain application (e.g., data generated during the consensus verification process, data generated after accepting service requests, etc.).
进一步地,用户通常需要通过客户端发送指令或者请求。后续,共识节点可接收客户端发送的业务请求,并根据业务请求执行后续的步骤。Furthermore, users usually need to send instructions or requests through the client. Subsequently, the consensus node can receive the business request sent by the client and execute subsequent steps according to the business request.
其中,共识节点可接收多个客户端发送的业务请求,并根据各业务请求进行业务处理。该共识节点可以是终端,例如,手机、平板电脑、个人电脑等设备。该共识节点也可以是服务器,并且该服务器可以是单独的一台设备,也可以是由多台设备组成的系统,例如,分布式服务器。本申请对共识节点具体为何种设备不做具体限定。The consensus node can receive service requests from multiple clients and process them accordingly. The consensus node can be a terminal, such as a mobile phone, tablet computer, or personal computer. The consensus node can also be a server, which can be a single device or a system composed of multiple devices, such as a distributed server. This application does not specify the specific device that a consensus node represents.
具体的,在共识节点接收业务请求时,可以是共识节点中安装的第一应用接收业务请求。并且在后续步骤中,由第一应用根据业务请求确定对应的业务逻辑,并分配线程执行业务。当然,在共识节点中安装的应用程序还可以有多个(如,第二应用),则各应用程序可分别接收不同客户端发送的业务请求,并分别进行后续操作。为方便描述,在本申请实施例中,仅以共识节点中包含第一应用以及第二应用为例进行说明,但并不限制共识节点中存在更多的应用。Specifically, when the consensus node receives a service request, it may be the first application installed in the consensus node that receives the service request. And in the subsequent steps, the first application determines the corresponding business logic based on the service request and allocates threads to execute the service. Of course, there may be multiple applications installed in the consensus node (such as the second application), and each application can receive service requests sent by different clients respectively, and perform subsequent operations respectively. For the convenience of description, in the embodiment of the present application, only the first application and the second application are included in the consensus node as an example, but it does not limit the presence of more applications in the consensus node.
进一步地,共识节点也可以由多台设备组成的系统,并且每台设备对应安装区块链应用,则各设备可通过安装的区块链应用分别接收不同客户端发送的业务请求,并独立的进行后续操作。Furthermore, the consensus node can also be a system composed of multiple devices, and each device has a corresponding blockchain application installed. Then, each device can receive business requests sent by different clients through the installed blockchain application and perform subsequent operations independently.
另外,无论共识节点中安装多个应用程序还是由多个设备组成,该共识节点在区块链网络中可视为是一个受理业务请求并可发起共识的节点。具体的共识节点如何构成,可由根据需要进行配置。例如,当共识节点的运行压力较大,经常有业务请求排队等待处理时,可为共识节点配置更多的应用或者配置更多的设备。Furthermore, regardless of whether a consensus node is comprised of multiple applications or multiple devices, it can be considered a single node within the blockchain network that accepts business requests and initiates consensus. The specific composition of a consensus node can be configured based on needs. For example, if a consensus node is under high operational pressure and frequently has a queue of business requests waiting to be processed, it can be configured with more applications or devices.
更进一步地,在本申请实施例中,第一应用在对接收的业务请求进行业务处理后,可将业务处理结果作为业务数据。并且,由于该业务数据尚未发送至其他共识节点,所以第一应用还可以确定该业务数据的状态为待发送状态。并将该业务数据及其对应的待发送状态存储在数据库中。Furthermore, in an embodiment of the present application, after performing business processing on a received business request, the first application may use the business processing result as business data. Furthermore, since the business data has not yet been sent to other consensus nodes, the first application may also determine that the state of the business data is a pending state. The business data and its corresponding pending state are stored in a database.
或者,第一应用可以在确定业务数据之后,为该业务数据添加待发送标识。再将添加了待发送标识的业务数据,作为待发送的业务数据存储在数据库中。则第二应用可以根据待发送标识确定该业务数据为待发送的业务数据。Alternatively, after determining the service data, the first application may add a to-be-sent flag to the service data. The service data with the to-be-sent flag added is then stored in the database as to-be-sent service data. The second application may then determine that the service data is to-be-sent service data based on the to-be-sent flag.
本申请并不限定共识节点确定业务数据的状态的方式,只要共识节点中的各应用或者各设备,在访问数据库时可以确定存储的业务数据的状态即可。This application does not limit the way in which the consensus node determines the status of business data, as long as each application or device in the consensus node can determine the status of the stored business data when accessing the database.
例如,若用户要进行交易业务,用户发送的业务请求中可携带有交易双方的身份信息、交易金额、支出方的账号信息等数据。共识节点的第一应用可以根据业务请求中携带的数据,确定并创建对应的交易业务。第一应用在确定业务数据之后,为该业务数据添加待发送的标识。For example, if a user wants to conduct a transaction, the transaction request they send may include the identities of both parties, the transaction amount, the payee's account information, and other data. Based on the data in the transaction request, the first application on the consensus node can determine and create the corresponding transaction. After determining the transaction data, the first application adds a pending send flag to the data.
其中,待发送标识也可作为业务数据中的一种业务属性被添加在业务数据中,例如,表1所示的业务数据的结构示意。The to-be-sent identifier may also be added to the business data as a business attribute in the business data, for example, the structure diagram of the business data shown in Table 1.
表1Table 1
在表1所示的业务数据的结构示意中的状态标识,可以是由共识节点的第一应用添加在业务数据中的。通过状态标识,共识节点中的任一应用可以确定该业务数据当前的状态为待发送状态。则下一步在对业务数据进行操作时,根据该状态标识可确定需要将该业务数据发送至其他共识节点。The status identifier in the business data structure shown in Table 1 can be added to the business data by the first application of the consensus node. Using this status identifier, any application in the consensus node can determine that the business data is currently in a pending state. When performing operations on the business data in the next step, the status identifier can be used to determine whether the business data needs to be sent to other consensus nodes.
当然,在本申请实施例中业务数据具体包括哪些内容,以及业务属性中具体包括哪些属性本申请并不做具体限定。Of course, in the embodiments of the present application, the present application does not specifically limit what the business data specifically includes and what attributes the business attributes specifically include.
S102:所述第一应用将所述待发送的业务数据存储在所述数据库中。S102: The first application stores the service data to be sent in the database.
在本申请实施例中,步骤S101中确定的待发送的业务数据过程依赖于共识节点的缓存,所以该业务数据也存储在缓存中。于是,第一应用还可将该业务数据转存至该在共识节点的数据库中,以释放缓存空间用于执行其他业务。In this embodiment of the present application, the business data to be sent in step S101 depends on the cache of the consensus node, so the business data is also stored in the cache. Therefore, the first application can also transfer the business data to the database of the consensus node to free up cache space for executing other business.
具体的,数据库可以是共识节点用于存储数据的存储设备,并且可以是采用非易失性存储器的存储设备。当然,数据库与共识节点可以位于同一台设备内(如,数据库可以位于个人电脑的硬盘中),也可以位于不同的设备内(如,外接移动硬盘),本申请对此并不做具体限定。Specifically, the database can be a storage device used by the consensus node to store data, and can be a storage device using non-volatile memory. Of course, the database and the consensus node can be located in the same device (e.g., the database can be located in the hard drive of a personal computer) or in different devices (e.g., an external mobile hard drive), and this application does not specifically limit this.
另外,当共识节点中安装有多个区块链应用时,各应用可分别接收不同客户端发送的业务请求。并将各自分别确定的业务数据存储在数据库中。则数据库可视为是各应用共用的数据库,各应用均可具有访问数据库的权限。也就是说,第二应用也可确定待发送的业务数据并存储在数据库中。Furthermore, when multiple blockchain applications are installed on a consensus node, each application can receive service requests from different clients and store the service data determined by each application in a database. This database can then be considered a shared database for all applications, with each application having access rights. This means that a second application can also determine service data to be sent and store it in the database.
进一步地,由于在步骤S101中所述的,共识节点可以是由多台设备组成的系统,所以当共识节点为多台设备组成的系统时,共识节点的各设备均可访问数据库,该数据库在共识节点内可视为是各设备共享的存储设备。Furthermore, as described in step S101, the consensus node can be a system composed of multiple devices. Therefore, when the consensus node is a system composed of multiple devices, each device of the consensus node can access the database, and the database can be regarded as a storage device shared by each device in the consensus node.
于是,共识节点的第一应用通过将待发送的业务数据存储在数据库中,释放业务数据占用的缓存空间,用于执行其他业务。使得在不增加共识节点的硬件配置的情况下,该共识节点可以受理更多的业务请求。Therefore, the first application of the consensus node stores the business data to be sent in the database, freeing up the cache space occupied by the business data for executing other businesses. This allows the consensus node to accept more business requests without increasing the hardware configuration of the consensus node.
S103:当满足预设条件时,所述第二应用或者所述第一应用,从所述数据库中捞取待发送的业务数据发送至其他共识节点存储。S103: When a preset condition is met, the second application or the first application retrieves the business data to be sent from the database and sends it to other consensus nodes for storage.
在本申请实施例中,共识节点的第一应用在将待发送的业务数据存储在数据库中后,共识节点的第一应用可继续接收其他客户端发送的业务请求。并执行如步骤S101以及步骤S102相同的操作(同理共识节点的第二应用也可以同步执行步骤S101以及步骤S102相同的操作)。于是,共识节点对应的数据库中可存储若干待发送的业务数据。为了使其他共识节点正常进行共识校验,该共识节点的数据库中存储的业务数据还需要发送至其他共识节点中进行存储。In an embodiment of the present application, after the first application of the consensus node stores the business data to be sent in the database, the first application of the consensus node can continue to receive business requests sent by other clients. And perform the same operations as steps S101 and S102 (similarly, the second application of the consensus node can also synchronously perform the same operations as steps S101 and S102). Therefore, a number of business data to be sent can be stored in the database corresponding to the consensus node. In order for other consensus nodes to perform consensus verification normally, the business data stored in the database of the consensus node also needs to be sent to other consensus nodes for storage.
于是,在本申请实施例中,当满足预先条件时,还可由共识节点的第一或者第二应用从数据库中,捞取待发送的业务数据发送至其他共识节点存储,以便其他共识节点后续进行共识校验。并且,针对每个待发送的业务数据,当待发送的业务数据被发送之后,还可更新待发送的业务数据为已发送的业务数据。Therefore, in the embodiment of the present application, when the pre-conditions are met, the first or second application of the consensus node can also retrieve the business data to be sent from the database and send it to other consensus nodes for storage so that other consensus nodes can subsequently perform consensus verification. In addition, for each business data to be sent, after the business data to be sent is sent, the business data to be sent can be updated to the business data that has been sent.
具体的,共识节点中的第一应用或者第二应用中的至少一个,可以根据该共识节点当前的状态,判断是否已经满足预设的条件。若是,则第一应用和/或第二应用捞取各待发送的业务数据并发送,若否,则不捞取。Specifically, at least one of the first application or the second application in the consensus node can determine whether a preset condition has been met based on the current state of the consensus node. If so, the first application and/or the second application retrieves the business data to be sent and sends it; if not, the first application and/or the second application does not retrieve it.
其中,当共识节点的数据库中存储的待发送的业务数据的数量达到预设阈值时,确定共识节点当前的状态满足预设的条件。或者,根据共识节点的发送周期,当指定时刻到达时确定满足预设的条件,即,周期性的捞取数据中的各待发送的业务数据,等等。When the amount of business data to be sent stored in the consensus node's database reaches a preset threshold, the consensus node's current state is determined to meet the preset conditions. Alternatively, based on the consensus node's sending cycle, the preset conditions are determined to be met when a specified time arrives, i.e., the business data to be sent is periodically retrieved from the data, etc.
当然,预设的条件也可根据实际需要进行设置。如,预设的条件也可以随着时间因素以及业务量的变化而变化,当时间为夜间时(如,24点至4点)增加捞取业务数据的间隔时间,当业务量增加时减少捞取的业务数据的时间间隔等等,本申请对此不做具体限定。Of course, the preset conditions can also be set according to actual needs. For example, the preset conditions can also change with time factors and changes in business volume. When it is nighttime (e.g., 24:00 to 4:00), the interval for retrieving business data can be increased, and when the business volume increases, the interval for retrieving business data can be reduced, etc. This application does not make specific restrictions on this.
另外,当第一应用或者第二应用在捞取各待发送的业务数据时,可以将共识节点对应的数据库中的各待发送的业务数据全部捞取并发送。也可以捞取指定数量的待发送的业务数据,本申请不做具体限定。并且,上述条件可以择一使用,或者任意组合使用。In addition, when the first application or the second application retrieves the business data to be sent, it can retrieve and send all the business data to be sent from the database corresponding to the consensus node. It can also retrieve a specified amount of business data to be sent, which is not specifically limited in this application. Moreover, the above conditions can be used individually or in any combination.
进一步地,第一应用或者第二应用在从数据库中捞取待发送的业务数据时,可以根据各待发送的业务数据的生成时间先后顺序,捞取各待发送的业务数据。并将捞取的各待发送的业务数据按照捞取的先后顺序发送至其他共识节点。具体的,共识节点可以逐一捞取并发送各待发送的业务数据,也可将捞取各待发送的业务数据并打包之后,再一并发送至其他共识节点。Furthermore, when the first application or the second application retrieves the business data to be sent from the database, it can retrieve the business data to be sent in the order of their generation time. The retrieved business data to be sent are then sent to other consensus nodes in the order in which they were retrieved. Specifically, the consensus node can retrieve and send each business data to be sent one by one, or it can retrieve and package the business data to be sent and then send them to other consensus nodes together.
更进一步地,第一应用或者第二应用还可将发送后的各待发送的业务数据,更新为各已发送的业务数据。Furthermore, the first application or the second application may also update the service data to be sent after being sent to the service data that has been sent.
例如,第一应用从数据库中捞取业务数据F并发送后,可以将数据库中业务数据F对应的状态更新为已发送状态。或者,将业务数据F的业务属性中的状态标识,更新为已发送的标识。也就是说,第一应用可以在调用业务数据F时,便更新业务数据F的状态标识。For example, after the first application retrieves business data F from the database and sends it, it can update the status corresponding to business data F in the database to the sent state. Alternatively, it can update the status flag in the business attributes of business data F to the sent flag. In other words, the first application can update the status flag of business data F when it calls business data F.
当然,由于网络延时或者设备故障等问题,所以可能出现业务数据发送失败的情况。于是,在本申请实施例中,第一应用或者第二应用也可以在接收到其他共识节点返回的针对发送的业务数据的响应信息时,再根据响应信息更新该业务数据的状态标识。具体采用何种方法本申请对此不做具体限定。Of course, due to network delays or equipment failures, it is possible that business data transmission fails. Therefore, in the embodiment of the present application, the first application or the second application can also update the status identifier of the business data according to the response information returned by other consensus nodes when receiving the response information for the sent business data. The specific method used is not specifically limited in this application.
基于图1所示的区块链业务受理方法,可见共识节点中可包括第一应用、第二应用以及数据库。该数据库用于存储第一应用以及第二应用进行业务处理后的业务数据,以便减少共识节点的缓存压力。共识节点即使在等待共识阶段也可以持续接收业务请求以及受理业务,而不会因为缓存空间不足而造成业务等待。同时,由于业务数据均存储在数据库中,所以共识节点可以根据需要扩展安装的应用数量。使得共识节点可以同时接收处理更多的业务请求,提高共识节点的工作效率。并且,当满足预设条件时,可由共识节点中第一或者第二应用,捞取数据库中存储的待发送的业务数据,并发送至其他共识节点存储。可见,通过本申请提供的方法,共识节点的运行效率不再受限于缓存大小。并且,由于共识节点中各应用都可以受理业务请求、发送业务数据,使得共识节点可以通过部分应用发送待发送的业务数据,同时另一部分应用受理业务请求,提高共识节点进行共识校验以及对业务请求进行处理的效率。Based on the blockchain business acceptance method shown in Figure 1, it can be seen that the consensus node may include a first application, a second application, and a database. The database is used to store business data processed by the first and second applications, thereby reducing cache pressure on the consensus node. Even while waiting for consensus, the consensus node can continue to receive business requests and process business, without being forced to wait due to insufficient cache space. Furthermore, because all business data is stored in the database, the consensus node can expand the number of installed applications as needed. This allows the consensus node to simultaneously receive and process more business requests, improving its operational efficiency. Furthermore, when preset conditions are met, the first or second application in the consensus node can retrieve the pending business data stored in the database and send it to other consensus nodes for storage. As can be seen, with the method provided by this application, the operating efficiency of the consensus node is no longer limited by cache size. Furthermore, because each application in the consensus node can accept business requests and send business data, the consensus node can send pending business data through some applications while other applications simultaneously accept business requests, improving the efficiency of the consensus node in performing consensus verification and processing business requests.
另外,在本申请实施例中,该第一或第二应用在发送待发送的业务数据时,可以先将该业务数据的状态更新为已发送状态,使得其他共识节点接收并存储的业务数据处于已发送状态。以使得其他共识节点在根据业务数据进行共识校验时,不会遗漏该第一或第二应用发送的业务数据。In addition, in an embodiment of the present application, when the first or second application sends business data to be sent, it can first update the status of the business data to the sent state, so that the business data received and stored by other consensus nodes is in the sent state. This ensures that when other consensus nodes perform consensus verification based on the business data, they will not miss the business data sent by the first or second application.
进一步地,在本申请实施例中,第一应用在接收到其他共识节点发送的业务数据之后,也可根据业务数据的哈希值以及业务数据的具体内容,对待发送的业务数据进行校验。并且在校验通过后,再将业务数据作为存储在数据库。Furthermore, in the embodiment of the present application, after receiving the business data sent by other consensus nodes, the first application can also verify the business data to be sent based on the hash value of the business data and the specific content of the business data. After the verification is passed, the business data is stored in the database.
更进一步的,在本申请步骤S101中,与现有技术相同,共识节点在确定业务请求时,可对业务请求中携带的进行业务处理所需的数据进行校验。并且,在校验通过之后,继续进行后续创建业务、进行业务处理等操作。具体的,校验过程以及实施细节可与现有技术中一致,本申请不再赘述。Furthermore, in step S101 of the present application, similar to the prior art, when determining a service request, the consensus node may verify the data required for service processing carried in the service request. Furthermore, after verification is successful, subsequent operations such as creating the service and performing service processing may proceed. Specifically, the verification process and implementation details may be consistent with the prior art and will not be further elaborated in this application.
另外,在本申请实施例中,共识节点在确定待发送的业务数据之后,便可向客户端返回对应于业务请求的响应信息,以使得客户端确定共识节点已经受理了业务请求。需要说明的是,当共识节点根据业务请求确定了业务数据时,便可视为共识节点受理了业务请求。In addition, in the embodiment of the present application, after the consensus node determines the business data to be sent, it can return a response message corresponding to the business request to the client, so that the client can determine that the consensus node has accepted the business request. It should be noted that when the consensus node determines the business data based on the business request, it can be considered that the consensus node has accepted the business request.
需要说明的是,本申请实施例所提供方法的各步骤的执行主体均可以是同一设备,或者,该方法也由不同设备作为执行主体。比如,步骤S101和步骤S102的执行主体可以为设备1,步骤S103的执行主体可以为设备2;又比如,步骤S101的执行主体可以为设备1,步骤S102和步骤S103的执行主体可以为设备2;等等。It should be noted that the execution entity of each step of the method provided in the embodiments of the present application can be the same device, or the method can be executed by different devices. For example, the execution entity of steps S101 and S102 can be device 1, and the execution entity of step S103 can be device 2; for another example, the execution entity of step S101 can be device 1, and the execution entity of steps S102 and S103 can be device 2; and so on.
基于图1所示区块链业务受理方法,本申请实施例还对应提供一种区块链业务共识的方法,如图2所示。Based on the blockchain business acceptance method shown in Figure 1, the embodiment of the present application also provides a blockchain business consensus method, as shown in Figure 2.
图2为本申请实施例提供的一种区块链业务共识的过程,其中,第一共识节点中包括第一应用、第二应用以及第一数据库,具体包括以下步骤:FIG2 illustrates a blockchain business consensus process provided by an embodiment of the present application, wherein the first consensus node includes a first application, a second application, and a first database, specifically including the following steps:
S201:所述第一应用接收共识数据,并存储在所述第一数据库中。S201: The first application receives consensus data and stores it in the first database.
在本申请实施例中,与图1所示的区块链业务受理过程中所述的共识节点类似,第一共识节点包括第一应用、第二应用以及第一数据库。并且,第一共识节点中也可包含更多的应用,本申请对此不做限定。但为方便后续描述,在本申请实施例中以第一应用、第二应用为例进行说明。In the embodiments of this application, similar to the consensus node described in the blockchain business acceptance process shown in Figure 1, the first consensus node includes a first application, a second application, and a first database. Furthermore, the first consensus node may also include more applications, which is not limited in this application. However, for the convenience of subsequent description, the first application and the second application are used as examples in this embodiment of the application.
通常,区块链网络中的各共识节点可以根据区块链的共识机制,确定发起共识的共识节点。于是,第一共识节点的第一应用可接收共识数据,并将共识数据存储在第一数据库中。Typically, each consensus node in a blockchain network can determine a consensus node that initiates consensus based on the consensus mechanism of the blockchain. Then, the first application of the first consensus node can receive the consensus data and store the consensus data in the first database.
另外,在某些共识算法中,共识节点可根据其他共识节点的校验结果,确定是否存储共识数据。例如,在一些共识算法中,对每个共识节点来说,该共识节点需要判断全网的共识节点中是否有超过50%的共识节点校验结果为通过,若是,则该共识节点存储预处理块,若否,则不存储。In addition, in some consensus algorithms, consensus nodes can determine whether to store consensus data based on the verification results of other consensus nodes. For example, in some consensus algorithms, each consensus node needs to determine whether more than 50% of the consensus nodes in the entire network have passed the verification. If so, the consensus node stores the pre-processed block; otherwise, it does not store it.
于是,校验结果也可以视为是一种共识数据,则本申请中共识数据可以包括:需要进行共识校验的数据(通常为预处理快)以及对应的校验结果。Therefore, the verification result can also be regarded as a kind of consensus data. The consensus data in this application may include: data that needs to be consensus verified (usually pre-processed data) and the corresponding verification result.
当然,无论第一应用接收到何种形式的共识数据,第一应用均可将共识数据存储在第一数据库中。Of course, no matter what form of consensus data the first application receives, the first application can store the consensus data in the first database.
S202:所述第二应用从所述第一数据库中捞取所述共识数据,进行共识校验。S202: The second application retrieves the consensus data from the first database and performs consensus verification.
在本申请实施例中,第二应用可从第一数据库中,捞取共识数据并对共识数据进行校验,以进行后续操作。In an embodiment of the present application, the second application may retrieve the consensus data from the first database and verify the consensus data to perform subsequent operations.
具体的,第二应用可以从第一数据库中捞取共识数据(具体可以是预处理块)以及第一数据库中的已发送状态的业务数据,根据已发送状态的业务数据,对共识数据进行共识校验,并确定校验结果。Specifically, the second application can retrieve consensus data (specifically, a preprocessing block) and business data in a sent state in the first database from the first database, perform consensus verification on the consensus data based on the business data in a sent state, and determine the verification result.
S203:所述第二应用将校验结果添加到所述共识数据中并存储至所述第一数据库,并将所述校验结果发送至其他共识节点继续进行共识校验。S203: The second application adds the verification result to the consensus data and stores it in the first database, and sends the verification result to other consensus nodes to continue consensus verification.
在本申请实施例中,当第二应用确定了校验结果之后,便可将校验结果存储在第一数据库中,并发送至其他共识节点继续进行共识校验。其中,第二应用存储校及发送校验数据的先后顺序本申请并不限定。In an embodiment of the present application, after the second application determines the verification result, it can store the verification result in the first database and send it to other consensus nodes to continue consensus verification. The order in which the second application stores the verification data and sends the verification data is not limited by this application.
另外,在本申请实施例步骤S201~步骤S203中,区块链的共识机制可以是实用拜占庭容错算法(Practical Byzantine Fault Tolerance,PBFT),则区块链网络中的各共识节点可以根据公式:View ID/M,确定各共识节点中的主节点,并且由主节点发起共识。针对每个共识节点,共识节点可先确定共识节点当前所处的周期(即,View),View ID表示共识节点确定的当期周期的标识。通常周期的标识为0至M-1之间的数字,M表示在区块链网络中的共识节点的总个数。In addition, in steps S201 to S203 of the embodiment of the present application, the consensus mechanism of the blockchain can be a practical Byzantine Fault Tolerance (PBFT) algorithm. Then, each consensus node in the blockchain network can determine the master node among the consensus nodes according to the formula: View ID/M, and the master node initiates the consensus. For each consensus node, the consensus node can first determine the cycle (i.e., View) in which the consensus node is currently located. The View ID represents the identifier of the current cycle determined by the consensus node. Typically, the cycle identifier is a number between 0 and M-1, where M represents the total number of consensus nodes in the blockchain network.
具体的,以第二共识节点为主节点并发起共识,第一共识节点为从节点进行共识校验为例进行说明。其中,第二共识节点中包括第三应用、第四应用以及第二数据库。第三应用根据第二数据库中已发送状态的业务数据创建预处理块,并将预处理块存储在第二数据库中。第四应用从第二数据库中捞取预处理块,并发送至除第二共识节点以外的各共识节点。Specifically, let's take the example of a second consensus node acting as the master node and initiating consensus, and the first consensus node acting as the slave node for consensus verification. The second consensus node includes a third application, a fourth application, and a second database. The third application creates pre-processed blocks based on the business data in the second database that has been sent, and stores the pre-processed blocks in the second database. The fourth application retrieves the pre-processed blocks from the second database and sends them to all consensus nodes except the second consensus node.
首先,第二共识节点的第三应用通过当前所处的View ID,可确定该第二共识节点为主节点。则第三应用可根据预先设置的共识条件,从第二数据库中捞取需要进行共识的各已发送的业务数据。其中,预设的共识条件可以是根据需求设置的,本申请对此不做具体限定。例如,按照时间顺序选择进行共识的业务数据,或者按照预处理块的容量,选择满足容量的各已发送的业务数据,等等。First, the third application of the second consensus node can determine that the second consensus node is the master node based on the current View ID. The third application can then retrieve the sent business data required for consensus from the second database based on the pre-set consensus conditions. The pre-set consensus conditions can be set based on demand and are not specifically limited in this application. For example, business data for consensus can be selected in chronological order, or the sent business data that meets the capacity of the pre-processing block can be selected based on the capacity of the pre-processing block, and so on.
其次,第三应用可根据捞取的各已发送的业务数据,创建对应的预处理块。如,确定预处理块中各已发送的业务数据的排列顺序,通过梅克尔数(Merkle trees)确定预处理块的头哈希值,等等。具体的,在本申请实施例中,预处理块的创建过程可以采用与现有技术相同的方法,本申请对此不做具体限定。Secondly, the third application can create a corresponding pre-processing block based on the retrieved sent service data. For example, it can determine the order of the sent service data in the pre-processing block, determine the header hash value of the pre-processing block using Merkle trees, and so on. Specifically, in the embodiments of the present application, the process of creating the pre-processing block can adopt the same method as the prior art, and this application does not specifically limit this.
再次,第三应用可以根据PBFT的三阶段协议中的第一阶段,采用与现有技术相同的方式,确定预处理块对应的预准备(Per-Perpared)信息,其中,Per-Perpared信息的格式可为<Per-Perpared,v,n,d>,其中v表示当前View ID的数字,n表示预处理块的标识,d为预处理块的摘要。第三应用可对Per-Perpared信息进行签名后,将Per-Perpared信息以及预处理块存储在第二数据库中。Next, the third application can determine the pre-prepared (Per-Perpared) information corresponding to the pre-processed block in the same manner as in the prior art, based on the first phase of the PBFT three-phase protocol. The format of the Per-Perpared information can be <Per-Perpared, v, n, d>, where v represents the current View ID number, n represents the identifier of the pre-processed block, and d is the digest of the pre-processed block. The third application can sign the Per-Perpared information and store it and the pre-processed block in the second database.
从次,第四应用可从数据库中捞取Per-Perpared信息以及预处理块,并发送至除第二共识节点以外的各共识节点。以使得其他共识节点对Per-Perpared信息进项校验。则如在步骤S201中所述的,第一应用可接收Per-Perpared信息以及预处理块作为共识数据,并存储在第一数据库中。Next, the fourth application can retrieve the Per-Performed information and pre-processed blocks from the database and send them to all consensus nodes except the second consensus node, so that the other consensus nodes can verify the Per-Performed information. Then, as described in step S201, the first application can receive the Per-Performed information and pre-processed blocks as consensus data and store them in the first database.
再后,如在步骤S202中所述的,第二应用可以从第一数据库中捞取共识数据(如,第二应用可以捞取Per-Perpared信息以及预处理块),并进行共识校验。具体的,第二应用可以对Per-Perpared信息的签名进行校验,确定Per-Perpared信息是由第二共识节点发送的。还根据预处理块中的业务数据,对Per-Perpared信息的摘要进行校验,确定预处理块以及Per-Perpared信息中的摘要对应。同时也可对Per-Perpared信息中的n进行判断确定是否符合预设的水位值(water mark),Per-Perpared信息中的v是否与第一共识节点当前所处的v一致。Then, as described in step S202, the second application can retrieve the consensus data from the first database (e.g., the second application can retrieve the Per-Perpared information and the pre-processed block) and perform a consensus check. Specifically, the second application can verify the signature of the Per-Perpared information to determine whether the Per-Perpared information is sent by the second consensus node. The summary of the Per-Perpared information is also verified based on the business data in the pre-processed block to determine whether the summary in the pre-processed block and the Per-Perpared information corresponds. At the same time, the n in the Per-Perpared information can also be judged to determine whether it meets the preset water mark value, and whether the v in the Per-Perpared information is consistent with the current v of the first consensus node.
由于在PBFT中确定Per-Perpared信息校验通过的共识节点,将自动执行下一阶段(即,第二阶段),所以当第二应用对Per-Perpared信息校验通过后可以将Per-Perpared信息、预处理块以及接收到的响应信息,存储在第一数据库中,并创建准备信息(Perpared信息)作为校验结果。Perpared信息的格式可为<Perpared,v,n,d,i>,其中i为创建Perpared信息的共识节点的标识。于是,第二应用还可将Perpared信息也存储在第一数据库中。Since the consensus node that has passed the Per-Perpared information verification in PBFT will automatically execute the next stage (i.e., the second stage), after the second application verifies the Per-Perpared information, it can store the Per-Perpared information, preprocessing blocks, and received response information in the first database and create preparation information (Perpared information) as the verification result. The format of the Perpared information can be <Perpared, v, n, d, i>, where i is the identifier of the consensus node that created the Perpared information. Therefore, the second application can also store the Perpared information in the first database.
然后,第二应用可将Perpared信息发送至其他共识节点继续进行共识校验。并且,其他通过对Per-Perpared信息校验的共识节点也可将自身创建的Perpared信息签名后进行广播。于是,在区块链网络中的各共识节点,均可接收到通过对Per-Perpared信息校验的共识节点发送的Perpared信息,并且,针对每个共识节点,该共识节点可将接收到的其他共识节点发送的Perpared信息存储在自身的数据库中。The second application can then send the Perpared information to other consensus nodes for further consensus verification. Furthermore, other consensus nodes that have verified the Per-Perpared information can also sign their own Perpared information and broadcast it. Thus, each consensus node in the blockchain network can receive the Perpared information sent by the consensus node that has verified the Per-Perpared information, and each consensus node can store the Perpared information received from other consensus nodes in its own database.
于是,在本申请实施例中,第一共识节点的第一应用可再次接收其他共识节点发送的校验结果(即,其他共识节点发送的Perpared信息),并存储在第一数据库中。第二应用可对第一数据库中存储的各Perpared信息的v、n、签名以及摘要进行校验。当第二应用判断第一数据库中存储的通过校验的各Perpared信息的数量大于等于预设的数量时,自动执行下一阶段(即,第三阶段)。其中,预设的数量与现有技术相同,为共识节点通过PBFT计算确定的,本申请不再赘述。Therefore, in an embodiment of the present application, the first application of the first consensus node can again receive the verification results sent by other consensus nodes (i.e., the Perpared information sent by other consensus nodes) and store them in the first database. The second application can verify the v, n, signature, and summary of each Perpared information stored in the first database. When the second application determines that the number of verified Perpared information stored in the first database is greater than or equal to the preset number, the next stage (i.e., the third stage) is automatically executed. Among them, the preset number is the same as the prior art, and is determined by the consensus node through PBFT calculation, and this application will not go into details.
之后,在三阶段协议的第三阶段,当第二应用确定进行第三阶段时,可创建确认信息(Commit信息),并向其他共识节点发送Commit信息。同理,第二共识节点的第三或者第四应用,在确定进行第三阶段时,也可发送Commit信息。第一应用可接收其他共识节点发送的Commit信息并存储在第一数据库中。其中,Commit信息格式可为<Commit,v,n,D,i>,其中D为共识节点创建的预处理块的摘要。Later, in the third phase of the three-phase protocol, when the second application determines to proceed to the third phase, it can create a confirmation message (Commit message) and send the Commit message to the other consensus nodes. Similarly, the third or fourth application of the second consensus node can also send a Commit message when it determines to proceed to the third phase. The first application can receive the Commit messages sent by other consensus nodes and store them in the first database. The Commit message format can be <Commit, v, n, D, i>, where D is the summary of the preprocessing block created by the consensus node.
最后,第二应用可对第一数据库中存储的其他共识节点发送的Commit信息的v、n、签名以及摘要进行校验,当确定通过校验的Commit信息大于等于预设的数量时,确定预处理块通过共识校验。Finally, the second application can verify the v, n, signature and summary of the Commit information sent by other consensus nodes stored in the first database. When it is determined that the number of Commit information that passes the verification is greater than or equal to the preset number, it is determined that the preprocessing block has passed the consensus verification.
其中,针对区块链网络中的每个共识节点,该共识节点在三阶段协议的每个阶段中,在接收到其他共识节点的信息、创建信息等进行共识校验时产生的数据,均可存储在该共识节点对应的数据库中。Among them, for each consensus node in the blockchain network, the data generated by the consensus node when receiving information from other consensus nodes, creating information, etc. for consensus verification in each stage of the three-stage protocol can be stored in the database corresponding to the consensus node.
当然,需要说明的是本申请实施例中,上述由第二应用执行的步骤均可以由第一应用执行,反之亦然。同理,由该第三应用执行的步骤也均可由第四应用执行,反之亦然。Of course, it should be noted that in the embodiment of the present application, the steps performed by the second application can be performed by the first application, and vice versa. Similarly, the steps performed by the third application can be performed by the fourth application, and vice versa.
另外,针对每个共识节点,由于在三阶段协议执行过程中,各共识节点都需要发送和接收其他共识节点的信息,而信息在通过网络传输时,可能出现网络延时,所以在三阶段协议的每个阶段,各共识节点都可等待一段时间以接收信息。于是,在执行三阶段协议过程中,共识节点可将创建的以及接收的信息先存储在数据库中。并在每个阶段的等待时间结束时,再根据数据库中存储的信息,确定是否进行下一阶段。Furthermore, each consensus node needs to send and receive information from other consensus nodes during the three-phase protocol. This information may be subject to network delays when transmitted over the network. Therefore, each consensus node can wait for a period of time during each phase of the three-phase protocol to receive information. Therefore, during the three-phase protocol, consensus nodes can store the information they create and receive in a database. At the end of each phase's waiting period, they determine whether to proceed to the next phase based on the information stored in the database.
进一步地,在本申请实施例中,在三阶段协议的第一阶段(也就是Per-Perpared的阶段),发起共识的第二共识节点(即,主节点)可将预处理块,以及预处理块中各业务数据的哈希值一并发送至出第二共识节点的各共识节点,而接收到Per-Perpared信息的各共识节点,可以根据各业务数据的哈希值,创建一个预处理块,并与主节点发送的预处理块进行对比校验。Furthermore, in an embodiment of the present application, in the first stage of the three-stage protocol (that is, the Per-Perpared stage), the second consensus node (that is, the master node) that initiates the consensus can send the pre-processed block and the hash value of each business data in the pre-processed block to each consensus node out of the second consensus node. Each consensus node that receives the Per-Perpared information can create a pre-processed block based on the hash value of each business data, and compare and verify it with the pre-processed block sent by the master node.
更进一步地,在本申请实施例中,针对每个共识节点,该共识节点在进行共识校验时,与现有技术一致各共识节点还可以根据共识条件,以及共识节点进行校验,即,判断是否主节点发送各业务数据是可进行共识校验的业务数据,若是,则继续后续共识校验,若否,则停止共识校验。Furthermore, in an embodiment of the present application, for each consensus node, when performing consensus verification, the consensus node can also perform verification based on the consensus conditions and the consensus node, consistent with the prior art, that is, determine whether the business data sent by the master node is business data that can be consensus verified. If so, continue with the subsequent consensus verification; if not, stop the consensus verification.
基于图2所示的区块链业务共识方法,第一共识节点中包括第一应用、第二应用以及第一数据库,在进行共识时,第一应用接收共识数据,并存储在第一数据库中,第二应用从第一数据库中捞取共识数据,进行共识校验,第二应用将校验结果添加到共识数据中并存储至第一数据库,并将校验结果发送至其他共识节点继续进行共识校验。其中,发起共识的第二共识节点的第三应用根据第二数据库中存储的已发送的业务数据,创建预处理块作为共识数据存储在第二数据中,第四应用从第二数据库中捞取共识数据并发送至出第二共识节点以外的各共识节点。可见,由于在本申请实施例中,共识节点可以采用PBFT的三阶段协议进行共识,并且将每一阶段产生的数据存储在数据库中,减少共识校验时对缓存占用率,提高缓存利用率。从而提高了共识节点进行共识校验以及对业务请求进行处理的效率。Based on the blockchain business consensus method shown in Figure 2, the first consensus node includes a first application, a second application, and a first database. When consensus is performed, the first application receives the consensus data and stores it in the first database. The second application retrieves the consensus data from the first database and performs consensus verification. The second application adds the verification result to the consensus data and stores it in the first database, and sends the verification result to other consensus nodes to continue consensus verification. Among them, the third application of the second consensus node that initiates consensus creates a pre-processing block based on the sent business data stored in the second database and stores it in the second data as consensus data. The fourth application retrieves the consensus data from the second database and sends it to each consensus node other than the second consensus node. It can be seen that since the consensus node can use the PBFT three-stage protocol to reach consensus in the embodiment of the present application, and stores the data generated in each stage in the database, the cache occupancy rate during consensus verification is reduced and the cache utilization rate is improved. This improves the efficiency of the consensus node in performing consensus verification and processing business requests.
需要说明的是,本申请实施例所提供方法的各步骤的执行主体均可以是同一设备,或者,该方法也由不同设备作为执行主体。比如,步骤S201和步骤S202的执行主体可以为设备1,步骤S203的执行主体可以为设备2;又比如,步骤S201的执行主体可以为设备1,步骤S202和步骤S203的执行主体可以为设备2;等等。It should be noted that the execution entity of each step of the method provided in the embodiments of the present application can be the same device, or the method can be executed by different devices. For example, the execution entity of steps S201 and S202 can be device 1, and the execution entity of step S203 can be device 2; for another example, the execution entity of step S201 can be device 1, and the execution entity of steps S202 and S203 can be device 2; and so on.
基于图1所示区块链业务受理方法,本申请实施例还对应提供一种区块链业务受理装置,如图3所示。Based on the blockchain business acceptance method shown in Figure 1, the embodiment of the present application also provides a blockchain business acceptance device, as shown in Figure 3.
图3为本申请实施例提供的一种区块链业务受理装置的结构示意图,共识节点中包括所述装置,第二应用以及数据库,所述装置包括:FIG3 is a schematic diagram of the structure of a blockchain business acceptance device provided in an embodiment of the present application. The consensus node includes the device, a second application, and a database. The device includes:
接收模块301,接收客户端发送的业务请求,并根据该业务请求确定对应的待发送的业务数据;The receiving module 301 receives a service request sent by a client and determines corresponding service data to be sent according to the service request;
存储模块302,将所述待发送的业务数据存储在所述数据库中;The storage module 302 stores the service data to be sent in the database;
当满足预设条件时,所述第二应用或者发送模块303,从所述数据库中捞取待发送的业务数据发送至其他共识节点存储。When the preset conditions are met, the second application or sending module 303 retrieves the business data to be sent from the database and sends it to other consensus nodes for storage.
所述存储模块302,确定所述待发送的业务数据的状态为待发送状态,将所述业务数据及其对应的待发送状态存储在所述存储模块中。The storage module 302 determines that the status of the to-be-sent service data is a to-be-sent status, and stores the service data and its corresponding to-be-sent status in the storage module.
当指定时刻到达时,确定满足预设的条件。When the specified time arrives, it is determined that the preset conditions are met.
所述发送模块303,从所述数据库中捞取指定数量的待发送的业务数据。The sending module 303 retrieves a specified amount of business data to be sent from the database.
所述装置还包括:The device further comprises:
更新模块304,将所述数据库中已发送的业务数据的状态更新为已发送状态。The updating module 304 updates the status of the sent service data in the database to a sent status.
具体的,该区块链业务受理装置可位于共识节点中,该共识节点可以是终端。如,手机、平板电脑、个人电脑等设备。或者,该共识节点也可以是服务器。如,单独一台服务器,或者由多台服务器组成的系统。Specifically, the blockchain business acceptance device can be located in a consensus node, which can be a terminal, such as a mobile phone, tablet computer, personal computer, or other device. Alternatively, the consensus node can be a server, such as a single server or a system consisting of multiple servers.
基于图2所示区块链业务共识方法,本申请实施例还对应提供一种区块链业务共识装置,如图4所示。Based on the blockchain business consensus method shown in Figure 2, the embodiment of the present application also provides a blockchain business consensus device, as shown in Figure 4.
图4为本申请实施例提供的一种区块链业务共识装置的结构示意图,第一共识节点中包括第一应用、所述装置以及第一数据库,所述装置包括:FIG4 is a schematic diagram of the structure of a blockchain business consensus device provided in an embodiment of the present application. The first consensus node includes a first application, the device, and a first database. The device includes:
接收模块401,接收共识数据,并存储在所述第一数据库中;Receiving module 401 receives consensus data and stores it in the first database;
校验模块402,从所述第一数据库中捞取所述共识数据,进行共识校验;Verification module 402 retrieves the consensus data from the first database and performs consensus verification;
存储发送模块403,将校验结果添加到所述共识数据中并存储至所述第一数据库,并将所述校验结果发送至其他共识节点继续进行共识校验。The storage and sending module 403 adds the verification result to the consensus data and stores it in the first database, and sends the verification result to other consensus nodes to continue consensus verification.
所述接收模块401,接收其他共识节点发送的共识数据,或者,接收其他共识节点发送的校验结果,作为共识数据。The receiving module 401 receives consensus data sent by other consensus nodes, or receives verification results sent by other consensus nodes as consensus data.
所述校验模块402,从所述第一数据库中捞取所述共识数据以及所述第一数据库中已发送状态的业务数据,根据所述已发送状态的业务数据对所述共识数据进行共识校验,并确定校验结果。The verification module 402 retrieves the consensus data and the business data in the sent state in the first database from the first database, performs consensus verification on the consensus data according to the business data in the sent state, and determines a verification result.
第二共识节点中包括第三应用、第四应用以及第二数据库,所述接收模块401接收共识数据之前,所述第三应用根据所述第二数据库中已发送状态的业务数据,确定共识数据,并存储在所述第二数据库中,所述第四应用从所述第二数据库中捞取所述共识数据,并发送至除所述第二共识节点以外的各共识节点。The second consensus node includes a third application, a fourth application and a second database. Before the receiving module 401 receives the consensus data, the third application determines the consensus data based on the business data in the sent state in the second database and stores it in the second database. The fourth application retrieves the consensus data from the second database and sends it to each consensus node except the second consensus node.
所述共识校验采用拜占庭容错算法PBFT。The consensus verification adopts the Byzantine Fault Tolerance algorithm PBFT.
具体的,如图4所示的一种区块链业务受理装置可位于共识节点中,该共识节点可以是终端。如,手机、平板电脑、个人电脑等设备。或者,该共识节点也可以是服务器。如,单独一台服务器,或者由多台服务器组成的系统。Specifically, a blockchain business acceptance device as shown in FIG4 may be located in a consensus node, which may be a terminal, such as a mobile phone, tablet computer, or personal computer. Alternatively, the consensus node may be a server, such as a single server or a system consisting of multiple servers.
在20世纪90年代,对于一个技术的改进可以很明显地区分是硬件上的改进(例如,对二极管、晶体管、开关等电路结构的改进)还是软件上的改进(对于方法流程的改进)。然而,随着技术的发展,当今的很多方法流程的改进已经可以视为硬件电路结构的直接改进。设计人员几乎都通过将改进的方法流程编程到硬件电路中来得到相应的硬件电路结构。因此,不能说一个方法流程的改进就不能用硬件实体模块来实现。例如,可编程逻辑器件(Programmable Logic Device,PLD)(例如现场可编程门阵列(Field Programmable GateArray,FPGA))就是这样一种集成电路,其逻辑功能由用户对器件编程来确定。由设计人员自行编程来把一个数字系统“集成”在一片PLD上,而不需要请芯片制造厂商来设计和制作专用的集成电路芯片。而且,如今,取代手工地制作集成电路芯片,这种编程也多半改用“逻辑编译器(logic compiler)”软件来实现,它与程序开发撰写时所用的软件编译器相类似,而要编译之前的原始代码也得用特定的编程语言来撰写,此称之为硬件描述语言(Hardware Description Language,HDL),而HDL也并非仅有一种,而是有许多种,如ABEL(Advanced Boolean Expression Language)、AHDL(Altera Hardware DescriptionLanguage)、Confluence、CUPL(Cornell University Programming Language)、HDCal、JHDL(Java Hardware Description Language)、Lava、Lola、MyHDL、PALASM、RHDL(RubyHardware Description Language)等,目前最普遍使用的是VHDL(Very-High-SpeedIntegrated Circuit Hardware Description Language)与Verilog。本领域技术人员也应该清楚,只需要将方法流程用上述几种硬件描述语言稍作逻辑编程并编程到集成电路中,就可以很容易得到实现该逻辑方法流程的硬件电路。In the 1990s, technological improvements could be clearly distinguished as either hardware improvements (for example, improvements to circuit structures like diodes, transistors, and switches) or software improvements (improvements to process flows). However, with the advancement of technology, many process flow improvements today can now be considered direct improvements to hardware circuit structures. Designers almost always create the corresponding hardware circuit structure by programming the improved process flow into the hardware circuit. Therefore, it cannot be said that a process flow improvement cannot be implemented using hardware modules. For example, a programmable logic device (PLD), such as a field programmable gate array (FPGA), is an integrated circuit whose logical function is determined by user programming. Designers can "integrate" a digital system on a PLD through their own programming, without having to hire a chip manufacturer to design and manufacture a dedicated integrated circuit chip. Moreover, nowadays, instead of manually fabricating integrated circuit chips, this programming is mostly done using "logic compiler" software. This is similar to the software compiler used when developing programs. Before compilation, the original code must also be written in a specific programming language, called a hardware description language (HDL). There is not just one HDL, but many, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art will also understand that by simply programming the method flow in one of these hardware description languages and then programming it into an integrated circuit, a hardware circuit that implements the logic method flow can be easily obtained.
控制器可以按任何适当的方式实现,例如,控制器可以采取例如微处理器或处理器以及存储可由该(微)处理器执行的计算机可读程序代码(例如软件或固件)的计算机可读介质、逻辑门、开关、专用集成电路(Application Specific Integrated Circuit,ASIC)、可编程逻辑控制器和嵌入微控制器的形式,控制器的例子包括但不限于以下微控制器:ARC 625D、Atmel AT91SAM、Microchip PIC18F26K20以及Silicone Labs C8051F320,存储器控制器还可以被实现为存储器的控制逻辑的一部分。本领域技术人员也知道,除了以纯计算机可读程序代码方式实现控制器以外,完全可以通过将方法步骤进行逻辑编程来使得控制器以逻辑门、开关、专用集成电路、可编程逻辑控制器和嵌入微控制器等的形式来实现相同功能。因此这种控制器可以被认为是一种硬件部件,而对其内包括的用于实现各种功能的装置也可以视为硬件部件内的结构。或者甚至,可以将用于实现各种功能的装置视为既可以是实现方法的软件模块又可以是硬件部件内的结构。The controller can be implemented in any suitable manner. For example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also know that in addition to implementing the controller in a purely computer-readable program code format, the controller can be implemented in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers by logically programming the method steps. Therefore, such a controller can be considered a hardware component, and the devices included therein for implementing various functions can also be considered as structures within the hardware component. Or even, the devices for implementing various functions can be considered as both software modules that implement the method and structures within the hardware component.
上述实施例阐明的系统、装置、模块或单元,具体可以由计算机芯片或实体实现,或者由具有某种功能的产品来实现。一种典型的实现设备为计算机。具体的,计算机例如可以为个人计算机、膝上型计算机、蜂窝电话、相机电话、智能电话、个人数字助理、媒体播放器、导航设备、电子邮件设备、游戏控制台、平板计算机、可穿戴设备或者这些设备中的任何设备的组合。The systems, devices, modules, or units described in the above embodiments may be implemented by computer chips or entities, or by products having certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
为了描述的方便,描述以上装置时以功能分为各种单元分别描述。当然,在实施本申请时可以把各单元的功能在同一个或多个软件和/或硬件中实现。For the convenience of description, the above devices are described as being divided into various units according to their functions. Of course, when implementing this application, the functions of each unit can be implemented in the same or multiple software and/or hardware.
本领域内的技术人员应明白,本发明的实施例可提供为方法、系统、或计算机程序产品。因此,本发明可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。It will be understood by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present invention is described with reference to the flowcharts and/or block diagrams of the methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and/or box in the flowchart and/or block diagram, as well as the combination of processes and/or boxes in the flowchart and/or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device for implementing the functions specified in one or more processes in the flowchart and/or one or more boxes in the block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction device that implements the functions specified in one or more processes in the flowchart and/or one or more boxes in the block diagram.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and/or one or more boxes in the block diagram.
在一个典型的配置中,计算设备包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
内存可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。内存是计算机可读介质的示例。Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and/or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media (transitory media), such as modulated data signals and carrier waves.
还需要说明的是,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、商品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、商品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、商品或者设备中还存在另外的相同要素。It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.
本领域技术人员应明白,本申请的实施例可提供为方法、系统或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
本申请可以在由计算机执行的计算机可执行指令的一般上下文中描述,例如程序模块。一般地,程序模块包括执行特定任务或实现特定抽象数据类型的例程、程序、对象、组件、数据结构等等。也可以在分布式计算环境中实践本申请,在这些分布式计算环境中,由通过通信网络而被连接的远程处理设备来执行任务。在分布式计算环境中,程序模块可以位于包括存储设备在内的本地和远程计算机存储介质中。The present application may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communications network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于系统实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。The various embodiments in this specification are described in a progressive manner. Similar parts between the various embodiments can be referred to in conjunction with each other. Each embodiment focuses on the differences between the other embodiments. In particular, the system embodiments are generally similar to the method embodiments, so the description is relatively simple. For relevant parts, refer to the description of the method embodiments.
以上所述仅为本申请的实施例而已,并不用于限制本申请。对于本领域技术人员来说,本申请可以有各种更改和变化。凡在本申请的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在本申请的权利要求范围之内。The foregoing is merely an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should all be included within the scope of the claims of the present application.
| Application Number | Priority Date | Filing Date | Title | 
|---|---|---|---|
| HK18106451.9AHK1247457B (en) | 2018-05-17 | Block chain service acceptance and consensus methods and devices | 
| Application Number | Priority Date | Filing Date | Title | 
|---|---|---|---|
| HK18106451.9AHK1247457B (en) | 2018-05-17 | Block chain service acceptance and consensus methods and devices | 
| Publication Number | Publication Date | 
|---|---|
| HK1247457A1 HK1247457A1 (en) | 2018-09-21 | 
| HK1247457Btrue HK1247457B (en) | 2021-03-26 | 
| Publication | Publication Date | Title | 
|---|---|---|
| TWI679547B (en) | Block chain business acceptance and business consensus method and device | |
| TWI752118B (en) | A blockchain consensus method and device | |
| CN107040585B (en) | Service checking method and device | |
| CN107196989B (en) | A service request processing method and device | |
| TW201904229A (en) | Blockchain data processing method and apparatus including an acquiring module and a processing module to increase validation processing for technical business | |
| CN111327703A (en) | A consensus method and device based on blockchain | |
| CN112087530B (en) | Method, device, equipment and medium for uploading data to block chain system | |
| CN111796864A (en) | Data verification method and device | |
| CN115129728A (en) | A method and device for document verification | |
| CN117743472B (en) | A storage task breakpoint synchronization method, device, medium and equipment | |
| CN117407124B (en) | Service execution method based on constructed data arrangement strategy generation model | |
| CN117555697A (en) | A cache loading system, method, device and equipment for distributed training | |
| HK1247457B (en) | Block chain service acceptance and consensus methods and devices | |
| CN117193670B (en) | A method, device, storage medium and electronic device for clearing cache | |
| HK1247457A1 (en) | Block chain service acceptance and consensus methods and devices | |
| HK1247357B (en) | Block chain consensus method and device | |
| HK1247300B (en) | Data processing method and equipment based on blockchain | |
| HK1247325B (en) | Data processing method and device | |
| HK1247301B (en) | Data processing method and equipment based on blockchain | |
| HK1247717B (en) | Method and device for sending electronic coupons | |
| HK1247359B (en) | Block chain consensus method and device | |
| HK1248378B (en) | Service publishing method and device, and equipment | |
| HK1244601B (en) | Method and device for broadcasting message | |
| HK1241594B (en) | Service check method and device | |
| HK1261859B (en) | Communication data recovery method, device and equipment |