CN112671878A - Block chain information subscription method, device, server and storage medium - Google Patents

Block chain information subscription method, device, server and storage medium Download PDF

Info

Publication number
CN112671878A
CN112671878A CN202011502980.7A CN202011502980A CN112671878A CN 112671878 A CN112671878 A CN 112671878A CN 202011502980 A CN202011502980 A CN 202011502980A CN 112671878 A CN112671878 A CN 112671878A
Authority
CN
China
Prior art keywords
information
block chain
data
information subscription
subscribed
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202011502980.7A
Other languages
Chinese (zh)
Other versions
CN112671878B (en
Inventor
邱炜伟
李伟
蔡亮
匡立中
张帅
钟蔚蔚
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Qulian Technology Co Ltd
Original Assignee
Hangzhou Qulian Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Qulian Technology Co Ltd filed Critical Hangzhou Qulian Technology Co Ltd
Priority to CN202011502980.7A priority Critical patent/CN112671878B/en
Publication of CN112671878A publication Critical patent/CN112671878A/en
Application granted granted Critical
Publication of CN112671878B publication Critical patent/CN112671878B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present application relates to the field of block chain technologies, and in particular, to an information subscription method and apparatus for a block chain, a server, and a storage medium. The information subscription method comprises the following steps: polling blocks in a block chain according to a time interval set in a preset information subscription rule, wherein the information subscription rule comprises data analysis modes corresponding to different contract execution engines respectively; analyzing the data in the block according to a data analysis mode corresponding to a contract execution engine adopted by the block chain to obtain information to be subscribed; and pushing the information to be subscribed to a client. By adopting the information subscription method, different block chain platforms can be compatible, and the difficulty in updating and maintaining the code of the intermediate layer server is reduced.

Description

Block chain information subscription method, device, server and storage medium
Technical Field
The present application relates to the field of block chain technologies, and in particular, to an information subscription method and apparatus for a block chain, a server, and a storage medium.
Background
In an actual blockchain system, an intermediate server is usually erected between a bottom blockchain platform and a client, and the server is responsible for data encoding/decoding, contract function encapsulation, processing of subscription information from the client to the blockchain, and the like in the communication process between the blockchain and the client.
Currently, for processing the subscription information from the client to the blockchain, the middle-layer server generally needs to perform customized development of processing logic for different blockchain platforms. For example, for a blockchain using different contract execution engines, such as a blockchain using an ethernet virtual machine as an execution engine or a blockchain using a java virtual machine as an execution engine, it is generally required to set respective corresponding processing logics in the middle-tier server. Thus, once the middle tier servers interface more blockchain platforms, code update and maintenance operations become very difficult.
Disclosure of Invention
In view of this, embodiments of the present application provide an information subscription method and apparatus for a block chain, a server, and a storage medium, which are compatible with different block chain platforms, and reduce difficulty in updating and maintaining codes of a middle-layer server.
A first aspect of an embodiment of the present application provides an information subscription method for a block chain, including:
polling blocks in a block chain according to a time interval set in a preset information subscription rule, wherein the information subscription rule comprises data analysis modes corresponding to different contract execution engines respectively;
analyzing the data in the block according to a data analysis mode corresponding to a contract execution engine adopted by the block chain to obtain information to be subscribed;
and pushing the information to be subscribed to a client.
In the embodiment of the application, an information subscription rule is set in the middle layer server, wherein data analysis modes corresponding to different contract execution engines are defined. The middle-layer server polls and acquires blocks in the block chain according to a time interval set in the information subscription rule, analyzes data in the blocks according to a data analysis mode corresponding to a contract execution engine adopted by the current block chain after acquiring the blocks, and then pushes the analyzed data to the client side, so that information pushing is completed. Through the arrangement, the intermediate layer server can be compatible with the information subscription processing of a plurality of different blockchain platforms only by constructing a set of information subscription rules, so that the difficulty of code updating and maintenance of the intermediate layer server can be reduced.
In an embodiment of the present application, polling to acquire a block in a block chain according to a time interval set in a preset information subscription rule may include:
if the activation request of the information subscription is detected, reading the information subscription rule stored in the database, and creating a processing thread of the information subscription according to the time interval;
and executing the processing thread to poll and acquire the blocks in the block chain.
The user may click an activation button on the management interface to send an activation request for information subscription, and after receiving the activation request, the middle tier server reads the information subscription rule stored in the database, and creates a processing thread for information subscription according to a time interval (i.e., a polling cycle) defined in the rule. The middle tier server then executes these processing threads and begins to listen for tiles in the tile chain.
In an embodiment of the present application, the analyzing the data in the block according to a data analysis manner corresponding to a contract execution engine adopted by the block chain to obtain the information to be subscribed may include:
searching data of a designated field from the block, wherein the designated field is a field where the information to be subscribed is set in the information subscription rule;
and analyzing the data of the specified field according to a data analysis mode corresponding to a contract execution engine adopted by the block chain to obtain the information to be subscribed.
When analyzing data, a field where the information to be subscribed is located can be found first, so that the information to be subscribed can be obtained only by analyzing the data of the field. In the information subscription rule, which field in the block the information to be subscribed is stored in can be marked, so that the information to be subscribed can be found more quickly and accurately.
Further, analyzing the data of the specified field according to a data analysis mode corresponding to a contract execution engine adopted by the block chain to obtain the information to be subscribed, which may include:
determining an intelligent contract name aimed at by the information subscription, an intelligent contract method name adopted by the information subscription, a parameter name required to be captured by the information subscription and an interface description file required by the contract execution engine to analyze data according to the information subscription rule;
and analyzing the data of the specified field by combining the intelligent contract name, the intelligent contract method name, the parameter name and the interface description file to obtain the information to be subscribed.
In the data hit and analysis rule included in the information subscription rule, information such as an intelligent contract name targeted by the information subscription of this time, an intelligent contract method name adopted by the information subscription of this time, a parameter name required to be captured by the information subscription of this time, an interface description file required by the contract execution engine to analyze data, and the like can be formulated. Then, when data analysis is performed, the data in the specified field may be analyzed in combination with the information, for example, data related to the intelligent contract in the specified field is found by the name of the intelligent contract, and the information to be subscribed is finally obtained.
In an embodiment of the present application, analyzing the data in the block according to a data analysis manner corresponding to a contract execution engine adopted by the block chain to obtain the information to be subscribed may include:
analyzing the data in the block according to a data analysis mode corresponding to a contract execution engine adopted by the block chain;
and if the analysis is successful, determining the information obtained by the analysis as the information to be subscribed.
And when the data analysis is successful, the block in the block chain is described to contain the data to be subscribed by the client, and the information obtained by the analysis is determined as the information to be subscribed and is pushed to the client.
Further, after analyzing the data in the block according to a data analysis mode corresponding to a contract execution engine adopted by the block chain, the method may further include:
and if the analysis fails, determining that the block does not contain the information to be subscribed, and continuously polling to obtain the next block in the block chain.
And when the data analysis fails, it is stated that the block of the block chain does not contain the data to be subscribed by the client, at this time, the intermediate layer server does not push the information, and continues to poll the next block in the block chain, and then the information subscription processing process is repeatedly executed.
Further, the information subscription rule further includes an interface address of a client subscribing to information to receive information, and the pushing the information to be subscribed to the client may include:
and pushing the information to be subscribed to the interface address.
In practical application, the information subscription rule may record an interface address of a client subscribing to information for receiving information, and the intermediate layer server only needs to push information to be subscribed to the interface address.
A second aspect of the embodiments of the present application provides an information subscription device for a block chain, which is applied to an intermediate layer server, and the device includes:
the system comprises a block acquisition module, a block chain acquisition module and a block management module, wherein the block acquisition module is used for polling and acquiring blocks in the block chain according to a time interval set in a preset information subscription rule, and the information subscription rule comprises data analysis modes respectively corresponding to different contract execution engines;
the information analysis module is used for analyzing the data in the block according to a data analysis mode corresponding to a contract execution engine adopted by the block chain to obtain information to be subscribed;
and the information pushing module is used for pushing the information to be subscribed to the client.
A third aspect of embodiments of the present application provides a server, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor, when executing the computer program, implements the steps of the information subscription method for a block chain as provided in the first aspect of embodiments of the present application.
A fourth aspect of embodiments of the present application provides a computer-readable storage medium, which stores a computer program, and the computer program, when executed by a processor, implements the steps of the information subscription method for a blockchain as provided in the first aspect of embodiments of the present application.
A fifth aspect of the embodiments of the present application provides a computer program product, which, when running on a terminal device, causes the terminal device to execute the steps of the method for subscribing to information of a block chain according to the first aspect of the embodiments of the present application.
It is understood that the beneficial effects of the second aspect to the fifth aspect can be referred to the related description of the first aspect, and are not described herein again.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
Fig. 1 is a schematic structural diagram of an information subscription system used in an information subscription method for a block chain according to an embodiment of the present application;
fig. 2 is a flowchart of an embodiment of an information subscription method for a blockchain according to an embodiment of the present application;
fig. 3 is a flowchart of an embodiment of another block chain information subscription method according to an embodiment of the present application;
fig. 4 is a schematic flowchart of an information subscription method for a block chain provided in the embodiment of the present application in an actual application scenario;
fig. 5 is a schematic flowchart of an example of an actual information subscription process provided in the embodiment of the present application;
fig. 6 is a block diagram of an embodiment of an information subscription apparatus for a block chain according to an embodiment of the present application;
fig. 7 is a schematic diagram of a server according to an embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail. Furthermore, in the description of the present application and the appended claims, the terms "first," "second," "third," and the like are used for distinguishing between descriptions and not necessarily for describing or implying relative importance.
The block chain is a distributed shared account book and a database, and has the characteristics of decentralization, no tampering, trace retaining in the whole process, traceability, collective maintenance, openness and transparency and the like. Currently, in an actual blockchain system, an intermediate layer server is usually installed to handle data encoding and decoding, contract function encapsulation, and processing of subscription information from a service system to a blockchain in a communication process between the blockchain and the service system (client). However, for the processing of the business system subscribing to the blockchain information, the middle layer server generally needs to perform customized development of processing logic for different blockchain platforms. If the subscription requirement is changed, the relevant codes of the middle-layer server need to be modified, and the service is restarted after the codes are updated. On one hand, restarting the middle layer server requires the service system to suspend the operation of the service, and has great influence on certain continuous services; on the other hand, if the middle-tier server interfaces with more blockchain platforms, the code update and maintenance operations become very difficult.
In view of the above problems, embodiments of the present application provide an information subscription method and apparatus for a block chain, a server, and a storage medium, which are compatible with different block chain platforms, reduce difficulty in updating and maintaining codes of an intermediate layer server, and can implement that, when a service subscription of a service system to the block chain is changed in an operation process of the intermediate layer server, the intermediate layer service does not need to be restarted.
It should be understood that the execution subject of the method embodiments of the present application may be various types of terminal devices or servers, such as a mobile phone, a tablet computer, a notebook computer, a desktop computer, a wearable device, and the like.
Fig. 1 is a schematic structural diagram of an information subscription system used in an information subscription method for a block chain according to an embodiment of the present application. Fig. 1 includes a service system, an intermediate layer server and a plurality of different blockchain platforms, where the service system is a client and requires to subscribe to information from the blockchain platform through the intermediate layer server; the middle layer server is responsible for data encoding and decoding, contract function encapsulation, subscription information processing from the service system to the block chain and other work in the communication process of the block chain and the service system (client), and is an execution main body of each method embodiment provided by the application; and each different blockchain platform (such as fabric or Ethernet) is in butt joint with the middle-layer server to complete data interaction. It should be noted that the present application does not set any limit to the type and number of the accessed blockchain platforms.
With regard to the specific working principle of the above information subscription system, reference may be made to the method embodiments described below.
Referring to fig. 2, an information subscription method for a block chain according to an embodiment of the present application is shown, including:
201. polling blocks in a block chain according to a time interval set in a preset information subscription rule, wherein the information subscription rule comprises data analysis modes corresponding to different contract execution engines respectively;
according to the method and the device, a set of information subscription rules are established in the middle layer server, and the subscription information processing from the client to each different block chain is realized through the information subscription rules. Specifically, the information subscription rule may include a client address, a time interval for monitoring and pushing information, a type of a contract execution engine, a field where information to be subscribed is located, and contents such as a data hit and resolution rule, where the data hit and resolution rule includes data resolution modes corresponding to different contract execution engines respectively. After creating the information subscription rule, the middle tier server may record the information subscription rule in a database for storage.
When the subscription information processing is executed, the middle-layer server polls and acquires the blocks in the block chain according to a certain time interval (for example, 3 seconds) set in the information subscription rule. The blockchain may be any type of blockchain, such as fabric or etherhouse.
In an embodiment of the present application, the polling to acquire a block in a block chain according to a time interval set in a preset information subscription rule may include:
(1) if the activation request of the information subscription is detected, reading the information subscription rule stored in the database, and creating a processing thread of the information subscription according to the time interval;
(2) and executing the processing thread to poll and acquire the blocks in the block chain.
In practical application, a management interface of the information subscription service may be set in the middle tier server, and the corresponding information subscription rule may be created, modified or deleted through the management interface. And after the information subscription rule is established, the middle layer server stores the rule in a database. Then, the user may click an activation button on the management interface to issue an activation request for information subscription, and after receiving the activation request, the middle tier server reads the information subscription rule stored in the database, and creates a processing thread for information subscription according to a time interval (i.e., a polling cycle) defined in the rule. Then, the middle layer server executes the processing threads, starts to monitor the blocks in the block chain, when the data contained in the blocks meet the requirements of the information subscription rule, analyzes the data in the blocks, and then sends the analyzed data to the client addresses recorded in the subscription rule, thereby completing the pushing of the information.
202. Analyzing the data in the block according to a data analysis mode corresponding to a contract execution engine adopted by the block chain to obtain information to be subscribed;
after acquiring a block in the block chain, the middle-layer server analyzes the data in the block according to a data analysis mode corresponding to a contract execution engine adopted by the block chain to obtain the information to be subscribed. The information subscription rule sets a data analysis mode corresponding to each different contract execution engine, wherein the contract execution engine adopted by the current block chain is firstly determined, and then the data analysis mode corresponding to the contract execution engine is searched to analyze the data of the block, so as to obtain the information to be subscribed. For example, if the contract execution engine adopted by the current block chain is the EVM virtual machine, the data of the block is analyzed in a data analysis mode corresponding to the EVM virtual machine; and if the contract execution engine in the current block chain is the fabric-go, analyzing the data of the block by adopting a data analysis mode corresponding to the fabric-go, and so on.
Further, step 202 may include:
(1) searching data of a designated field from the block, wherein the designated field is a field where the information to be subscribed is set in the information subscription rule;
(2) and analyzing the data of the specified field according to a data analysis mode corresponding to a contract execution engine adopted by the block chain to obtain the information to be subscribed.
When analyzing data, a field where the information to be subscribed is located can be found first, so that the information to be subscribed can be obtained only by analyzing the data of the field. In the information subscription rule, which field in the block the information to be subscribed is stored in can be marked, so that the information to be subscribed can be found more quickly and accurately.
Further, analyzing the data of the specified field according to a data analysis mode corresponding to a contract execution engine adopted by the block chain to obtain the information to be subscribed, which may include:
(2.1) determining an intelligent contract name aimed at by the information subscription, an intelligent contract method name adopted by the information subscription, a parameter name required to be captured by the information subscription and an interface description file required by the contract execution engine to analyze data according to the information subscription rule;
and (2.2) analyzing the data of the specified field by combining the intelligent contract name, the intelligent contract method name, the parameter name and the interface description file to obtain the information to be subscribed.
In the data hit and analysis rule included in the information subscription rule, information such as an intelligent contract name targeted by the information subscription of this time, an intelligent contract method name adopted by the information subscription of this time, a parameter name required to be captured by the information subscription of this time, an interface description file required by the contract execution engine to analyze data, and the like can be formulated. Then, when data analysis is performed, the data in the specified field may be analyzed in combination with the information, for example, data related to the intelligent contract in the specified field is found by the name of the intelligent contract, and the information to be subscribed is finally obtained.
203. And pushing the information to be subscribed to a client.
After obtaining the information to be subscribed, the middle-layer server will push the information to be subscribed to a client subscribing to the information, such as the service system in fig. 1, thereby completing a process of subscribing to the information. Specifically, the information subscription rule may record an interface address of the client terminal subscribing the information to receive the information, and the intermediate layer server only needs to push the information to be subscribed to the interface address.
In the embodiment of the application, an information subscription rule is set in the middle layer server, wherein data analysis modes corresponding to different contract execution engines are defined. The middle-layer server polls and acquires blocks in the block chain according to a time interval set in the information subscription rule, analyzes data in the blocks according to a data analysis mode corresponding to a contract execution engine adopted by the current block chain after acquiring the blocks, and then pushes the analyzed data to the client side, so that information pushing is completed. Through the arrangement, the intermediate layer server can be compatible with the information subscription processing of a plurality of different blockchain platforms only by constructing a set of information subscription rules, so that the difficulty of code updating and maintenance of the intermediate layer server can be reduced.
Referring to fig. 3, a method for subscribing to information of a block chain according to another embodiment of the present application is shown, including:
301. polling blocks in a block chain according to a time interval set in a preset information subscription rule, wherein the information subscription rule comprises data analysis modes corresponding to different contract execution engines respectively;
step 301 is the same as step 201, and specific reference may be made to the description related to step 201.
302. Analyzing the data in the block according to a data analysis mode corresponding to a contract execution engine adopted by the block chain;
after acquiring a block in the block chain, the middle-layer server may analyze the data in the block according to a data analysis manner corresponding to a contract execution engine adopted by the block chain, where a specific data analysis manner may refer to a related description of an embodiment of the present application.
303. Judging whether the data analysis is successful or not;
after data analysis is performed on the data in the block in the corresponding data analysis mode, whether the data analysis is successful is judged, and if the data analysis is successful, step 304 is executed; if the data analysis fails, step 305 is executed.
304. Determining the information obtained by analysis as the information to be subscribed and pushing the information to the client;
the data analysis is successful, it is described that the block in the block chain includes data to be subscribed by the client, at this time, the information obtained by the analysis is determined as information to be subscribed, and is pushed to the client, and the specific operation may refer to step 203 above.
305. And determining that the block does not contain the information to be subscribed, and continuously polling to acquire the next block in the block chain.
And when the data analysis fails, it is stated that the block of the block chain does not contain the data to be subscribed by the client, at this time, the intermediate layer server does not push the information, and continues to poll the next block in the block chain, and then the information subscription processing process is repeatedly executed.
In the embodiment of the application, an information subscription rule is set in the middle layer server, wherein data analysis modes corresponding to different contract execution engines are defined. The middle-layer server polls and acquires blocks in the block chain according to a time interval set in the information subscription rule, analyzes data in the blocks according to a data analysis mode corresponding to a contract execution engine adopted by the current block chain after acquiring the blocks, and then pushes the analyzed data to the client side, so that information pushing is completed. Through the arrangement, the intermediate layer server can be compatible with the information subscription processing of a plurality of different blockchain platforms only by constructing a set of information subscription rules, so that the difficulty of code updating and maintenance of the intermediate layer server can be reduced.
For ease of understanding, the information subscription method proposed in the present application is described below in an actual application scenario.
Firstly, a set of information subscription rules is created at the middle layer server side and stored in the database, and the information contained in a certain information subscription rule is shown in the following table 1:
TABLE 1
Figure BDA0002844007700000111
Further, Rule in table 1, i.e. the data hit and parse Rule, may include the following contents shown in table 2:
TABLE 2
Figure BDA0002844007700000112
Figure BDA0002844007700000121
After the information subscription rule is created, the information subscription rule may be stored in a database of the middle tier server. In the information subscription, after detecting the activation request of the information subscription, the middle tier server creates a processing thread for the information subscription according to a time Interval (i.e., Interval) defined in the rule, so as to poll and acquire the tiles in the tile chain according to the time Interval. Then, the data in the block, specifically, the data in the Datafield field set by the information subscription rule, is extracted and saved as value (Datafield). And then, reading a data hit and analysis rule in the information subscription rule, and analyzing the data according to a data analysis mode corresponding to a contract execution engine adopted by the current block chain. For example, if the contract execution engine adopted by the current blockchain is a fabric-go, a data parsing mode corresponding to the fabric-go is adopted, and value (datafield) is parsed according to the Rule requirement; if the contract execution engine adopted by the current blockchain is evm, a data parsing mode corresponding to evm is adopted, and value (datafield) is parsed according to the Rule requirement, and so on. If the data analysis is successful, it indicates that the block contains data to be subscribed by the client, and at this time, the data obtained by the analysis is pushed to the address NoticeAddr. If the data analysis fails, it indicates that the block does not contain data to be subscribed by the client, at this time, the intermediate layer server does not push information, and continues to poll the next block in the block chain, and then repeatedly executes the information subscription processing process, where a flow diagram of the information subscription processing is shown in fig. 4.
An example of an actual information subscription process is listed below to illustrate the information subscription process method proposed in the present application.
This example is: in the operation process of the middle-layer server, the business system adds a piece of subscription information aiming at the value parameter of the token contract transfer method, and the subscription information is monitored and acquired from a block chain platform based on an evm intelligent contract engine.
The information subscription rules created for this example are shown in table 3 below:
TABLE 3
Figure BDA0002844007700000131
As shown in fig. 5, after the flow is activated, the middle-tier server starts creating a thread, and polls the acquisition tiles in evm tile chains at a timing interval of 3s by the thread; after obtaining a block, extracting transaction data in the block; then obtaining the numerical value of the payload field in the transaction data, and recording the numerical value as data; next, Rule in table 3 is read, and data is analyzed by using a data analysis method corresponding to the evm contract execution engine in combination with information such as the contigname, the methodName, the argName, and the ABI defined in Rule. If the data is successfully analyzed, the transaction is called for a transfer method in a token contract, the value of the value parameter can be successfully acquired, and finally the value of the value parameter is pushed to the noticeAddr and returned to the service system. If the data analysis fails, it indicates that the data in the block does not contain the data to be subscribed by the service system, and at this time, information push is not performed, and the next block in the block chain is continuously polled.
In summary, the information subscription method for the block chain provided by the present application has the following advantages:
(1) the method can realize that the intermediate layer service does not need to be restarted when the information subscription of the business system to the block chain is newly increased or modified in the operation process of the intermediate layer server;
(2) the subscription service of the middle layer completes one-time development and one-time test, and frequent updating is not needed;
(3) the information subscription rule realizes configurability, and can be compatible with various different types of blockchain platforms such as a fabric platform based on a go language intelligent contract, an etherhouse platform and a partial commercial blockchain platform based on a evm intelligent contract, a partial commercial blockchain platform based on a jvm intelligent contract and the like.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
The above mainly describes an information subscription method for a block chain, and an information subscription apparatus for a block chain will be described below.
Referring to fig. 6, an embodiment of an information subscribing device for a block chain in an embodiment of the present application includes:
a block acquisition module 601, configured to poll and acquire blocks in a block chain according to a time interval set in a preset information subscription rule, where the information subscription rule includes data analysis modes corresponding to different contract execution engines, respectively;
the information analysis module 602 is configured to analyze data in the block according to a data analysis manner corresponding to a contract execution engine adopted by the block chain, so as to obtain information to be subscribed;
an information pushing module 603, configured to push the information to be subscribed to the client.
In an embodiment of the present application, the block acquiring module may include:
the thread creating unit is used for reading the information subscription rule stored in the database and creating a processing thread of the information subscription according to the time interval if the activation request of the information subscription is detected;
and the block acquisition unit is used for executing the processing thread to poll and acquire the blocks in the block chain.
In an embodiment of the present application, the information parsing module may include:
a field searching unit, configured to search data of a specified field from the block, where the specified field is a field where information to be subscribed set in the information subscription rule is located;
and the first data analysis unit is used for analyzing the data of the specified field according to a data analysis mode corresponding to a contract execution engine adopted by the block chain to obtain the information to be subscribed.
Further, the first data parsing unit may include:
a rule determining subunit, configured to determine, according to the information subscription rule, an intelligent contract name targeted by the information subscription of this time, an intelligent contract method name adopted by the information subscription of this time, a parameter name required to be captured by the information subscription of this time, and an interface description file required by the contract execution engine to analyze data;
and the data analysis subunit is used for analyzing the data of the specified field by combining the intelligent contract name, the intelligent contract method name, the parameter name and the interface description file to obtain the information to be subscribed.
In an embodiment of the present application, the information parsing module may include:
the second data analysis unit is used for analyzing the data in the block according to a data analysis mode corresponding to a contract execution engine adopted by the block chain;
and the information determining unit is used for determining the information obtained by analysis as the information to be subscribed if the analysis is successful.
Further, the information parsing module may further include:
and the polling acquisition unit is used for determining that the block does not contain the information to be subscribed if the analysis fails, and continuously polling to acquire the next block in the block chain.
In an embodiment of the application, the information subscription rule further includes an interface address for a client subscribing to information to receive information, and the information pushing module may include:
and the information pushing unit is used for pushing the information to be subscribed to the interface address.
An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the computer program implements the steps of the information subscription method of any one of the block chains as shown in fig. 2 or fig. 3.
An embodiment of the present application further provides a computer program product, which, when running on a terminal device, causes the terminal device to execute the steps of implementing the information subscription method for a block chain as shown in any one of fig. 2 or fig. 3.
Fig. 7 is a schematic diagram of a server according to an embodiment of the present application. As shown in fig. 7, the server 7 of this embodiment includes: a processor 70, a memory 71 and a computer program 72 stored in said memory 71 and executable on said processor 70. The processor 70, when executing the computer program 72, implements the steps in the above-described embodiments of the information subscription method for each block chain, such as the steps 201 to 203 shown in fig. 2. Alternatively, the processor 70, when executing the computer program 72, implements the functions of each module/unit in each device embodiment described above, for example, the functions of the modules 601 to 603 shown in fig. 6.
The computer program 72 may be divided into one or more modules/units, which are stored in the memory 71 and executed by the processor 70 to accomplish the present application. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution of the computer program 72 in the server 7.
The Processor 70 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The storage 71 may be an internal storage unit of the server 7, such as a hard disk or a memory of the server 7. The memory 71 may also be an external storage device of the server 7, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the server 7. Further, the memory 71 may also include both an internal storage unit and an external storage device of the server 7. The memory 71 is used for storing the computer program and other programs and data required by the server. The memory 71 may also be used to temporarily store data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described system embodiments are merely illustrative, and for example, the division of the modules or units is only one logical division, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow in the method of the embodiments described above can be realized by a computer program, which can be stored in a computer-readable storage medium and can realize the steps of the embodiments of the methods described above when the computer program is executed by a processor. . Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain other components which may be suitably increased or decreased as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media which may not include electrical carrier signals and telecommunications signals in accordance with legislation and patent practice.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present application and are intended to be included within the scope of the present application.

Claims (10)

1. An information subscription method of a blockchain is applied to a middle layer server, and is characterized in that the method comprises the following steps:
polling blocks in a block chain according to a time interval set in a preset information subscription rule, wherein the information subscription rule comprises data analysis modes corresponding to different contract execution engines respectively;
analyzing the data in the block according to a data analysis mode corresponding to a contract execution engine adopted by the block chain to obtain information to be subscribed;
and pushing the information to be subscribed to a client.
2. The information subscription method according to claim 1, wherein polling blocks in the block chain according to a time interval set in a preset information subscription rule comprises:
if the activation request of the information subscription is detected, reading the information subscription rule stored in the database, and creating a processing thread of the information subscription according to the time interval;
and executing the processing thread to poll and acquire the blocks in the block chain.
3. The information subscription method according to claim 1, wherein the analyzing the data in the block according to the data analysis mode corresponding to the contract execution engine adopted by the block chain to obtain the information to be subscribed comprises:
searching data of a designated field from the block, wherein the designated field is a field where the information to be subscribed is set in the information subscription rule;
and analyzing the data of the specified field according to a data analysis mode corresponding to a contract execution engine adopted by the block chain to obtain the information to be subscribed.
4. The information subscription method according to claim 3, wherein analyzing the data in the specified field according to a data analysis mode corresponding to a contract execution engine adopted by the block chain to obtain the information to be subscribed includes:
determining an intelligent contract name aimed at by the information subscription, an intelligent contract method name adopted by the information subscription, a parameter name required to be captured by the information subscription and an interface description file required by the contract execution engine to analyze data according to the information subscription rule;
and analyzing the data of the specified field by combining the intelligent contract name, the intelligent contract method name, the parameter name and the interface description file to obtain the information to be subscribed.
5. The information subscription method according to claim 1, wherein analyzing the data in the block according to a data analysis mode corresponding to a contract execution engine adopted by the block chain to obtain the information to be subscribed comprises:
analyzing the data in the block according to a data analysis mode corresponding to a contract execution engine adopted by the block chain;
and if the analysis is successful, determining the information obtained by the analysis as the information to be subscribed.
6. The information subscription method according to claim 5, wherein after parsing the data in the block according to a data parsing manner corresponding to a contract execution engine adopted by the block chain, the method further comprises:
and if the analysis fails, determining that the block does not contain the information to be subscribed, and continuously polling to obtain the next block in the block chain.
7. The information subscription method according to any one of claims 1 to 6, wherein the information subscription rule further includes an interface address for a client subscribing to information to receive information, and the pushing the information to be subscribed to the client comprises:
and pushing the information to be subscribed to the interface address.
8. An information subscription device of a blockchain, which is applied to a middle layer server, is characterized in that the device comprises:
the system comprises a block acquisition module, a block chain acquisition module and a block management module, wherein the block acquisition module is used for polling and acquiring blocks in the block chain according to a time interval set in a preset information subscription rule, and the information subscription rule comprises data analysis modes respectively corresponding to different contract execution engines;
the information analysis module is used for analyzing the data in the block according to a data analysis mode corresponding to a contract execution engine adopted by the block chain to obtain information to be subscribed;
and the information pushing module is used for pushing the information to be subscribed to the client.
9. A server comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the information subscription method of a blockchain according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method of information subscription of a blockchain according to any one of claims 1 to 7.
CN202011502980.7A 2020-12-17 2020-12-17 Block chain information subscription method, device, server and storage medium Active CN112671878B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011502980.7A CN112671878B (en) 2020-12-17 2020-12-17 Block chain information subscription method, device, server and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011502980.7A CN112671878B (en) 2020-12-17 2020-12-17 Block chain information subscription method, device, server and storage medium

Publications (2)

Publication Number Publication Date
CN112671878A true CN112671878A (en) 2021-04-16
CN112671878B CN112671878B (en) 2023-03-24

Family

ID=75406409

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011502980.7A Active CN112671878B (en) 2020-12-17 2020-12-17 Block chain information subscription method, device, server and storage medium

Country Status (1)

Country Link
CN (1) CN112671878B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113505319A (en) * 2021-07-27 2021-10-15 上海点融信息科技有限责任公司 Method, apparatus and medium for updating search content for search engine on BaaS platform
CN113689188A (en) * 2021-08-23 2021-11-23 交通银行股份有限公司 Decentralization information management system and method based on Ether house intelligent contracts

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107147704A (en) * 2017-04-21 2017-09-08 杭州趣链科技有限公司 A kind of generic service middleware system towards block chain
CN108510389A (en) * 2018-03-30 2018-09-07 深圳前海微众银行股份有限公司 Intelligent contract call method, equipment and readable storage medium storing program for executing based on block chain
CN109376541A (en) * 2018-09-21 2019-02-22 上海点融信息科技有限责任公司 For running the method, apparatus and computer storage medium of intelligent contract
CN110097363A (en) * 2019-04-12 2019-08-06 深圳前海微众银行股份有限公司 It is a kind of based on block chain event publication, event subscription method and device
CN110209381A (en) * 2019-05-31 2019-09-06 深圳前海微众银行股份有限公司 SDK fast integration method, apparatus, equipment and storage medium based on block chain
CN111126977A (en) * 2019-12-27 2020-05-08 深圳大学 Transaction processing method of block chain system

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107147704A (en) * 2017-04-21 2017-09-08 杭州趣链科技有限公司 A kind of generic service middleware system towards block chain
CN108510389A (en) * 2018-03-30 2018-09-07 深圳前海微众银行股份有限公司 Intelligent contract call method, equipment and readable storage medium storing program for executing based on block chain
CN109376541A (en) * 2018-09-21 2019-02-22 上海点融信息科技有限责任公司 For running the method, apparatus and computer storage medium of intelligent contract
CN110097363A (en) * 2019-04-12 2019-08-06 深圳前海微众银行股份有限公司 It is a kind of based on block chain event publication, event subscription method and device
CN110209381A (en) * 2019-05-31 2019-09-06 深圳前海微众银行股份有限公司 SDK fast integration method, apparatus, equipment and storage medium based on block chain
CN111126977A (en) * 2019-12-27 2020-05-08 深圳大学 Transaction processing method of block chain system

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113505319A (en) * 2021-07-27 2021-10-15 上海点融信息科技有限责任公司 Method, apparatus and medium for updating search content for search engine on BaaS platform
CN113689188A (en) * 2021-08-23 2021-11-23 交通银行股份有限公司 Decentralization information management system and method based on Ether house intelligent contracts

Also Published As

Publication number Publication date
CN112671878B (en) 2023-03-24

Similar Documents

Publication Publication Date Title
CN107506451B (en) Abnormal information monitoring method and device for data interaction
CN111522922A (en) Log information query method and device, storage medium and computer equipment
CN108984389B (en) Application program testing method and terminal equipment
CN111104421A (en) Data query method and device based on data interface standard configuration
CN112491602B (en) Behavior data monitoring method and device, computer equipment and medium
CN112671878B (en) Block chain information subscription method, device, server and storage medium
CN109740129B (en) Report generation method, device and equipment based on blockchain and readable storage medium
CN111552633A (en) Interface abnormal call testing method and device, computer equipment and storage medium
CN108415998B (en) Application dependency relationship updating method, terminal, device and storage medium
CN110019444B (en) Operation request processing method, device, equipment and system
CN112948224A (en) Data processing method, device, terminal and storage medium
CN104765792A (en) Dimension data storing method, device and system
CN107071553B (en) Method, device and computer readable storage medium for modifying video and voice
CN101442539B (en) Method and apparatus for implementing field filtration
CN114531340A (en) Log acquisition method and device, electronic equipment, chip and storage medium
CN114169318A (en) Process identification method, apparatus, device, medium, and program
CN113778996A (en) Large data stream data processing method and device, electronic equipment and storage medium
CN112003837A (en) Intelligent equipment adaptation method and device based on Modbus protocol and storage medium
CN112835901A (en) File storage method and device, computer equipment and computer readable storage medium
CN112860456A (en) Log processing method and device
CN111242256A (en) Information verification method, device and terminal
CN114818645B (en) Automatic report generation method, device, equipment and medium based on data body
CN109284268A (en) A kind of method, system and the electronic equipment of fast resolving log
CN116028108B (en) Method, device, equipment and storage medium for analyzing dependent package installation time
CN117389841B (en) Method and device for monitoring accelerator resources, cluster equipment and storage medium

Legal Events

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