WO2020215925A1 - 一种基于区块链的事件订阅的方法及装置 - Google Patents
一种基于区块链的事件订阅的方法及装置 Download PDFInfo
- Publication number
- WO2020215925A1 WO2020215925A1 PCT/CN2020/079361 CN2020079361W WO2020215925A1 WO 2020215925 A1 WO2020215925 A1 WO 2020215925A1 CN 2020079361 W CN2020079361 W CN 2020079361W WO 2020215925 A1 WO2020215925 A1 WO 2020215925A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- event
- subject
- block
- contract
- acquired
- 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.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
- G06F16/2457—Query processing with adaptation to user needs
- G06F16/24578—Query processing with adaptation to user needs using ranking
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
- G06F16/2458—Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
- G06F16/2474—Sequence data queries, e.g. querying versioned data
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q20/00—Payment architectures, schemes or protocols
- G06Q20/38—Payment protocols; Details thereof
- G06Q20/382—Payment protocols; Details thereof insuring higher security of transaction
- G06Q20/3821—Electronic credentials
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q20/00—Payment architectures, schemes or protocols
- G06Q20/38—Payment protocols; Details thereof
- G06Q20/389—Keeping log of transactions for guaranteeing non-repudiation of a transaction
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q40/00—Finance; Insurance; Tax strategies; Processing of corporate or income taxes
- G06Q40/04—Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
Definitions
- the embodiments of the present invention relate to the field of financial technology (Fintech), and in particular to a method and device for event subscription based on a blockchain (Blockchain).
- Fetech financial technology
- Blockchain a method and device for event subscription based on a blockchain
- a blockchain is a chain composed of a series of blocks. Each block records the data of the block and the hash value of the previous block. In this way, all blocks form a chain one after another.
- the cryptographic technology and decentralized ideas on which the blockchain is based make the historical information on the chain unable to be tampered with.
- the embodiment of the present invention provides a method and device for event subscription based on blockchain, which are used to improve the efficiency of obtaining events on specific topics.
- the server receives the acquisition request; the acquisition request is used to instruct the server to acquire the event to be acquired from the blockchain system;
- the server obtains the subject contract of the subject of the subject to be acquired from the blockchain system according to the subject to which the event to be acquired belongs; the subject contract corresponding to each subject is stored in the blockchain system; The subject contract records the block location of each event stored in the blockchain system;
- the server determines the block location where the to-be-obtained event is stored from the subject contract of the subject to which the to-be-obtained event belongs, and obtains the to-be-obtained event from the block corresponding to the block location.
- the server after the server receives the acquisition request, it can acquire the subject contract of the subject of the event to be acquired from the blockchain system according to the subject of the event to be acquired in the acquisition request, and the subject contract records the event stored in the block
- the server can determine the block location of the event to be obtained in the blockchain system from the subject contract, and then can determine the event to be obtained from the specific block without traversing the entire blockchain system
- Each of the blocks improves the efficiency of obtaining events on specific topics.
- the event identification of each event is recorded in the subject contract; the event identification includes the event sequence number and the block height; the event sequence number is used to characterize the publishing sequence of the event in the subject; the zone The block height is the block storing the event.
- the event identifier of each event is recorded in the theme contract, and the event identifier includes the event sequence number, which is used to characterize the publishing sequence of the event within the theme.
- the server can write the event identifiers into the subject contract in the order of publishing events, that is, the event identifiers of the subject contract are stored in sequence.
- the server can directly search for the theme contract in sequence according to the serial number range, and obtain the event identifier of the event to be obtained.
- the acquisition request includes an event identifier of the acquired event;
- the to-be-acquired event is an event of the same subject that is published after the acquired event;
- the server determining the location of the block where the event to be obtained is stored from the subject contract of the subject to which the event to be obtained belongs includes:
- the server determines the event identifier of the event to be acquired from the subject contract of the subject to which the event to be acquired belongs, so as to acquire the event identifier of the event to be acquired in the blockchain system The location of each block of storage.
- the server can acquire all events after the acquired event.
- the server determines the event identifier of the event to be acquired from the subject contract of the subject to which the event belongs according to the event identifier of the acquired event. Get the serial number of the event ID of the event Get the event ID of all the serial numbers after the serial number, and use it as the event ID of the event to be obtained, and then get all the events after the event that has been obtained, and satisfy the request of different consumers .
- Optional also includes:
- the server receives a publishing request; the publishing request includes an event to be published;
- the server generates and sends a transaction request to the blockchain system according to the event to be published; the transaction request is used to instruct the blockchain system to call the theme contract corresponding to the theme of the event to be published;
- the subject contract is used to generate a transaction log recording the event to be published and store the transaction log in a block; the subject contract is also used to record the location of the block storing the event to be published in all In the subject contract.
- the server can also receive the release request of the producer, and according to the event to be released in the release request, generate a transaction request and send it to the blockchain system.
- the blockchain system calls the topic contract of the subject to which the event belongs to generate
- the transaction log and the location of the block storing the event to be published are recorded in the subject contract, so that the server can determine the block location of the event to be obtained from the subject contract of the subject to which the event belongs after receiving the acquisition request.
- an embodiment of the present invention also provides a device for event subscription based on blockchain, including:
- the transceiver unit is configured to receive an acquisition request; the acquisition request is used to instruct the processing unit to acquire the event to be acquired from the blockchain system;
- the processing unit is configured to obtain the subject contract of the subject of the subject to be acquired from the blockchain system according to the subject of the subject to be acquired; the subject corresponding to each subject is stored in the blockchain system Contract; the subject contract records the block location of each event stored in the blockchain system;
- the processing unit is further configured to determine the block location where the event to be obtained is stored in the subject contract of the subject to which the event to be obtained belongs, and to obtain the event to be obtained from the block corresponding to the block location .
- the event identification of each event is recorded in the subject contract; the event identification includes the event sequence number and the block height; the event sequence number is used to characterize the publishing sequence of the event in the subject; the zone The block height is used to indicate the block where the event is stored.
- the acquisition request includes an event identifier of the acquired event;
- the to-be-acquired event is an event of the same subject that is published after the acquired event;
- the processing unit is specifically used for:
- the event identifier of the to-be-obtained event is determined from the subject contract of the subject to which the to-be-obtained event belongs, so as to obtain each area of the to-be-obtained event stored in the blockchain system Block location.
- processing unit is further configured to:
- a transaction request is generated and sent to the blockchain system; the transaction request is used to instruct the blockchain system to call the theme contract corresponding to the theme of the event to be published; the theme contract Used to generate a transaction log recording the event to be published and store the transaction log in a block; the subject contract is also used to record the location of the block storing the event to be published in the subject contract Inside.
- an embodiment of the present invention also provides a computing device, including:
- Memory used to store program instructions
- the processor is used to call the program instructions stored in the memory and execute the above event subscription method according to the obtained program.
- an embodiment of the present invention also provides a computer-readable non-volatile storage medium, including computer-readable instructions.
- the computer reads and executes the computer-readable instructions, the computer executes the above-mentioned event subscription method. .
- an embodiment of the present invention also provides a computer program product, the computer program product includes a computer program stored on a computer-readable non-volatile storage medium, the computer program includes program instructions, when the program When the instructions are executed by a computer, the computer executes the above-mentioned event subscription method.
- the server after the server receives the acquisition request, it can acquire the subject contract of the subject of the event to be acquired from the blockchain system according to the subject to which the event to be acquired in the acquisition request belongs.
- the subject contract records the event and is stored in the area.
- the server can determine the block location of the event to be obtained in the blockchain system from the subject contract, and then can determine the event to be obtained from the specific block without traversing the entire blockchain Each block of the system improves the efficiency of obtaining specific subject events.
- FIG. 1 is a schematic diagram of a system architecture provided by an embodiment of the present invention
- FIG. 2 is a schematic flowchart of an event subscription method provided by an embodiment of the present invention.
- FIG. 3 is a schematic flowchart of another event subscription method provided by an embodiment of the present invention.
- FIG. 4 is a schematic flowchart of an event publishing method according to an embodiment of the present invention.
- FIG. 5 is a schematic structural diagram of an event subscription apparatus provided by an embodiment of the present invention.
- Fig. 6 is a schematic structural diagram of a computing device provided by an embodiment of the present invention.
- Fig. 1 exemplarily shows the system architecture to which the method for event subscription based on blockchain provided in an embodiment of the present invention is applicable.
- the system architecture may include a producer 100, a publishing server 200, a blockchain system 300, and a subscription server. 400, 500 consumers.
- the producer 100 is used to generate events to be published
- the publishing server 200 is used to write the events to be published into the blockchain system 300
- the consumer 500 is used to subscribe to events from the blockchain system 300 through the subscription server 400.
- the blockchain system 300 stores theme contracts corresponding to each theme.
- the producer 100 needs to publish an event, it sends the event to be published to the publishing server 200.
- the publishing server 200 generates a transaction request according to the event to be published, and the publishing server 200 sends the transaction request Send to the blockchain system 300.
- the blockchain system 300 executes the subject contract of the subject of the event to be published according to the transaction request, records the event to be published in the blockchain system 300, and at the same time in the subject contract of the subject of the event to be published Record the event identifier of the event to be released.
- the event identifier includes the event sequence number and block height.
- the event sequence number is used to characterize the publishing sequence of the event within the subject
- the block height is used to indicate the block in which the event is stored.
- the blockchain system 300 when the blockchain system 300 records the event to be published in the blockchain system 300, it will also record the block location of the event to be published in the blockchain system 300 in the subject of the event to be published.
- the theme contract of it is equivalent to that the theme contract of the blockchain system 300 records the location of each event stored in the block chain system 300.
- the consumer 500 When the consumer 500 needs to acquire an event, it sends an acquisition request to the subscription server 400.
- the subscription server 400 determines the event corresponding to the acquisition request from the blockchain system 300 according to the received acquisition request, and feeds it back to the consumer 500 to complete the consumer 500 event subscriptions.
- the publishing server 200 and the subscribing server 400 in the system architecture can be one server physically, which completes publishing and subscribing functions, or two separate servers, which complete publishing and subscribing functions respectively, which will not be done here. limit.
- the servers involved in event subscription and the servers involved in event publishing in the following embodiments are now referred to as servers.
- Figure 2 exemplarily shows the flow of a method for event subscription based on blockchain provided by an embodiment of the present invention, and the flow specifically includes:
- Step 201 The server receives the acquisition request.
- the acquisition request may be sent by the consumer to the server to instruct the server to acquire the event to be acquired from the blockchain system.
- the acquisition request may include the subject of the event to be acquired, which is used by the server to determine the subject contract of the subject of the event to be acquired according to the subject of the event to be acquired. It may also include the event identifier of the acquired event. Obtain the events of the same topic published by the producer after the event has been acquired in the blockchain system.
- step 202 the server obtains the subject contract of the subject of the event to be obtained from the blockchain system according to the subject of the event to be obtained.
- theme contracts corresponding to each theme are stored in the blockchain system, for example, theme contracts A, B, and C are deployed in the blockchain system, corresponding to themes a, b, and c, respectively.
- the server determines that the subject of the event to be obtained is subject a, and then the subject contract A of subject a can be obtained from the blockchain system.
- Step 203 The server determines the location of the block where the event to be obtained is stored from the subject contract of the subject to which the event belongs, and obtains the event to be obtained from the block corresponding to the block location.
- the block location of each event is stored in the subject contract, that is, the server can determine the block location in the blockchain system where the event to be obtained is located by querying the content in the subject contract, and further obtain it from the corresponding block To the pending event.
- the acquisition request received by the server includes the event identifier of the acquired event, and the acquisition request is used to instruct the server to obtain the event of the same subject after acquiring the acquired event from the blockchain system, that is, the event to be acquired It is an event of the same topic published after the event has been obtained.
- the server determines the event identifier of the event to be acquired from the subject contract of the subject to be acquired, thereby acquiring the location of each block stored in the blockchain system of the event to be acquired, and corresponds to the block location Obtain the pending events in the block of.
- the producer publishes 20 events corresponding to theme a to the blockchain system.
- the theme contract A of the blockchain system stores the event identifier of each of the 20 events.
- the event identifier includes the event serial number and the area. Block height.
- the event identifier of an event is "a2, block30", where "a2" means that the event is the second event published in topic A, and "block30” means that the event is stored in a block height of 30 Block.
- the acquisition request received by the server includes the event identifier of the acquired event. If it is "a4, block34", the event to be acquired is an event of topic A published after the event with the event identifier "a4, block34".
- a4, block34" determines the event identifier of the event to be obtained from the subject contract A, such as "a5, block34", “a6, block36”, ..., “a20, block98", thereby determining the storage of each event in the event to be obtained
- the location of the block in the blockchain system, such as the event to be obtained with the serial number "a5" is stored in the block with the block height of 34 in the blockchain system, so that the serial number can be further obtained from the block The pending event of "a5".
- the event identifier includes the event serial number, which is used to characterize the publishing sequence of the event in the subject to which it belongs.
- the event serial number can be a serial number from 1 to n determined in the same subject according to the publishing sequence, or it can be a different subject.
- the serial number from 1 to n is determined according to the publishing order. Of course, it can also be the time when events are published in the same topic or in different topics, that is, any parameter in this scheme that can characterize the publishing order of events in the subject. Can be understood as the event sequence number.
- the event identifier includes the block height, which is used to indicate the block where the event is stored, that is, the event to be acquired can be located to a specific block in the blockchain system according to the block height, and the block height can also be understood It is the identification number, serial number, etc. of the block in the blockchain system.
- the scenario is that a consumer subscribes to an event of a specific topic published by a producer, that is, production Consumers can subscribe to the event from the blockchain system every time the user publishes an event on the specific topic to the blockchain system, but due to the consumer’s own failure, the access to the event on the specific topic published by the producer is interrupted .
- the producer has published 100 events from a certain point in time to the present, and consumers subscribed to the events of topic a published by the producer. Due to the consumer's own failure, he only subscribed to the 52nd event. , You can’t get the events in Article 53 and after Article 53, you can send an acquisition request to the server.
- the acquisition request includes the event identifier of the acquired event (Article 52). Event) to obtain the event identifiers of the 53rd and subsequent events, and further obtain the 53rd and subsequent events from the corresponding block.
- Consumers can continue to subscribe to the events published by the producer after obtaining the 53rd and subsequent events. That is, at this time, the producer publishes the 101st event, and the consumer subscribes to the published 101st event.
- Step 301 Receive an acquisition request sent by a consumer.
- step 302 it is judged whether there is a subject to which the event to be obtained belongs in the blockchain system, and if so, it proceeds to step 303, otherwise, a message indicating that the subscription failed is returned to the consumer.
- step 303 it is judged whether the event identifier is included in the acquisition request, if yes, go to step 304; otherwise, go to step 306.
- the acquisition request sent by the consumer is used to acquire real-time events or historical events. If the acquisition request includes an event identifier, it means that the acquisition request is used to acquire historical events; otherwise, it means that the acquisition request is used to acquire real-time events.
- the event identifier may be an event identifier of an acquired event, which is used to instruct the server to acquire an event under the same subject and published in the blockchain system after the acquired event according to the event identifier of the acquired event.
- Step 304 Determine the historical block in which the event to be obtained is located from the subject contract of the subject.
- the historical block where the event to be obtained is located is determined from the subject contract of the subject.
- the event identifiers of the acquired events the event identifiers of all the events published in the blockchain system after the acquired events under the same subject can be determined as the event identifiers of the events to be acquired, and the pending events can be further determined. Get the historical block where the event is located.
- Step 305 Obtain the event to be obtained from the historical block.
- all transaction logs in the historical block can be obtained, and the transaction log storing the event to be obtained can be determined from all transaction logs, and the to-be-obtained event can be determined from it event.
- Step 306 After determining that there is a newly added block in the blockchain system, obtain the to-be-obtained event from the newly added block.
- Step 307 Return the to-be-obtained event to the consumer.
- step 305 the server obtains the event to be obtained, and after sending the event to be obtained to the consumer in step 307, it can also return to step 306, that is, it is determined that there is a new addition in the blockchain system.
- step 306 After the block, obtain the to-be-obtained event from the newly added block, which is equivalent to obtaining the real-time event corresponding to the corresponding topic after obtaining the historical event and returning it to the consumer.
- the event identifier of each event is recorded in the theme contract.
- the event identifier in the theme contract is written into the theme contract after the event issued by the producer is recorded by the blockchain system.
- the flowchart shown in FIG. 4 can be used, which involves the server and the blockchain system.
- Step 401 The server receives the publishing request.
- the publishing request may be sent by the producer to the server, and may include the event to be published, and the publishing request is used to instruct the server to write the event to be published into the blockchain system.
- Step 402 The server generates a transaction request according to the event to be published.
- the subject contract corresponding to each subject is stored in the blockchain system.
- the server After the server receives the publishing request, it can determine the event to be published in the blockchain system according to the subject of the event to be published in the publishing request.
- the subject contract address corresponding to the subject that is, the contract address of the subject contract to be called by the blockchain system.
- the server can obtain the correspondence between each subject in the blockchain system and the subject contract address, and determine according to the correspondence The subject contract address, and a transaction request that records the event to be published and the subject contract address.
- the correspondence between each topic and the topic contract address can be stored locally on the server, or can be stored in the blockchain system in the form of a contract.
- a system contract is established in the blockchain system. To store the correspondence between each subject and subject contract address.
- Step 403 The server sends the transaction request to the blockchain system.
- Step 404 The blockchain system calls the theme contract corresponding to the theme to which the event to be published belongs.
- the blockchain system calls the subject contract corresponding to the subject of the event to be published, so as to write the transaction log recording the event to be published into the specific block of the blockchain system and the specific block The location of the block is recorded in the subject contract.
- step 405 the blockchain system generates a transaction log recording the events to be published and stores the transaction log in the block.
- the transaction log can record events to be published, such as the subject of the event to be published, the content of the event, etc., and of course, it can also record the relevant parameters of the event to be published, such as the event identifier and producer identifier of the event to be published. Further, in the event identification of the transaction log, not only the serial number written according to the subject can be recorded, but also the identification number of the block in which the transaction log is located in the entire blockchain system, that is, the event identification of the transaction log Including event sequence number and block height, where the event sequence number is used to characterize the publishing sequence of the event within the subject, and the block height is used to indicate the block where the event is stored.
- the blockchain system generates a transaction log that records the event to be released, which can be understood as the release of the event to be released. After the block chain system generates the transaction log, the transaction log is stored in the block chain system, and the pending events in the transaction log will not be easily tampered with.
- step 406 the blockchain system records the location of the block storing the event to be published in the subject contract.
- a Vector array can be set in the theme contract, and the Vector array is used to store the event identifier of the event to be published.
- the blockchain system calls the subject contract of the subject to which the event to be published belongs, and not only writes the event to be published into the transaction log, but also sequentially inserts a piece of data in the Vector array of the subject contract. The location of the block where the event was posted.
- the mapping structure Mapping can also be used instead of the array structure Vector, where the Key of the Mapping is the event sequence number.
- the server after the server receives the acquisition request, it can acquire the subject contract of the subject of the event to be acquired from the blockchain system according to the subject to which the event to be acquired in the acquisition request belongs.
- the subject contract records the event and is stored in the block.
- the server can determine the block location of the event to be obtained in the blockchain system from the subject contract, and then can determine the event to be obtained from the specific block without traversing the entire blockchain system Each of the blocks improves the efficiency of obtaining events on specific topics.
- FIG. 5 exemplarily shows a block chain-based event subscription device provided by an embodiment of the present invention.
- the event subscription device can execute the flow of the above event subscription method.
- the device includes:
- the transceiver unit 501 is configured to receive an acquisition request; the acquisition request is used to instruct the processing unit 502 to acquire the event to be acquired from the blockchain system;
- the processing unit 502 is configured to obtain the subject contract of the subject to which the event to be obtained belongs from the blockchain system according to the subject to which the event to be obtained belongs; the blockchain system stores the subject corresponding to each subject Subject contract; the subject contract records the block location of each event stored in the blockchain system;
- the processing unit 502 is further configured to determine the location of the block where the event to be obtained is stored from the subject contract of the subject to which the event to be obtained belongs, and obtain the block to be obtained from the block corresponding to the block location event.
- the event identification of each event is recorded in the subject contract; the event identification includes the event sequence number and the block height; the event sequence number is used to characterize the publishing sequence of the event in the subject; the zone The block height is used to indicate the block where the event is stored.
- the acquisition request includes an event identifier of the acquired event;
- the to-be-acquired event is an event of the same subject that is published after the acquired event;
- the processing unit 502 is specifically configured to:
- the event identifier of the to-be-obtained event is determined from the subject contract of the subject to which the to-be-obtained event belongs, so as to obtain each area of the to-be-obtained event stored in the blockchain system Block location.
- processing unit 502 is further configured to:
- a transaction request is generated and sent to the blockchain system; the transaction request is used to instruct the blockchain system to call the theme contract corresponding to the theme of the event to be published; the theme contract Used to generate a transaction log recording the event to be published and store the transaction log in a block; the subject contract is also used to record the location of the block storing the event to be published in the subject contract Inside.
- an embodiment of the present invention also provides a computing device, as shown in FIG. 6, including:
- the memory 601 is used to store program instructions
- the processor 602 is configured to call the program instructions stored in the memory, and execute the above event subscription method according to the obtained program.
- embodiments of the present invention also provide a computer-readable non-volatile storage medium, including computer-readable instructions.
- the computer reads and executes the computer-readable instructions, the computer executes the above event subscription.
- the embodiments of the present invention also provide a computer program product.
- the computer program product includes a computer program stored on a computer-readable non-volatile storage medium.
- the computer program includes program instructions. When the program instructions are executed by a computer, the computer executes the above event subscription method.
- These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing equipment to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction device.
- the device implements the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
- These computer program instructions can also be loaded on a computer or other programmable data processing equipment, so that a series of operation steps are executed on the computer or other programmable equipment to produce computer-implemented processing, so as to execute on the computer or other programmable equipment.
- the instructions provide steps for implementing functions specified in a flow or multiple flows in the flowchart and/or a block or multiple blocks in the block diagram.
Landscapes
- Engineering & Computer Science (AREA)
- Business, Economics & Management (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Accounting & Taxation (AREA)
- General Physics & Mathematics (AREA)
- Finance (AREA)
- General Business, Economics & Management (AREA)
- Strategic Management (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- General Engineering & Computer Science (AREA)
- Computational Linguistics (AREA)
- Fuzzy Systems (AREA)
- Mathematical Physics (AREA)
- Probability & Statistics with Applications (AREA)
- Computer Security & Cryptography (AREA)
- Software Systems (AREA)
- Development Economics (AREA)
- Economics (AREA)
- Marketing (AREA)
- Technology Law (AREA)
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
Abstract
一种基于区块链的事件订阅的方法及装置,方法包括:服务器接收获取请求(201),根据待获取事件所属主题,从区块链系统中获取待获取事件所属主题的主题合约(202),从待获取事件所属主题的主题合约中确定待获取事件存储的区块位置,并从区块位置对应的区块中获取待获取事件(203)。该方法通过从主题合约中确定待获取事件的区块位置,提高了获取特定主题事件的效率。
Description
相关申请的交叉引用
本申请要求在2019年04月22日提交中国专利局、申请号为201910321654.7、申请名称为“一种基于区块链的事件订阅的方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
本发明实施例涉及金融科技(Fintech)领域,尤其涉及一种基于区块链(Blockchain)的事件订阅的方法及装置。
区块链是由一系列区块组成的一条链,每个区块记录本块的数据及上一块的哈希值,所有区块通过这种方式前后相继组成一条链。区块链所基于的密码学技术和去中心化思想使链上的历史信息无法被篡改。
随着计算机技术的发展,越来越多的技术应用在金融领域,传统金融业正在逐步向金融科技(Finteh)转变,区块链技术也不例外,但由于金融、支付行业的安全性、实时性要求,也对技术提出的更高的要求。在事件发布订阅中,生产者将待发布事件写入区块链系统,消费者从区块链系统读取待获取事件,由于区块链上信息的不易篡改性,保障消费者准确读取生产者写入区块链系统中的事件。
现有技术中,消费者在获取生产者写入区块链系统中的特定主题事件时,需要顺着区块链的方向从前往后查找下去,从而遍历整个区块链系统,并从中获取到该特定主题事件。但当区块链系统中存在大量其他主题事件时,采用遍历方式获取特定主题事件的效率较低。
发明内容
本发明实施例提供一种基于区块链的事件订阅的方法及装置,用于提高获取特定主题事件的效率。
本发明实施例提供的一种基于区块链的事件订阅的方法,包括:
服务器接收获取请求;所述获取请求用于指示所述服务器从区块链系统中获取待获取事件;
所述服务器根据所述待获取事件所属主题,从所述区块链系统中获取所述待获取事件所属主题的主题合约;所述区块链系统中存储有各主题对应的主题合约;所述主题合约内记录有各事件存储于所述区块链系统中的区块位置;
所述服务器从所述待获取事件所属主题的主题合约中确定所述待获取事件存储的区块位置,并从所述区块位置对应的区块中获取所述待获取事件。
上述技术方案中,服务器接收获取请求后,可以根据获取请求中的待获取事件所属主题,从区块链系统中获取待获取事件所属主题的主题合约,该主题合约中记录有事件存储于区块链系统中的区块位置,服务器可以从主题合约中确定出待获取事件在区块链系统中的区块位置,进而可以从具体区块中确定出待获取事件,无需遍历整个区块链系统的每个区块,提高了获取特定主题事件的效率。
可选的,所述主题合约内记录有各事件的事件标识;所述事件标识包括事件序列号和区块高度;所述事件序列号用于表征事件在所属主题内的发布顺序;所述区块高度为存储事件的区块。
上述技术方案中,主题合约中记录各事件的事件标识,事件标识包括事件序列号,用于表征事件在所属主题内的发布顺序。服务器可以将事件标识按事件的发布顺序写入主题合约,也就是说,主题合约的事件标识是按顺序存储的。当服务器需要获取特定主题的某序列号区间的事件时,服务器可直接根据序列号区间按顺序查找主题合约,并获取待获取事件的事件标识,该方案有效提高获取特定主题内某序列号区间的事件的效率。
可选的,所述获取请求中包括已获取事件的事件标识;所述待获取事件为所述已获取事件之后发布的同一主题的事件;
所述服务器从所述待获取事件所属主题的主题合约中确定所述待获取事件存储的区块位置,包括:
所述服务器根据所述已获取事件的事件标识,从所述待获取事件所属主题的主题合约中确定所述待获取事件的事件标识,从而获取所述待获取事件在所述区块链系统中存储的各区块位置。
上述技术方案中,服务器可以获取已获取事件之后的所有事件,服务器根据该已获取事件的事件标识,从待获取事件所属主题的主题合约中确定待获取事件的事件标识,具体的,可以根据已获取事件的事件标识的序列号获取该序列号之后的所有序列号的事件标识,并将其作为待获取事件的事件标识,进而获取到已获取事件之后的所有事件,满足不同消费者的获取请求。
可选的,还包括:
所述服务器接收发布请求;所述发布请求包括待发布事件;
所述服务器根据所述待发布事件,生成并发送交易请求至所述区块链系统;所述交易请求用于指示所述区块链系统调用所述待发布事件所属主题对应的主题合约;所述主题合约用于生成记录有所述待发布事件的交易日志并将所述交易日志存储于区块中;所述主题合约还用于将存储有所述待发布事件的区块位置记录于所述主题合约内。
上述技术方案中,服务器还可以接收生产者的发布请求,并根据发布请求中的待发布事件,生成交易请求发送至区块链系统,区块链系统调用待发布事件所属主题的主题合约,生成交易日志以及将存储待发布事件的区块位置记录在主题合约中,以使得服务器在接收到获取请求后,可以从待获取事件所属主题的主题合约中确定出待获取事件的区块位置。
相应的,本发明实施例还提供了一种基于区块链的事件订阅的装置,包括:
收发单元,用于接收获取请求;所述获取请求用于指示处理单元从区块 链系统中获取待获取事件;
所述处理单元,用于根据所述待获取事件所属主题,从所述区块链系统中获取所述待获取事件所属主题的主题合约;所述区块链系统中存储有各主题对应的主题合约;所述主题合约内记录有各事件存储于所述区块链系统中的区块位置;
所述处理单元,还用于从所述待获取事件所属主题的主题合约中确定所述待获取事件存储的区块位置,并从所述区块位置对应的区块中获取所述待获取事件。
可选的,所述主题合约内记录有各事件的事件标识;所述事件标识包括事件序列号和区块高度;所述事件序列号用于表征事件在所属主题内的发布顺序;所述区块高度用于指示存储事件的区块。
可选的,所述获取请求中包括已获取事件的事件标识;所述待获取事件为所述已获取事件之后发布的同一主题的事件;
所述处理单元具体用于:
根据所述已获取事件的事件标识,从所述待获取事件所属主题的主题合约中确定所述待获取事件的事件标识,从而获取所述待获取事件在所述区块链系统中存储的各区块位置。
可选的,所述处理单元还用于:
控制所述收发单元接收发布请求;所述发布请求包括待发布事件;
根据所述待发布事件,生成并发送交易请求至所述区块链系统;所述交易请求用于指示所述区块链系统调用所述待发布事件所属主题对应的主题合约;所述主题合约用于生成记录有所述待发布事件的交易日志并将所述交易日志存储于区块中;所述主题合约还用于将存储有所述待发布事件的区块位置记录于所述主题合约内。
相应的,本发明实施例还提供了一种计算设备,包括:
存储器,用于存储程序指令;
处理器,用于调用所述存储器中存储的程序指令,按照获得的程序执行 上述事件订阅的方法。
相应的,本发明实施例还提供了一种计算机可读非易失性存储介质,包括计算机可读指令,当计算机读取并执行所述计算机可读指令时,使得计算机执行上述事件订阅的方法。
相应的,本发明实施例还提供了一种计算机程序产品,所述计算机程序产品包括存储在计算机可读非易失性存储介质上的计算机程序,所述计算机程序包括程序指令,当所述程序指令被计算机执行时,使所述计算机执行上述事件订阅的方法。
本发明实施例中,服务器接收获取请求后,可以根据获取请求中的待获取事件所属主题,从区块链系统中获取待获取事件所属主题的主题合约,该主题合约中记录有事件存储于区块链系统中的区块位置,服务器可以从主题合约中确定出待获取事件在区块链系统中的区块位置,进而可以从具体区块中确定出待获取事件,无需遍历整个区块链系统的每个区块,提高了获取特定主题事件的效率。
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简要介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域的普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为本发明实施例提供的一种系统架构的示意图;
图2为本发明实施例提供的一种事件订阅的方法的流程示意图;
图3为本发明实施例提供的另一种事件订阅的方法的流程示意图;
图4本发明实施例提供的一种事件发布的方法的流程示意图;
图5为本发明实施例提供的一种事件订阅的装置的结构示意图;
图6为本发明实施例提供的一种计算设备的结构示意图。
为了使本发明的目的、技术方案和优点更加清楚,下面将结合附图对本发明作进一步地详细描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其它实施例,都属于本发明保护的范围。
图1示例性的示出了本发明实施例提供的基于区块链的事件订阅的方法所适用的系统架构,该系统架构可以包括生产者100、发布服务器200、区块链系统300、订阅服务器400、消费者500。其中,生产者100用于生成待发布事件,发布服务器200用于将待发布事件写入区块链系统300中,消费者500用于通过订阅服务器400从区块链系统300中订阅事件。
区块链系统300中存储有各主题对应的主题合约,生产者100需要发布事件时,将待发布事件发送至发布服务器200,发布服务器200根据待发布事件生成交易请求,发布服务器200将交易请求发送至区块链系统300,区块链系统300根据交易请求执行待发布事件所属主题的主题合约,将待发布事件记录在区块链系统300中,同时在待发布事件所属主题的主题合约中记录待发布事件的事件标识,可选的,事件标识包括事件序列号和区块高度,事件序列号用于表征事件在所属主题内的发布顺序,区块高度用于指示存储事件的区块。
也就是说,区块链系统300在将待发布事件记录在区块链系统300中时,还会将待发布事件所存储在区块链系统300中的区块位置记录在待发布事件所属主题的主题合约中,相当于,区块链系统300的主题合约中记录有各事件存储于区块链系统300中的区块位置。
消费者500需要获取事件时,向订阅服务器400发送获取请求,订阅服务器400根据接收到的获取请求从区块链系统300中确定出获取请求对应的事件,反馈至消费者500,以完成消费者500的事件订阅。
本系统架构中的发布服务器200和订阅服务器400在物理实体上可以为 一个服务器,该服务器完成发布和订阅功能,也可以为两个分开的服务器,分别完成发布功能和订阅功能,在此不做限制。为方便描述,现将下述实施例中涉及事件订阅的服务器以及涉及事件发布的服务器均称为服务器。
图2示例性的示出了本发明实施例提供的一种基于区块链的事件订阅的方法的流程,该流程具体包括:
步骤201,服务器接收获取请求。
本发明实施例中,获取请求可以是消费者向服务器发送的,用于指示服务器从区块链系统中获取待获取事件。获取请求可以包括待获取事件所属主题,用于服务器根据待获取事件所属主题确定待获取事件所属主题的主题合约,也可以包括已获取事件的事件标识,用于服务器根据已获取事件的事件标识从区块链系统中获取已获取事件之后生产者发布的同一主题的事件。
步骤202,服务器根据待获取事件所属主题,从区块链系统中获取待获取事件所属主题的主题合约。
此处,由于区块链系统中存储有各主题对应的主题合约,如区块链系统中部署主题合约A、B、C,分别对应主题a、b、c。服务器确定待获取事件所属主题为主题a,则可以从区块链系统中获取主题a的主题合约A。
步骤203,服务器从待获取事件所属主题的主题合约中确定待获取事件存储的区块位置,并从区块位置对应的区块中获取待获取事件。
具体的,主题合约中存储各事件的区块位置,即服务器通过查询主题合约中的内容,即可以确定出待获取事件所在区块链系统中的区块位置,进一步从对应的区块中获取到待获取事件。
具体实现中,服务器接收到的获取请求中包括已获取事件的事件标识,获取请求用于指示服务器从区块链系统中获取已获取事件之后发布的同一主题的事件,也就是说,待获取事件是已获取事件之后发布的同一主题的事件。服务器根据已获取事件的事件标识,从待获取事件所属主题的主题合约中确定待获取事件的事件标识,从而获取待获取事件在区块链系统中存储的各区块位置,并从区块位置对应的区块中获取待获取事件。
举例来说,生产者发布主题a对应的20个事件至区块链系统中,区块链系统的主题合约A中存储有20个事件中各事件的事件标识,事件标识包括事件序列号和区块高度,如某事件的事件标识为“a2,block30”,其中,“a2”代表该事件是发布于主题A中的第二个事件,“block30”代表该事件存储在区块高度为30的区块中。服务器接收的获取请求中包括已获取事件的事件标识,假设为“a4,block34”,则待获取事件是在事件标识为“a4,block34”的事件之后发布的A主题的事件,服务器可以根据“a4,block34”从主题合约A中确定出待获取事件的事件标识,如“a5,block34”、“a6,block36”、……、“a20,block98”,从而确定出待获取事件中各事件存储于区块链系统中的区块位置,如序列号为“a5”的待获取事件存储在区块链系统中区块高度为34的区块中,从而进一步从区块中获取到该序列号为“a5”的待获取事件。
需要说明的是,事件标识包括事件序列号,用于表征事件在所属主题内的发布顺序,事件序列号可以为相同主题内根据发布顺序确定的由1至n的序列号,也可以为不同主题内根据发布顺序确定的由1至n的序列号,当然,还可以是相同主题或不同主题内事件发布的时间,也就是说,本方案中任何可以表征事件在所属主题内的发布顺序的参数都可以理解为事件序列号。同理,事件标识包括区块高度,区块高度用于指示存储事件的区块,即可以根据区块高度将待获取事件定位到区块链系统中的具体区块,区块高度也可以理解为区块链系统中区块的标识号、编号等。
为了更好的理解本发明中服务器根据已获取事件的事件标识获取待获取事件的实现方式,下面在具体场景下举例说明,该场景为消费者订阅某生产者发布的特定主题的事件,即生产者每发布一条该特定主题的事件至区块链系统中,消费者都可以从区块链系统中订阅到该事件,但是由于消费者自身故障原因,导致中断获取生产者发布的特定主题的事件。
举例来说,生产者从某时间点发布主题a的事件至今,共发布100条事件,消费者订阅生产者发布的主题a的事件,由于消费者自身故障原因,仅仅订阅到第52条事件之后,则无法获取第53条以及第53条之后的事件,则 可以向服务器发送获取请求,该获取请求中包括已获取事件(第52条事件)的事件标识,服务器根据已获取事件(第52条事件)的事件标识,获取第53条以及第53条之后的事件的事件标识,进一步从对应的区块中获取第53条以及第53条之后的事件。消费者在获取到第53条以及第53条之后的事件之后,可以继续订阅生产者发布的事件,即此时,生产者发布第101条事件,消费者订阅该发布的第101条事件。
结合上述描述,提供一种具体的服务器订阅方式,可以如图3示出的流程图。该流程可以以服务器为执行主体进行说明。
步骤301,接收消费者发送的获取请求。
步骤302,判断区块链系统是否存在待获取事件所属主题,若是,则转向步骤303,否则,向消费者返回订阅失败的消息。
步骤303,判断获取请求中是否包括事件标识,若是,则转向步骤304,否则,转向步骤306。
相当于判断消费者发送的获取请求是用于获取实时事件还是历史事件,若获取请求中包括事件标识,则代表获取请求用于获取历史事件,否则,代表获取请求用于获取实时事件。此处,事件标识可以是已获取事件的事件标识,用于指示服务器根据已获取事件的事件标识,获取同一主题下的在已获取事件之后发布于区块链系统中的事件。
步骤304,从所属主题的主题合约中确定待获取事件所在的历史区块。
根据事件标识,从所属主题的主题合约中确定待获取事件所在的历史区块。此处,可以根据已获取事件的事件标识,确定出同一主题下的在已获取事件之后发布于区块链系统中的所有事件的事件标识,作为待获取事件的事件标识,进一步可以确定出待获取事件所在的历史区块,此处,同一主题下的在已获取事件之后发布于区块链系统中的事件可以为多个,即待获取事件可以为多个。
步骤305,从历史区块中获取待获取事件。
在确定出待获取事件所在的历史区块后,可以获取该历史区块中的全部 交易日志,并从全部交易日志中确定出存储有该待获取事件的交易日志,并从中确定出该待获取事件。
步骤306,在确定区块链系统中存在新增区块后,从新增区块中获取待获取事件。
步骤307,返回待获取事件至消费者。
需要说明的是,在步骤305中,服务器获取到待获取事件,并在步骤307中将待获取事件发送至消费者之后,还可以返回至步骤306,即在确定区块链系统中存在新增区块后,从新增区块中获取待获取事件,相当于在获取历史事件之后,继续获取相应主题对应的实时事件返回至消费者。
本发明实施例中,主题合约内记录有各事件的事件标识,该主题合约内的事件标识是区块链系统将生产者发布的事件记录在区块链系统之后,写入主题合约中的。具体的,可以如图4示出的流程图,该流程图涉及服务器和区块链系统。
步骤401,服务器接收发布请求。
本发明实施例中,发布请求可以是生产者向服务器发送的,可以包括待发布事件,发布请求用于指示服务器将待发布事件写入区块链系统中。
步骤402,服务器根据待发布事件,生成交易请求。
本发明实施例中,区块链系统中存储有各主题对应的主题合约,当服务器接收到发布请求之后,可以根据发布请求中的待发布事件所属主题,确定出区块链系统中待发布事件所属主题对应的主题合约地址,即区块链系统待调用的主题合约的合约地址,具体的,服务器可以获取到区块链系统中各主题与主题合约地址的对应关系,并根据对应关系确定出主题合约地址,以及生成记录有待发布事件和主题合约地址的交易请求。此处,各主题与主题合约地址的对应关系可以存储在服务器本地,也可以以合约的形式存储在区块链系统中,示例性的,在区块链系统中建立系统合约,该系统合约用于存储各主题与主题合约地址的对应关系。
步骤403,服务器将交易请求发送至区块链系统。
步骤404,区块链系统调用待发布事件所属主题对应的主题合约。
区块链系统根据交易请求中的主题合约地址,调用待发布事件所属主题对应的主题合约,从而将记录有待发布事件的交易日志写入区块链系统的具体区块中以及将该具体区块的区块位置记录于主题合约内。
步骤405,区块链系统生成记录有待发布事件的交易日志并将交易日志存储于区块中。
交易日志中可以记录有待发布事件,如记录有待发布事件所属主题、事件内容等,当然还可以记录待发布事件的相关参数,如待发布事件的事件标识、生产者标识等。进一步的,在交易日志的事件标识中,不仅可以记录依据主题编写的序列号,还可以记录该交易日志所在区块在整个区块链系统中的标识号,也就是说,交易日志的事件标识包括事件序列号和区块高度,其中,事件序列号用于表征事件在所属主题内的发布顺序,区块高度用于指示存储事件的区块。区块链系统生成记录有待发布事件的交易日志,可以理解为该待发布事件已经发布完成。区块链系统生成交易日志后,将交易日志存储至区块链系统中,则该交易日志中的待发布事件不会被轻易篡改。
步骤406,区块链系统将存储有待发布事件的区块位置记录于主题合约内。
本发明实施例中,可以在主题合约中设置Vector数组,该Vector数组用于存储待发布事件的事件标识。当有事件发布时,区块链系统调用待发布事件所属主题的主题合约,不仅将待发布事件写入交易日志中,还在主题合约的Vector数组里顺序插入一份数据,该数据即记录有待发布事件的区块位置。此外,还可以采用映射结构Mapping代替数组结构Vector,其中,Mapping的Key为事件序列号。
本发明实施中,服务器接收获取请求后,可以根据获取请求中的待获取事件所属主题,从区块链系统中获取待获取事件所属主题的主题合约,该主题合约中记录有事件存储于区块链系统中的区块位置,服务器可以从主题合约中确定出待获取事件在区块链系统中的区块位置,进而可以从具体区块中确定出待获取事件,无需遍历整个区块链系统的每个区块,提高了获取特定 主题事件的效率。
基于同一发明构思,图5示例性的示出了本发明实施例提供的一种基于区块链的事件订阅的装置,该事件订阅的装置可以执行上述事件订阅的方法的流程。
该装置包括:
收发单元501,用于接收获取请求;所述获取请求用于指示处理单元502从区块链系统中获取待获取事件;
所述处理单元502,用于根据所述待获取事件所属主题,从所述区块链系统中获取所述待获取事件所属主题的主题合约;所述区块链系统中存储有各主题对应的主题合约;所述主题合约内记录有各事件存储于所述区块链系统中的区块位置;
所述处理单元502,还用于从所述待获取事件所属主题的主题合约中确定所述待获取事件存储的区块位置,并从所述区块位置对应的区块中获取所述待获取事件。
可选的,所述主题合约内记录有各事件的事件标识;所述事件标识包括事件序列号和区块高度;所述事件序列号用于表征事件在所属主题内的发布顺序;所述区块高度用于指示存储事件的区块。
可选的,所述获取请求中包括已获取事件的事件标识;所述待获取事件为所述已获取事件之后发布的同一主题的事件;
所述处理单元502具体用于:
根据所述已获取事件的事件标识,从所述待获取事件所属主题的主题合约中确定所述待获取事件的事件标识,从而获取所述待获取事件在所述区块链系统中存储的各区块位置。
可选的,所述处理单元502还用于:
控制所述收发单元501接收发布请求;所述发布请求包括待发布事件;
根据所述待发布事件,生成并发送交易请求至所述区块链系统;所述交易请求用于指示所述区块链系统调用所述待发布事件所属主题对应的主题合 约;所述主题合约用于生成记录有所述待发布事件的交易日志并将所述交易日志存储于区块中;所述主题合约还用于将存储有所述待发布事件的区块位置记录于所述主题合约内。
基于同一发明构思,本发明实施例还提供了一种计算设备,如图6所示,包括:
存储器601,用于存储程序指令;
处理器602,用于调用所述存储器中存储的程序指令,按照获得的程序执行上述事件订阅的方法。
基于同一发明构思,本发明实施例还提供了一种计算机可读非易失性存储介质,包括计算机可读指令,当计算机读取并执行所述计算机可读指令时,使得计算机执行上述事件订阅的方法。
基于同一发明构思,本发明实施例还提供了一种计算机程序产品,所述计算机程序产品包括存储在计算机可读非易失性存储介质上的计算机程序,所述计算机程序包括程序指令,当所述程序指令被计算机执行时,使所述计算机执行上述事件订阅的方法。
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
尽管已描述了本发明的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例作出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本发明范围的所有变更和修改。
显然,本领域的技术人员可以对本发明进行各种改动和变型而不脱离本发明的精神和范围。这样,倘若本发明的这些修改和变型属于本发明权利要求及其等同技术的范围之内,则本发明也意图包括这些改动和变型在内。
Claims (11)
- 一种基于区块链的事件订阅的方法,其特征在于,包括:服务器接收获取请求;所述获取请求用于指示所述服务器从区块链系统中获取待获取事件;所述服务器根据所述待获取事件所属主题,从所述区块链系统中获取所述待获取事件所属主题的主题合约;所述区块链系统中存储有各主题对应的主题合约;所述主题合约内记录有各事件存储于所述区块链系统中的区块位置;所述服务器从所述待获取事件所属主题的主题合约中确定所述待获取事件存储的区块位置,并从所述区块位置对应的区块中获取所述待获取事件。
- 如权利要求1所述的方法,其特征在于,所述主题合约内记录有各事件的事件标识;所述事件标识包括事件序列号和区块高度;所述事件序列号用于表征事件在所属主题内的发布顺序;所述区块高度用于指示存储事件的区块。
- 如权利要求2所述的方法,其特征在于,所述获取请求中包括已获取事件的事件标识;所述待获取事件为所述已获取事件之后发布的同一主题的事件;所述服务器从所述待获取事件所属主题的主题合约中确定所述待获取事件存储的区块位置,包括:所述服务器根据所述已获取事件的事件标识,从所述待获取事件所属主题的主题合约中确定所述待获取事件的事件标识,从而获取所述待获取事件在所述区块链系统中存储的各区块位置。
- 如权利要求1至3任一项所述的方法,其特征在于,还包括:所述服务器接收发布请求;所述发布请求包括待发布事件;所述服务器根据所述待发布事件,生成并发送交易请求至所述区块链系统;所述交易请求用于指示所述区块链系统调用所述待发布事件所属主题对 应的主题合约;所述主题合约用于生成记录有所述待发布事件的交易日志并将所述交易日志存储于区块中;所述主题合约还用于将存储有所述待发布事件的区块位置记录于所述主题合约内。
- 一种基于区块链的事件订阅的装置,其特征在于,包括:收发单元,用于接收获取请求;所述获取请求用于指示处理单元从区块链系统中获取待获取事件;所述处理单元,用于根据所述待获取事件所属主题,从所述区块链系统中获取所述待获取事件所属主题的主题合约;所述区块链系统中存储有各主题对应的主题合约;所述主题合约内记录有各事件存储于所述区块链系统中的区块位置;所述处理单元,还用于从所述待获取事件所属主题的主题合约中确定所述待获取事件存储的区块位置,并从所述区块位置对应的区块中获取所述待获取事件。
- 如权利要求5所述的装置,其特征在于,所述主题合约内记录有各事件的事件标识;所述事件标识包括事件序列号和区块高度;所述事件序列号用于表征事件在所属主题内的发布顺序;所述区块高度用于指示存储事件的区块。
- 如权利要求6所述的装置,其特征在于,所述获取请求中包括已获取事件的事件标识;所述待获取事件为所述已获取事件之后发布的同一主题的事件;所述处理单元具体用于:根据所述已获取事件的事件标识,从所述待获取事件所属主题的主题合约中确定所述待获取事件的事件标识,从而获取所述待获取事件在所述区块链系统中存储的各区块位置。
- 如权利要求5至7任一项所述的装置,其特征在于,所述处理单元还用于:控制所述收发单元接收发布请求;所述发布请求包括待发布事件;根据所述待发布事件,生成并发送交易请求至所述区块链系统;所述交易请求用于指示所述区块链系统调用所述待发布事件所属主题对应的主题合约;所述主题合约用于生成记录有所述待发布事件的交易日志并将所述交易日志存储于区块中;所述主题合约还用于将存储有所述待发布事件的区块位置记录于所述主题合约内。
- 一种计算设备,其特征在于,包括:存储器,用于存储程序指令;处理器,用于调用所述存储器中存储的程序指令,按照获得的程序执行权利要求1至4任一项所述的方法。
- 一种计算机可读非易失性存储介质,其特征在于,包括计算机可读指令,当计算机读取并执行所述计算机可读指令时,使得计算机执行如权利要求1至4任一项所述的方法。
- 一种计算机程序产品,其特征在于,所述计算机程序产品包括存储在计算机可读非易失性存储介质上的计算机程序,所述计算机程序包括程序指令,当所述程序指令被计算机执行时,使得计算机执行如权利要求1至4任一项所述的方法。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201910321654.7 | 2019-04-22 | ||
| CN201910321654.7A CN110083629B (zh) | 2019-04-22 | 2019-04-22 | 一种基于区块链的事件订阅的方法及装置 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2020215925A1 true WO2020215925A1 (zh) | 2020-10-29 |
Family
ID=67415991
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2020/079361 Ceased WO2020215925A1 (zh) | 2019-04-22 | 2020-03-13 | 一种基于区块链的事件订阅的方法及装置 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN110083629B (zh) |
| WO (1) | WO2020215925A1 (zh) |
Cited By (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN112199221A (zh) * | 2020-12-04 | 2021-01-08 | 杭州趣链科技有限公司 | 事件推送方法、系统、区块链平台、合约调用端及介质 |
| CN116340011A (zh) * | 2021-12-22 | 2023-06-27 | 中国人民银行数字货币研究所 | 一种基于区块链的事件订阅方法、装置及系统 |
| CN116775756A (zh) * | 2023-05-06 | 2023-09-19 | 中国建设银行股份有限公司 | 基于Uliweb的数据同步方法、装置及系统 |
Families Citing this family (8)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110083629B (zh) * | 2019-04-22 | 2024-05-07 | 深圳前海微众银行股份有限公司 | 一种基于区块链的事件订阅的方法及装置 |
| CN114553953A (zh) * | 2019-08-22 | 2022-05-27 | 杭州趣链科技有限公司 | 一种区块链的java智能合约的事件推送方法 |
| US10936581B2 (en) | 2019-08-30 | 2021-03-02 | Advanced New Technologies Co., Ltd. | Blockchain transaction processing method and apparatus |
| CN110633309A (zh) * | 2019-08-30 | 2019-12-31 | 阿里巴巴集团控股有限公司 | 一种区块链交易处理方法及装置 |
| CN113205424B (zh) * | 2020-10-28 | 2023-08-25 | 支付宝(杭州)信息技术有限公司 | 在区块链中部署和调用合约的方法和装置 |
| CN112948342A (zh) * | 2021-02-25 | 2021-06-11 | 杭州沃趣科技股份有限公司 | 一种基于日志解析系统的数据处理方法 |
| CN113591130B (zh) * | 2021-08-17 | 2025-06-20 | 腾讯科技(深圳)有限公司 | 基于区块链的数据处理方法、装置、电子设备及存储介质 |
| CN116095081A (zh) * | 2021-11-05 | 2023-05-09 | 腾讯科技(深圳)有限公司 | 基于区块链系统的事件处理方法及装置、设备、介质 |
Citations (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107017992A (zh) * | 2017-03-29 | 2017-08-04 | 杭州秘猿科技有限公司 | 一种基于双链结构的高性能联盟区块链 |
| CN108510389A (zh) * | 2018-03-30 | 2018-09-07 | 深圳前海微众银行股份有限公司 | 基于区块链的智能合约调用方法、设备及可读存储介质 |
| CN109274752A (zh) * | 2018-10-10 | 2019-01-25 | 腾讯科技(深圳)有限公司 | 区块链数据的访问方法及装置、电子设备、存储介质 |
| CN109271362A (zh) * | 2018-08-31 | 2019-01-25 | 上海雄九投资控股(集团)有限公司 | 一种基于区块链的数据处理系统 |
| WO2019042754A1 (en) * | 2017-09-04 | 2019-03-07 | Siemens Aktiengesellschaft | DATA COMMUNICATION SYSTEM BASED ON A FILTER UNIT COMPRISING A BLOCK CHAIN PLATFORM |
| CN110083629A (zh) * | 2019-04-22 | 2019-08-02 | 深圳前海微众银行股份有限公司 | 一种基于区块链的事件订阅的方法及装置 |
| CN110097363A (zh) * | 2019-04-12 | 2019-08-06 | 深圳前海微众银行股份有限公司 | 一种基于区块链的事件发布、事件订阅的方法及装置 |
Family Cites Families (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101677327B (zh) * | 2008-09-16 | 2013-11-06 | 华为技术有限公司 | 一种位置相关信息订阅方法、系统及装置 |
| CN101925047B (zh) * | 2009-06-11 | 2014-09-10 | 中兴通讯股份有限公司 | 用户数据融合网络系统及订阅通知的实现方法 |
| US11049104B2 (en) * | 2017-04-05 | 2021-06-29 | Samsung Sds Co., Ltd. | Method of processing payment based on blockchain and apparatus thereof |
| CN107943951B (zh) * | 2017-11-24 | 2020-08-11 | 中钞信用卡产业发展有限公司杭州区块链技术研究院 | 一种区块链业务信息的检索方法及系统 |
| CN108282529B (zh) * | 2018-01-23 | 2021-08-24 | 百度在线网络技术(北京)有限公司 | 发布和订阅数据的系统、方法和装置 |
| CN110400221B (zh) * | 2018-09-29 | 2021-09-10 | 腾讯科技(深圳)有限公司 | 数据处理方法、系统、存储介质及计算机设备 |
-
2019
- 2019-04-22 CN CN201910321654.7A patent/CN110083629B/zh active Active
-
2020
- 2020-03-13 WO PCT/CN2020/079361 patent/WO2020215925A1/zh not_active Ceased
Patent Citations (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107017992A (zh) * | 2017-03-29 | 2017-08-04 | 杭州秘猿科技有限公司 | 一种基于双链结构的高性能联盟区块链 |
| WO2019042754A1 (en) * | 2017-09-04 | 2019-03-07 | Siemens Aktiengesellschaft | DATA COMMUNICATION SYSTEM BASED ON A FILTER UNIT COMPRISING A BLOCK CHAIN PLATFORM |
| CN108510389A (zh) * | 2018-03-30 | 2018-09-07 | 深圳前海微众银行股份有限公司 | 基于区块链的智能合约调用方法、设备及可读存储介质 |
| CN109271362A (zh) * | 2018-08-31 | 2019-01-25 | 上海雄九投资控股(集团)有限公司 | 一种基于区块链的数据处理系统 |
| CN109274752A (zh) * | 2018-10-10 | 2019-01-25 | 腾讯科技(深圳)有限公司 | 区块链数据的访问方法及装置、电子设备、存储介质 |
| CN110097363A (zh) * | 2019-04-12 | 2019-08-06 | 深圳前海微众银行股份有限公司 | 一种基于区块链的事件发布、事件订阅的方法及装置 |
| CN110083629A (zh) * | 2019-04-22 | 2019-08-02 | 深圳前海微众银行股份有限公司 | 一种基于区块链的事件订阅的方法及装置 |
Cited By (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN112199221A (zh) * | 2020-12-04 | 2021-01-08 | 杭州趣链科技有限公司 | 事件推送方法、系统、区块链平台、合约调用端及介质 |
| CN112199221B (zh) * | 2020-12-04 | 2021-03-30 | 杭州趣链科技有限公司 | 事件推送方法、系统、区块链平台、合约调用端及介质 |
| CN116340011A (zh) * | 2021-12-22 | 2023-06-27 | 中国人民银行数字货币研究所 | 一种基于区块链的事件订阅方法、装置及系统 |
| CN116775756A (zh) * | 2023-05-06 | 2023-09-19 | 中国建设银行股份有限公司 | 基于Uliweb的数据同步方法、装置及系统 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN110083629B (zh) | 2024-05-07 |
| CN110083629A (zh) | 2019-08-02 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2020215925A1 (zh) | 一种基于区块链的事件订阅的方法及装置 | |
| CN112000703B (zh) | 数据入库处理方法、装置、计算机设备和存储介质 | |
| US20180181751A1 (en) | Anomaly Detection in Distributed Ledger Systems | |
| US11200226B2 (en) | Data read and write method and apparatus, and electronic device | |
| US20160142369A1 (en) | Service addressing in distributed environment | |
| US20210149883A1 (en) | Data structure reading methods and apparatuses, data structure update methods and apparatuses, and electronic devices | |
| WO2021027531A1 (zh) | 一种区块链交易记录的处理方法及装置 | |
| CN110032598A (zh) | 字段更新方法及装置、电子设备 | |
| CN113946552B (zh) | 数据处理方法及电子装置 | |
| CN110097363A (zh) | 一种基于区块链的事件发布、事件订阅的方法及装置 | |
| WO2021259149A1 (zh) | 区块链网络的压力测试方法及装置、系统 | |
| WO2020216077A1 (zh) | 一种区块链事件去重方法、装置、计算机设备及存储介质 | |
| CN115129782A (zh) | 一种分布式数据库的分区级连接方法和装置 | |
| JP2022548638A5 (zh) | ||
| CN110704438A (zh) | 一种区块链中布隆过滤器的生成方法及装置 | |
| CN110069533A (zh) | 一种基于区块链的事件订阅方法及装置 | |
| CN110928941B (zh) | 一种数据分片抽取方法及装置 | |
| WO2020256831A1 (en) | Smart contract information redirect to updated version of smart contract | |
| CN115048372A (zh) | 多流数据的关联方法和关联装置 | |
| CN105468623A (zh) | 数据处理方法及装置 | |
| CN106156185B (zh) | 一种业务请求执行状态的查询方法、装置及系统 | |
| CN104572737B (zh) | 数据存储辅助方法及系统 | |
| CN105989445A (zh) | 规则管理方法及系统 | |
| JP2024504564A5 (zh) | ||
| CN114117526A (zh) | 印鉴信息管理方法、装置、电子设备及计算机存储介质 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 20794579 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 32PN | Ep: public notification in the ep bulletin as address of the adressee cannot be established |
Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205 DATED 02/02/2022) |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 20794579 Country of ref document: EP Kind code of ref document: A1 |