Disclosure of Invention
In order to overcome the defects in the prior art, an autonomous protocol implementation method for calling a rear-end block chain by a front-end application is provided so as to solve the problem that products such as digital collections are developed by internet applications such as mobile phone APP and the like, the performance bottleneck between the ultrahigh concurrency of the front-end oversized users and the rear-end block chain is encountered, and the problem of unsynchronized performance is solved.
The method comprises a digital collection module, wherein the digital collection module comprises a digital collection operation protocol and a digital collection scheduling engine, the digital collection operation protocol defines a processing protocol for various operations of digital collections, the processing protocol is used for user registration, collection issue, digital certificate transfer, digital certificates and various query operations, the digital collection operation protocol can summarize and encapsulate various operations of digital collections to form operation instructions, the digital collection scheduling engine is used for scheduling and executing the operations, the digital collection scheduling engine encapsulates the operation instructions according to a DCOP protocol and puts the operation instructions into a task queue after receiving the operation requests from applications, the digital collection scheduling engine analyzes the operation requests and calls a block chain interface to execute the operations according to the instructions in the scheduling policy execution queue, the results of the block chain are obtained, the results are processed, a task state is updated, and a source application is notified, the digital collection module is further connected with a network, the front-end application encapsulates the work item operation instructions according to the digital collection operation protocol, and transmits work item operation data to a digital collection scheduling engine through a data scheduling sheet.
Preferably, the digital Tibetan scheduling engine operates according to the following mechanism, and after receiving the work order, the digital Tibetan scheduling engine adds the work order into the task queue and synchronously returns a receipt to the front-end application;
a scheduling engine of the digital collection scheduling engine monitors a task queue, takes out an operation work order from the queue, analyzes an operation instruction and calls a corresponding interface of a block chain according to the type of the instruction for processing;
an instruction of a result is returned to the block chain in real time, after a synchronous result is obtained, the task state is immediately updated, and after the result is packaged according to DCOP, the result is fed back to the front-end application through an asynchronous notification interface of the application end;
and (4) asynchronously returning a result instruction to the block chain, updating the task state after a synchronous result is obtained, and feeding back a processing result to the application end through an asynchronous notification interface of the application end.
Preferably, the sub-tasks are automatically generated while the synchronous result is obtained for the instruction of asynchronously returning the result to the block chain, and the block chain asynchronous execution result is inquired, and after the asynchronous execution result is obtained, the final result is notified to the application end again.
Preferably, the operation layer composed of the digital collection operation protocol and the digital collection scheduling engine is located between the front-end application and the blockchain and used for linking the front-end application and the blockchain, the operation layer supports multiple front-end applications, and the operation layer is connected with multiple blockchain systems in an interfacing manner;
the block chain end has asynchronous operation, and the block chain end adopts an asynchronous mode, returns an instruction number of the operation, and inquires the progress and the return result of the operation according to the instruction number.
Preferably, the asynchronous operation generates the query task by automatically creating the subtask to obtain the result of the asynchronous operation.
Preferably, the block chain operation scenario includes two types, namely a query type and an execution type, wherein the query type includes user collection query, digital voucher query and voucher detail query;
the execution class comprises user registration, collection issuing, certificate transferring and certificate destroying.
Preferably, for executing the class operation, the blockchain itself may adopt an asynchronous mode, and after the operation, the result is not directly returned, but the number of the asynchronous request is returned, and the execution result of the blockchain operation is queried through the number.
Preferably, the digital collection scheduling engine adopts a memory queue, and in terms of implementation, a database is adopted to store tasks according to the requirements of performance, compatibility and development difficulty.
Preferably, when the block chain is docked, a plurality of different block chain platforms are docked through adaptive operations of interfaces and logics.
The invention has the beneficial effects that:
1. the method designs a set of instruction protocol, encapsulates related operations of the digital collection, appoints corresponding data transmission specifications such as parameters and formats, and asynchronously interfaces the block chain interface through the task scheduling engine, thereby solving the contradiction between the front-end high-concurrency application and the back-end block chain performance bottleneck and realizing the on-line of the block chain digital collection product on the front-end APP.
2. According to the method, a self-defined protocol, namely a digital collection operation protocol DCOP is designed, so that both upstream and downstream cooperation parties or multiple parties can directly develop the protocols based on protocol specifications, joint debugging test can be carried out after the development is finished, the phenomena that the two parties are communicated continuously, discuss running-in and are inconsistent when the multiple parties are in butt joint are avoided, and the development efficiency is improved.
Detailed Description
The embodiments of the present invention are described below with reference to specific embodiments, and other advantages and effects of the present invention will be easily understood by those skilled in the art from the disclosure of the present specification. The invention is capable of other and different embodiments and of being practiced or of being carried out in various ways, and its several details are capable of modification in various respects, all without departing from the spirit and scope of the present invention.
Referring to fig. 1-3, the method for implementing the autonomous protocol for calling the back-end block chain by the front-end application comprises a digital collection module, wherein the digital collection module comprises two parts, namely a digital collection operation protocol and a digital collection scheduling engine, the Digital Collection Operation Protocol (DCOP) defines a processing protocol for various operations of the digital collection, such as user registration, collection issue, digital certificate transfer, digital certificate destruction and various query operations, according to the definition, various operations of the digital collection can be summarized and encapsulated to form an operation instruction, and the operation instruction is scheduled and executed by the Digital Collection Scheduling Engine (DCSE).
The Digital Collection Scheduling Engine (DCSE) is a task type scheduling processing mechanism, after receiving an operation request from an application, an operation instruction is packaged according to a DCOP protocol and is put into a task queue, the engine executes the instruction in the queue according to a scheduling strategy, analyzes and calls a block chain interface to execute operation, after a synchronous response result or an asynchronous notification result of a block chain is obtained, the result is processed, the task state is updated and the source application is notified, the digital collection module is further connected with a front-end application through a network, the front-end application packages the data collection operation instruction into an operation work order according to the digital collection operation protocol, and the work order is sent to the digital collection scheduling engine through the interface.
In a preferred embodiment, the front-end Application (APP) encapsulates the data collection operation instructions into an operation work ORDER (ORDER) according to the Digital Collection Operation Protocol (DCOP), and sends the work ORDER to the Digital Collection Scheduling Engine (DCSE) through the interface.
After receiving the work order, the DCSE adds the work order into the task queue and synchronously returns a receipt to the front-end application.
And a scheduling engine of the DCSE monitors the task queue, takes out the operation work order from the queue, analyzes the operation instruction, and calls a corresponding interface of the block chain according to the instruction type for processing.
And returning a result instruction to the block chain in real time, immediately updating the task state after a synchronous result is obtained, and simultaneously feeding back the result to the front-end application through an asynchronous notification interface of the application end after the result is packaged according to DCOP.
And asynchronously returning a result instruction to the block chain, updating the task state after obtaining a synchronous result, and feeding back a processing result to the application end through an asynchronous notification interface of the application end. And meanwhile, automatically generating subtasks (recording the serial numbers of the preposed tasks in the subtasks), inquiring asynchronous execution results of the block chains, and notifying the final results to the application end again after the asynchronous execution results are obtained.
In a preferred embodiment, the method is an operation layer located between the front-end application layer and the blockchain layer, and is used for linking the front-end application layer and the blockchain layer to support various front-end applications upwards and to interface various blockchain systems downwards.
For the block chain end, the asynchronous operation is possible, for example, some time-consuming processing is performed, and the block chain end also adopts an asynchronous mode, firstly returns the instruction number of the operation, and then inquires the progress of the operation and returns the result according to the instruction number.
The method supports synchronous return of the block chain and also supports asynchronous operation in the block chain. For asynchronous operation, a query task is generated by automatically creating subtasks to obtain the result of the asynchronous operation.
As a preferred embodiment, the scenario of blockchain operation includes two types, i.e., query type such as user collection query, digital certificate query, certificate detail query, etc., and execution type such as user registration, collection issue, certificate transfer, certificate destruction, etc.
For the execution of the class operation, the blockchain itself may also adopt an asynchronous mode, and after the operation, the result is not directly returned, but the number of the asynchronous request is returned, and the execution result of the blockchain operation can be queried through the number. The method supports the slow operation of a synchronous block chain and the operation of an asynchronous block chain, and generates subtasks to obtain asynchronous return results for the asynchronous block chain operation, wherein the steps are 12, 13, 14 and 15 in the time sequence.
Operation work order:
the Digital Collection Scheduling Engine (DCSE) runs in a work ORDER (ORDER) mode, receives a work ORDER from a front-end Application (APP), and packages a work ORDER number, an operation number, a request parameter, an application number, a pre-work ORDER number and the like as follows:
| work order number
|
orderid
|
| Operation number
|
actionid
|
| Request parameters
|
requests
|
| Application numbering
|
appid
|
| Front work order numbering
|
Preorderid
|
| Execution results
|
Result |
Wherein: the work order number orderid is the unique identification of the work order for identifying and locating the work order.
The operation number actionid is a specific digital collection operation, and includes related operation instructions such as user registration and collection issue.
The request parameters requests encapsulate the parameter set required by the request instruction, such as operator, collection number, digital voucher number, transfer person, recipient, etc
The application number appid is an identifier of the front-end application, and is used for identifying the source application.
The prepositioned work order number preorderid, the work order number of the prepositioned task and partial asynchronous operation of the block chain end exist, results such as user registration, collection distribution and the like cannot be returned immediately, and the system automatically generates subtasks to receive and process asynchronous result notifications of the block chain end after the previous task is completed and a synchronous receipt is received, wherein the previous task is the prepositioned task of the subtask.
And storing the execution Result returned by the instruction.
The instruction set:
the operation instructions of the digital collection comprise user registration, collection issuing and the like:
| user registration
|
userRegister
|
| Tibet issue
|
mintShard
|
| Querying user collections
|
queryShardByAccount
|
| Digital voucher for inquiring collection
|
queryShardByAsset
|
| Querying digital voucher details
|
getShardDetail
|
| Transferring digital certificates
|
tranferShard
|
| Destroying digital certificates
|
burnShard
|
| Querying asynchronous request results
|
getOperateResult
|
| ……
|
…… |
Different operation instructions require different request parameters, and the request parameters are all packaged in requests and are analyzed according to DCOP.
Inputting parameters:
the key characteristics of the main input parameters of the agreement are shown in the following table, wherein R is a mandatory item and O is an optional item.
As the business develops, more parameters can be extended according to agreement agreements:
the format of the instruction input parameter supports json and xml, and other modes can be adopted according to the actual service requirement, so long as both upstream and downstream collaborators use the same format for encapsulation and analysis.
The following describes the packaging method of input parameters by taking the Json format as an example.
A. Examples of the main input parameters of the user registration instruction:
B. example of main input parameters for querying user collection instructions:
outputting parameters:
key characteristics of the main output parameters of the agreement are shown in the following table, where R is mandatory and O is optional.
As services evolve, more parameters may be extended according to protocol conventions.
Wherein:
the Code is a response Code, and identifies whether the operation is successfully executed and whether an error is encountered.
The Message is response information, and when the operation execution encounters an error, the detailed error information is returned by using the parameter.
Result is returned, which is mainly used for inquiring the class instruction, and the parameter is used for returning the inquired Result data, and the parameter is null for executing the class instruction. Note that: the return format of the parameter is different according to different instructions, and the parameter needs to be analyzed according to protocol convention.
The requested is a request ID for asynchronously executing instructions (such as register, issue, etc.) of the class, the blockchain system does not return the operation result in real time, and the operation execution progress can be queried again from the blockchain platform according to the request ID.
The output format of the instruction operation result supports json and xml, and other modes can be adopted according to the actual service requirement, so long as both upstream and downstream collaborators use the same format for encapsulation and analysis.
The packaging method of the output result is described below by taking the Json format as an example.
A. Examples of main parameters of the output result of the user registration instruction are as follows:
B. inquiring the main parameter examples of the output result of the user collection instruction:
compatibility:
and (3) task queue: the Digital Collection Scheduling Engine (DCSE) suggests the use of memory queues, and in terms of implementation, the database may also be used to store tasks according to the requirements in terms of performance, compatibility, development difficulty, and the like.
The type of the work order: the operation work order is recommended to adopt an http + json mode, and in the aspect of concrete implementation, according to the requirements of compatibility and the like, the http + xml and the like modes can also be adopted.
Application and butt joint: through the adaptation operation of interface and logic, can be fit for various front end APP and call.
Block chain butt joint: through the adaptive operation of the interface and the logic, a plurality of different block chain platforms can be docked.
The working principle is as follows: the method is used for connecting a middle operation layer of a front-end application layer and a block chain layer, a non-front-end application and a block chain, is used for solving the problem of asynchronous performance of the front end and the back end, and can also be used for other services with large difference between the front end and the back end, is designed as a general solution, can be used for butt joint of different applications and different block chains, carries out scheduling in a task mode, supports synchronous operation of a block chain end, and also supports asynchronous operation of the block chain end (the result of the asynchronous operation is obtained through subtasks, and the asynchronous operation is asynchronous).
While the present invention has been described in detail and with reference to the embodiments thereof as illustrated in the accompanying drawings, it will be apparent to one skilled in the art that various changes and modifications can be made therein. Therefore, certain details of the embodiments should not be construed as limitations of the invention, except insofar as the invention is defined by the appended claims.