Blockchain service acceptance and consensus method and devices
This specification describes techniques for handling a blockchain service. A service request sent by a client is received by a first application of a first consensus node of a blockchain network, where the first consensus node includes the first application, a second application, and a database. To-be-sent service data is determined based on the service request. The to-be-sent service data is stored in the database by the first application. A determination is made as to whether a predetermined condition is satisfied. If it is determined that the predetermined condition is satisfied, the to-be-sent service data is retrieved from the database by the first application or the second application. The to-be-sent service data is transmitted to a second consensus node of the blockchain network.
1. A computer-implemented method for handling a blockchain service, comprising:
receiving, by a first application of a first consensus node of a blockchain network, a service request sent by a client, wherein the first consensus node comprises the first application, a second application, and a database;
determining to-be-sent service data based on the service request;
storing, by the first application, the to-be-sent service data in the database;
determining based on an identifier of the to-be-sent service data that the to-be-sent service data satisfies a predetermined condition that changes with time changes and service volume changes, wherein the predetermined condition defines a data volume corresponding to the first consensus node to be retrieved within a time interval, and wherein the predetermined condition comprises an increase of the time interval for retrieving the data volume during nighttime;
in response to determining that the predetermined condition is satisfied, retrieving, by the first application or the second application, the to-be-sent service data from the database; and
transmitting the to-be-sent service data to a second consensus node of the blockchain network.
2. The computer-implemented method of claim 1 , further comprising:
prior to storing the to-be-sent service data:
determining, by the first application, a state associated with the to-be-sent service data is a to-be-sent state; and
storing the to-be-sent service data and the to-be-sent state associated with the to-be-sent service data in the database.
3. The computer-implemented method of claim 1 , wherein the predetermined condition defines a first data volume to be retrieved within a first time interval during nighttime and a second data volume to be retrieved within a second time interval during daytime, the first data volume being larger than the second data volume.
4. The computer-implemented method of claim 1 , wherein retrieving the to-be-sent service data from the database comprises retrieving a specified amount of the to-be-sent service data from the database.
5. The computer-implemented method of claim 1 , further comprising:
updating a state associated with the to-be-sent service data to a sent state.
6. A computer-implemented method for performing a consensus process in a blockchain network, comprising:
receiving, by a first application of a first consensus node of the blockchain network, consensus data, wherein the first consensus node includes the first application, a second application, and a first database;
storing, by the first application, the consensus data in the first database;
retrieving, by the second application from the first database, the consensus data;
performing, by the second application, a consensus verification based on the consensus data;
generating, by the second application, a verification result of the consensus verification based on the consensus data;
adding, by the second application, the verification result into the consensus data;
storing, by the second application, the consensus data that includes the verification result in the first database;
determining based on an identifier of the consensus data that the consensus data satisfies a predetermined condition that changes with time changes and service volume changes, wherein the predetermined condition defines a data volume corresponding to the first consensus node to be retrieved within a time interval, and wherein the predetermined condition comprises an increase of the time interval for retrieving the data volume during nighttime;
in response to determining that the predetermined condition is satisfied, retrieving, by the first application or the second application, the consensus data from the database; and
sending, by the second application, the consensus data to a second consensus node.
7. The computer-implemented method of claim 6 , wherein receiving, by the first application of the first consensus node of the blockchain network, the consensus data comprises:
receiving, by the first application of the first consensus node of the blockchain network, the consensus data from the second consensus node of the blockchain network; or
receiving, by the first application of the first consensus node of the blockchain network, the verification result from a third consensus node of the blockchain network as the consensus data.
8. The computer-implemented method of claim 6 , wherein retrieving, by the second application from the first database, the consensus data comprises:
retrieving, by the second application from the first database, the consensus data and service data that has a sent state;
performing, by the second application, a consensus verification based on the service data that has the sent state; and
generating the verification result of the consensus verification based on the service data that has the sent state.
9. The computer-implemented method of claim 8 , wherein the second consensus node includes a third application, a fourth application, and a second database, prior to receiving, by the first application of the first consensus node of the blockchain network, the method comprising:
identifying, by the third application, the consensus data based on the service data that has the sent state;
storing, by the third application, the consensus data in the second database;
retrieving, by the fourth application from the second database, the consensus data; and
sending, by the fourth application, the consensus data to consensus nodes of the blockchain network other than the second consensus node.
10. The computer-implemented method of claim 6 , wherein performing, by the second application, a consensus verification based on the consensus data comprises performing, by the second application, the consensus verification based on the consensus data using a Practical Byzantine Fault Tolerance (PBFT) algorithm.
11. A non-transitory, computer-readable medium storing one or more instructions executable by a computer system to perform operations comprising:
receiving, by a first application of a first consensus node of a blockchain network, a service request sent by a client, wherein the first consensus node includes the first application, a second application, and a database;
determining to-be-sent service data based on the service request;
storing, by the first application, the to-be-sent service data in the database;
determining based on an identifier of the to-be-sent service data that the to-be-sent service data satisfies a predetermined condition that changes with time changes and service volume changes, wherein the predetermined condition defines a data volume corresponding to the first consensus node to be retrieved within a time interval, and wherein the predetermined condition comprises an increase of the time interval for retrieving the data volume during nighttime;
in response to determining that the predetermined condition is satisfied, retrieving, by the first application or the second application, the to-be-sent service data from the database; and
transmitting the to-be-sent service data to a second consensus node of the blockchain network.
12. The non-transitory, computer-readable medium of claim 11 , the operations further comprising:
prior to storing the to-be-sent service data:
determining, by the first application, a state associated with the to-be-sent service data is a to-be-sent state; and
storing the to-be-sent service data and the to-be-sent state associated with the to-be-sent service data in the database.
13. The non-transitory, computer-readable medium of claim 11 , wherein the predetermined condition defines a first data volume to be retrieved within a first time interval during nighttime and a second data volume to be retrieved within a second time interval during daytime, the first data volume being larger than the second data volume.
14. The non-transitory, computer-readable medium of claim 11 , wherein retrieving the to-be-sent service data from the database comprises retrieving a specified amount of the to-be-sent service data from the database.
15. The non-transitory, computer-readable medium of claim 11 , the operations further comprising:
updating a state associated with the to-be-sent service data to a sent state.
16. A computer-implemented system, comprising:
one or more computers; and
one or more computer memory devices interoperably coupled with the one or more computers and having tangible, non-transitory, machine-readable media storing one or more instructions that, when executed by the one or more computers, perform one or more operations comprising:
receiving, by a first application of a first consensus node of a blockchain network, a service request sent by a client, wherein the first consensus node includes the first application, a second application, and a database;
determining to-be-sent service data based on the service request;
storing, by the first application, the to-be-sent service data in the database;
determining based on an identifier of the to-be-sent service data that the to-be-sent service data satisfies a predetermined condition that changes with time changes and service volume changes, wherein the predetermined condition defines a data volume corresponding to the consensus node to be retrieved within a time interval, and wherein the predetermined condition comprises an increase of the time interval for retrieving the data volume during nighttime;
in response to determining that the predetermined condition is satisfied, retrieving, by the first application or the second application, the to-be-sent service data from the database; and
transmitting the to-be-sent service data to a second consensus node of the blockchain network.
17. The computer-implemented system of claim 16 , the one or more operations further comprising:
prior to storing the to-be-sent service data:
determining, by the first application, a state associated with the to-be-sent service data is a to-be-sent state; and
storing the to-be-sent service data and the to-be-sent state associated with the to-be-sent service data in the database.
18. The computer-implemented system of claim 16 , wherein determining whether the predetermined condition is satisfied comprises determining whether the predetermined condition is satisfied when a time condition is satisfied.
19. The computer-implemented system of claim 16 , wherein retrieving the to-be-sent service data from the database comprises retrieving a specified amount of the to-be-sent service data from the database.
20. The computer-implemented system of claim 16 , the one or more operations further comprising:
updating a state associated with the to-be-sent service data to a sent state.