WO2021163920A1 - Blockchain price feeding method and apparatus, and terminal device - Google Patents

Blockchain price feeding method and apparatus, and terminal device Download PDF

Info

Publication number
WO2021163920A1
WO2021163920A1 PCT/CN2020/075846 CN2020075846W WO2021163920A1 WO 2021163920 A1 WO2021163920 A1 WO 2021163920A1 CN 2020075846 W CN2020075846 W CN 2020075846W WO 2021163920 A1 WO2021163920 A1 WO 2021163920A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
type
price
request
price feed
Prior art date
Application number
PCT/CN2020/075846
Other languages
French (fr)
Chinese (zh)
Inventor
陈晓东
Original Assignee
深圳市嘉舟科技有限公司
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 深圳市嘉舟科技有限公司 filed Critical 深圳市嘉舟科技有限公司
Priority to PCT/CN2020/075846 priority Critical patent/WO2021163920A1/en
Publication of WO2021163920A1 publication Critical patent/WO2021163920A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION 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/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange

Definitions

  • This application relates to the field of blockchain technology, in particular to a blockchain price feeding method, a blockchain price feeding device and terminal equipment.
  • Blockchain can be regarded as a distributed database based on specific computer protocols (such as consensus mechanism and verification mechanism). Because the computer protocol on the block chain has the characteristic of passively receiving data, the block chain can only obtain the data on the chain, but cannot actively obtain the data outside the chain.
  • the concept of oracle is introduced. Through the oracle machine, the off-chain data of the blockchain can be collected, and the off-chain data can be submitted to the blockchain, and the off-chain data can be written into the blockchain through a computer protocol (such as a smart contract) on the blockchain.
  • a computer protocol such as a smart contract
  • the embodiments of the application provide a blockchain price feeding method, a blockchain price feeding device and terminal equipment, which can solve the problem of easily causing on-chain data fluctuations after feeding off-chain data to the blockchain through an oracle machine, and thereby affect The issue of blockchain stability.
  • an embodiment of the present application provides a blockchain price feeding method, which is applied to a price feeding node, and the method includes:
  • each type of data set For each moment, at least one type of data set is acquired, where each type of data set includes the type of off-chain data at the current moment obtained from multiple off-chain data sources;
  • various types of price feed data are calculated at the current moment, and various types of price feed data at the current moment are submitted to the blockchain to submit a price feed request.
  • the calculation of various types of price feed data at the current moment respectively according to various types of data sets includes:
  • the i-th weight is the proportion of the amount corresponding to the i-th off-chain data in the data set, and the proportion of the amount is the type of off-chain data in the off-chain data source.
  • the submitting a price feed request to the blockchain according to various types of price feed data at the current moment includes:
  • the price feed data of the type at the current time is generated into the price feed of the type Request, and submit the type of price feed request to the blockchain.
  • an embodiment of the present application provides a blockchain pricing method, which is applied to a blockchain node, and the method includes:
  • each type of request set includes all price feed requests of the type in the current block, and each price feed request includes one Feed price data;
  • the separately calculating the consensus data of various types of request sets corresponding to the current block includes:
  • For each type determine the median of the price feed data corresponding to all price feed requests of the type in the current block, and record the median as the consensus data of the request set of the type.
  • each type of request set also includes all price feed requests of the type corresponding to each of the M blocks before the current block, and M is a positive integer ;
  • the calculation of the consensus data of various types of request sets corresponding to the current block respectively includes:
  • the median of the price feed data corresponding to all price feed requests in the request set of the type is determined, and the median is recorded as the consensus data of the price feed request of the type.
  • an embodiment of the present application provides a blockchain price feeding device, which is applied to a price feeding node, and the device includes:
  • the first acquiring unit is configured to acquire at least one type of data set for each moment, where each type of data set includes the type of off-chain at the current moment obtained from multiple off-chain data sources data;
  • the weighting calculation unit is used to calculate various types of price feed data at the current time according to various types of data sets, and submit a price feed request to the blockchain according to the various types of price feed data at the current time.
  • an embodiment of the present application provides a blockchain price feeding device, which is applied to a blockchain node, and the device includes:
  • the second acquiring unit is configured to acquire at least one type of request set corresponding to the current block in the blockchain, wherein each type of request set includes all price feed requests of the type in the current block, each A price feed request includes a price feed data;
  • the consensus data calculation unit is used to calculate the consensus data of various types of request sets corresponding to the current block, and add the consensus data to the current block.
  • an embodiment of the present application provides a terminal device, including a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, wherein the processor When the computer-readable instruction is executed, the blockchain price feeding method according to any one of the first aspect or the blockchain price feeding method according to any one of the second aspect is implemented.
  • an embodiment of the present application provides a computer-readable storage medium
  • an embodiment of the present application provides a computer-readable storage medium
  • the computer-readable storage medium stores computer-readable instructions, and is characterized in that: When the computer-readable instructions are executed by a processor, the blockchain price feeding method according to any one of the first aspect or the blockchain price feeding method according to any one of the second aspect is implemented.
  • the embodiments of the present application provide a computer-readable instruction product.
  • the terminal device is caused to execute the blockchain as described in any one of the above-mentioned first aspects.
  • the embodiment of the present application acquires at least one type of data set for each time, where each type of data set includes the type of off-chain data at the current time obtained from multiple off-chain data sources, Using the above method, multiple off-chain data of the same type can be obtained from different data sources, providing a rich data basis for subsequent price feeding; according to various types of data sets, various types of price feeding data at the current moment can be calculated separately For each type, multiple off-chain data corresponding to the type are combined into one price feed data by calculation. Since the price feed data is obtained based on multiple off-chain data, it can reduce an unreliable off-chain data.
  • the impact of the data on the price feed data thereby ensuring the reliability of the price feed data; and then submit a price feed request to the blockchain according to various types of price feed data at the current moment.
  • the data fluctuation caused by unreliable off-chain data to the on-chain data of the blockchain can be avoided during price feeding, thereby ensuring the stability of the blockchain.
  • Figure 1 is a schematic diagram of a blockchain pricing system provided by an embodiment of the present application.
  • FIG. 2 is a schematic flowchart of a blockchain pricing method provided by an embodiment of the present application.
  • FIG. 3 is a schematic flowchart of a blockchain pricing method provided by another embodiment of the present application.
  • FIG. 4 is a structural block diagram of the blockchain price feeding device provided by an embodiment of the present application.
  • FIG. 5 is a structural block diagram of a blockchain pricing device provided by another embodiment of the present application.
  • FIG. 6 is a schematic structural diagram of a terminal device provided by an embodiment of the application.
  • the term “if” can be construed as “when” or “once” or “in response to determination” or “in response to detecting ".
  • the blockchain price feeding system includes at least one price feeding node 101 and at least one blockchain node 102.
  • the price-feeding node is used to provide price-feeding data to the blockchain
  • the blockchain node is used to process the price-feeding data to obtain consensus data and write the consensus data to the blockchain.
  • the price feed node and the blockchain node can be processors or terminal devices with computing capabilities.
  • data sources are divided into two types, one is the data that exists and on the blockchain, that is, data on the chain; the other is the data that exists and outside the blockchain, that is, off-chain data.
  • the computer protocol on the block chain has the characteristic of passively receiving data, the block chain can only obtain the data on the chain, but cannot actively obtain the data outside the chain.
  • the price feeder node can submit off-chain data to the blockchain, that is, the off-chain data is fed to the blockchain as the price feed data; the blockchain node processes the off-chain data submitted by the price feeder node to get Consensus data, and add the consensus data to the blockchain.
  • the blockchain can obtain off-chain data.
  • the price-feeding authorization can be performed on nodes that meet the authorization conditions among all the blockchain nodes, and the blockchain node after the price-feeding authorization can be used as the price-feeding node.
  • the authorization condition may be that the blockchain node is required to pledge a certain amount of on-chain tokens. If the blockchain nodes that are not authorized to feed the price force the price, the check mechanism on the chain will delete the price feed request submitted by these blockchain nodes.
  • authorization conditions malicious blockchain nodes can be excluded from participating in price feeding, thereby greatly reducing the risk of blockchain being attacked.
  • Fig. 2 shows a schematic flowchart of a blockchain pricing method provided by an embodiment of the present application.
  • the method in the embodiment of Fig. 2 is applied to the price feed node.
  • the method may include the following steps:
  • each type of data set includes the type of off-chain data at the current moment obtained from multiple off-chain data sources.
  • Off-chain data can be the currency value of financial currencies, the unit price of financial derivatives, and so on.
  • the off-chain data source can be currency exchanges and so on.
  • the USD price in Exchange A may be obtained as 6.2
  • the USD price in Exchange B may be obtained as 6.3.
  • the off-chain data are 6.2 and 6.3 respectively, and the corresponding type is USD, that is, the data set corresponding to the US dollar includes two off-chain data, 6.2 and 6.3.
  • other types of off-chain data such as yen can also be obtained at the same time.
  • S202 Calculate various types of price feed data at the current moment respectively according to various types of data sets, and submit a price feed request to the blockchain according to the various types of price feed data at the current moment.
  • the price feed data can change over time.
  • the calculation of various types of price feed data at the current moment according to various types of data sets in step S202 includes:
  • weighted sum processing is performed on all off-chain data in the data set to obtain the price feed data of the type at the current moment.
  • the i-th weight is the proportion of the amount corresponding to the i-th off-chain data in the data set, and the proportion of the amount is the type of off-chain data in the off-chain data source.
  • the current moment corresponds to The data set of is [6.1, 6.2, 6], and the corresponding type of the data set is USD.
  • the feed price data of the dollar at the current moment is 6.1w1+6.2w2+6w3.
  • w1 is the proportion of the dollar amount in Exchange I in the total dollar amount of the three exchanges
  • w2 is the proportion of the dollar amount in Exchange II in the total dollar amount of the three exchanges
  • w3 is the exchange The percentage of the dollar amount in the three exchanges in the total dollar amount in III.
  • submitting a price feed request to the blockchain according to various types of price feed data at the current moment in step S202 includes:
  • the calculation method of the price feed data at the previous moment is the same as the calculation method of the price feed data at the current moment in step S202, and will not be repeated here.
  • the price feed data may not change or change slightly within a certain period of time.
  • the price feed request is submitted. In this way, it is possible to avoid submitting price feed data with little volatility, or submitting the same price feed data repeatedly, which is conducive to saving price feed costs.
  • the embodiment of the present application obtains at least one type of data set for each time, where each type of data set includes the type of off-chain data at the current time obtained from multiple off-chain data sources, Using the above method, multiple off-chain data of the same type can be obtained from different data sources, providing a rich data basis for subsequent price feeding; according to various types of data sets, various types of price feeding data at the current moment can be calculated separately For each type, multiple off-chain data corresponding to the type are combined into one price feed data by calculation. Since the price feed data is obtained based on multiple off-chain data, it can reduce an unreliable off-chain data.
  • the impact of the data on the price feed data thereby ensuring the reliability of the price feed data; and then submit a price feed request to the blockchain according to various types of price feed data at the current moment.
  • the data fluctuation caused by unreliable off-chain data to the on-chain data of the blockchain can be avoided during price feeding, thereby ensuring the stability of the blockchain.
  • Fig. 3 shows a schematic flowchart of a blockchain pricing method provided by another embodiment of the present application.
  • the method in the embodiment of FIG. 3 is applied to a blockchain node.
  • the method may include the following steps:
  • S301 Obtain at least one type of request set corresponding to the current block in the blockchain.
  • each type of request set includes all price feed requests of the type in the current block, and each price feed request includes one price feed data.
  • the time for establishing a block can be preset.
  • the price-feeding node may submit multiple price-feeding requests of the same type.
  • the price feeder node submitted a USD price feed request (corresponding to the price feed data of 6 USD), and in the 2nd s, the price feeder node submitted another USD price feed request (corresponding price feed data) For US$6.1). Then the US dollar type request set corresponding to the block includes the above two price feed requests.
  • S302 Calculate the consensus data of various types of request sets corresponding to the current block, respectively, and add the consensus data to the current block.
  • the method in the embodiment in Figure 2 can effectively prevent the failure or error of a single off-chain data acquisition, but cannot resist at a certain point in time, a certain off-chain data source, especially the off-chain data source with a large weight.
  • the data is manipulated, resulting in a violation of the normal data fluctuations in a short period of time (within a few seconds).
  • step S302 the consensus data of various types of request sets corresponding to the current block are calculated respectively, including:
  • Calculate the median that is, arrange a set of data in ascending order or descending order. If the number of data in the group of data is odd, the data in the middle of the sequence is taken as the median; if the number of data in the group of data is even, the average of the two data in the middle of the sequence is taken as the median number.
  • the median is not easily affected by extreme values.
  • the median in the request set corresponding to the block is taken as the consensus data, which can avoid abnormal data fluctuations in a short period of time, thereby ensuring The stability of consensus data in each block.
  • each type of request set further includes all price feed requests of the type corresponding to each of the M blocks before the current block, and M is a positive integer.
  • the calculation of consensus data of various types of request sets corresponding to the current block in step S302 includes:
  • S22 For each type, determine the median of price feed data corresponding to all price feed requests in the request set of the type, and record the median as the consensus data of the price feed request of the type.
  • step S302 it is equivalent to taking a time sliding window, and then calculating the median of each data in the time sliding window.
  • the size of the time sliding window is the time period used to establish the current block; in S22, the size of the sliding window is the time period used to establish the current block and M blocks before the current block. It can be seen that the time sliding window in S22 is larger, and the consensus data calculated in this way can be relatively stable in a relatively long period of time.
  • This embodiment of the application obtains at least one type of request set corresponding to the current block in the blockchain, where each type of request set includes all price feed requests of the type in the current block, each of which is The price request includes a price feed data.
  • a consensus data is calculated based on multiple price feed requests in the request set corresponding to the type. Since the consensus data is obtained based on multiple price feed requests, it can be Avoid the influence of the price feed data in an unreliable price feed request on the data on the chain, and ensure the stability of the consensus data; and then add the consensus data to the current block.
  • the data fluctuation caused by unreliable off-chain data to the on-chain data of the blockchain can be avoided during price feeding, thereby ensuring the stability of the blockchain.
  • Fig. 4 shows a structural block diagram of the block chain price feeding device provided in an embodiment of the present application. The relevant part of the embodiment.
  • the device 4 includes:
  • the first obtaining unit 41 is configured to obtain at least one type of data set for each time, wherein each type of data set includes the type of chain at the current time obtained from multiple off-chain data sources External data.
  • the weighting calculation unit 42 is configured to calculate various types of weighted data at the current moment according to various types of data sets, and submit a price feed request to the blockchain according to the various types of weighted data at the current moment.
  • the weight calculation unit 42 is further configured to:
  • weighted sum processing is performed on all off-chain data in the data set to obtain the price feed data of the type at the current moment.
  • the i-th weight is the proportion of the amount corresponding to the i-th off-chain data in the data set, and the proportion of the amount is the type of off-chain data in the off-chain data source.
  • the weight calculation unit 42 includes:
  • the obtaining module is used to obtain the price feed data of the type mentioned at the previous moment for each type.
  • the generating module is used to generate the price feed data of the type at the current time if the absolute value of the difference between the price feed data of the type at the previous time and the price feed data of the type at the current time is greater than the preset value.
  • Fig. 5 shows a structural block diagram of a block chain price feeding device provided by another embodiment of the present application. The relevant part of the embodiment of this application.
  • the device 5 includes:
  • the second obtaining unit 51 is configured to obtain at least one type of request set corresponding to the current block in the blockchain, wherein each type of request set includes all price feed requests of the type in the current block, Each price feed request includes a price feed data.
  • the consensus data calculation unit 52 is configured to respectively calculate consensus data of various types of request sets corresponding to the current block, and add the consensus data to the current block.
  • the consensus data calculation unit 52 includes:
  • the first calculation module is used to determine the median of the price feed data corresponding to all price feed requests of the type in the current block for each type, and record the median as the request set of the type Consensus data.
  • each type of request set further includes all price feed requests of the type corresponding to each of the M blocks before the current block, and M is a positive integer.
  • the consensus data calculation unit 52 is also used to:
  • the median of the price feed data corresponding to all price feed requests in the request set of the type is determined, and the median is recorded as the consensus data of the price feed request of the type.
  • the blockchain pricing device shown in Figure 4/5 can be a software unit, a hardware unit, or a combination of software and hardware built into the existing terminal equipment, or it can be integrated into the terminal as an independent pendant. In the device, it can also exist as an independent terminal device.
  • FIG. 6 is a schematic structural diagram of a terminal device provided by an embodiment of the application.
  • the terminal device 6 of this embodiment includes: at least one processor 60 (only one is shown in FIG. 6), a processor, a memory 61, and a processor that is stored in the memory 61 and can be processed in the at least one processor.
  • the computer-readable instructions 62 running on the processor 60 when the processor 60 executes the computer-readable instructions 62, implement the steps in each of the above-mentioned blockchain pricing method embodiments.
  • the terminal device may be a computing device such as a desktop computer, a notebook, a palmtop computer, and a cloud server.
  • the terminal device may include, but is not limited to, a processor and a memory.
  • FIG. 6 is only an example of the terminal device 6 and does not constitute a limitation on the terminal device 6. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. , For example, can also include input and output devices, network access devices, and so on.
  • the so-called processor 60 may be a central processing unit (Central Processing Unit, CPU), and the processor 60 may also be other general-purpose processors, digital signal processors (Digital Signal Processors, DSPs), and application specific integrated circuits (Application Specific Integrated Circuits). , ASIC), ready-made programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc.
  • the general-purpose processor may be a microprocessor or the processor may also be any conventional processor or the like.
  • the memory 61 may be an internal storage unit of the terminal device 6 in some embodiments, such as a hard disk or a memory of the terminal device 6. In other embodiments, the memory 61 may also be an external storage device of the terminal device 6, such as a plug-in hard disk equipped on the terminal device 6, a smart media card (SMC), a secure digital (Secure Digital, SD) card, flash card (Flash Card), etc. Further, the memory 61 may also include both an internal storage unit of the terminal device 6 and an external storage device.
  • the memory 61 is used to store an operating system, an application program, a boot loader (BootLoader), data, and other programs, for example, the program code of the computer-readable instruction.
  • the memory 61 can also be used to temporarily store data that has been output or will be output.
  • the embodiments of the present application also provide a computer-readable storage medium, the computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, they can realize step.
  • the embodiments of the present application provide a computer-readable instruction product.
  • the steps in the foregoing method embodiments can be realized when the mobile terminal is executed.
  • the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium.
  • the implementation of all or part of the processes in the above-mentioned embodiments and methods in this application can be accomplished by instructing relevant hardware through computer-readable instructions, and the computer-readable instructions can be stored in a computer-readable storage medium.
  • the computer-readable instructions are executed by the processor, they can implement the steps of the foregoing method embodiments.
  • the computer-readable instruction includes computer-readable instruction code
  • the computer-readable instruction code may be in the form of source code, object code, executable file, or some intermediate form.
  • the computer-readable medium may include at least any entity or device capable of carrying computer-readable instruction codes to a terminal device, a recording medium, a computer memory, a read-only memory (ROM, Read-Only Memory), and a random access memory (RAM, Random Access Memory), electric carrier signal, telecommunications signal and software distribution medium.
  • ROM read-only memory
  • RAM Random Access Memory
  • electric carrier signal telecommunications signal and software distribution medium.
  • U disk mobile hard disk, floppy disk or CD-ROM, etc.
  • computer-readable media cannot be electrical carrier signals and telecommunication signals.
  • the disclosed apparatus/network equipment and method may be implemented in other ways.
  • the device/network device embodiments described above are only illustrative.
  • the division of the modules or units is only a logical function division, and there may be other divisions in actual implementation, such as multiple units.
  • components can be combined or integrated into another system, or some features can be omitted or not implemented.
  • the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.

Landscapes

  • Engineering & Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Finance (AREA)
  • Accounting & Taxation (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Development Economics (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • Strategic Management (AREA)
  • Technology Law (AREA)
  • General Business, Economics & Management (AREA)
  • Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)

Abstract

The present application is applicable to the technical field of blockchains and provides a blockchain price feeding method and apparatus, and a terminal device. The method comprises: for each moment, a price feeding node obtains at least one type of data set, respectively calculates various types of price feeding data at the current moment according to various types of data sets, and submits a price feeding request to a blockchain according to the various types of price feeding data at the current moment; and a blockchain node obtains price feeding data of a plurality of continuous blocks comprising the current block, calculates the median of the price feeding data, and uses the median as consensus data of the current block. By means of the method, data fluctuation caused by unreliable out-of-chain data to on-chain data of the blockchain can be avoided during price feeding, so that the stability of the blockchain is guaranteed.

Description

一种区块链喂价方法、区块链喂价装置及终端设备Block chain price feeding method, block chain price feeding device and terminal equipment 技术领域Technical field
本申请涉及区块链技术领域,尤其涉及一种区块链喂价方法、区块链喂价装置及终端设备。This application relates to the field of blockchain technology, in particular to a blockchain price feeding method, a blockchain price feeding device and terminal equipment.
背景技术Background technique
区块链可以看成是一种基于特定的计算机协议(如共识机制和验证机制)的分布式数据库。由于区块链上的计算机协议具有被动接收数据的特性,因此,区块链只能获取链上数据、而无法主动获取链外数据。为了满足区块链对链外数据的交互需求,引入了预言机的概念。通过预言机可以采集区块链的链外数据、并将链外数据提交给区块链,通过区块链上的计算机协议(如智能合约)将该链外数据写入区块链。换句话说,预言机可以看作是一种区块链与外部数据源之间的单向数字代理。Blockchain can be regarded as a distributed database based on specific computer protocols (such as consensus mechanism and verification mechanism). Because the computer protocol on the block chain has the characteristic of passively receiving data, the block chain can only obtain the data on the chain, but cannot actively obtain the data outside the chain. In order to meet the interaction demand of blockchain for off-chain data, the concept of oracle is introduced. Through the oracle machine, the off-chain data of the blockchain can be collected, and the off-chain data can be submitted to the blockchain, and the off-chain data can be written into the blockchain through a computer protocol (such as a smart contract) on the blockchain. In other words, the oracle can be seen as a one-way digital agent between the blockchain and external data sources.
由于无法保障链外数据的可靠性,因此通过预言机将链外数据喂价给区块链后,容易导致链上数据的波动,进而影响区块链的稳定性。Since the reliability of off-chain data cannot be guaranteed, after the off-chain data is fed to the blockchain through the oracle, it is easy to cause fluctuations in the data on the chain, which in turn affects the stability of the blockchain.
发明概述Summary of the invention
技术问题technical problem
本申请实施例提供了一种区块链喂价方法、区块链喂价装置及终端设备,可以解决通过预言机将链外数据喂价给区块链后容易导致链上数据波动、进而影响区块链稳定性的问题。The embodiments of the application provide a blockchain price feeding method, a blockchain price feeding device and terminal equipment, which can solve the problem of easily causing on-chain data fluctuations after feeding off-chain data to the blockchain through an oracle machine, and thereby affect The issue of blockchain stability.
问题的解决方案The solution to the problem
技术解决方案Technical solutions
为解决上述技术问题,本申请实施例采用的技术方案是:In order to solve the above technical problems, the technical solutions adopted in the embodiments of this application are:
第一方面,本申请实施例提供了一种区块链喂价方法,应用于喂价节点,所述方法包括:In the first aspect, an embodiment of the present application provides a blockchain price feeding method, which is applied to a price feeding node, and the method includes:
对于每个时刻,获取至少一种类型的数据集,其中,每种类型的数据集中包括从多个链外数据源中获取到的当前时刻的所述类型的链外数据;For each moment, at least one type of data set is acquired, where each type of data set includes the type of off-chain data at the current moment obtained from multiple off-chain data sources;
根据各种类型的数据集分别计算当前时刻各种类型的喂价数据,并根据当前时刻各种类型的喂价数据向所述区块链提交喂价请求。According to various types of data sets, various types of price feed data are calculated at the current moment, and various types of price feed data at the current moment are submitted to the blockchain to submit a price feed request.
在第一方面的一种可能的实现方式中,所述根据各种类型的数据集分别计算当前时刻各种类型的喂价数据,包括:In a possible implementation manner of the first aspect, the calculation of various types of price feed data at the current moment respectively according to various types of data sets includes:
对于每种类型的数据集,对所述数据集中所有的链外数据进行加权求和处理,得到当前时刻所述类型的喂价数据;For each type of data set, perform weighted summation processing on all off-chain data in the data set to obtain the type of price feed data at the current moment;
其中,在所述加权求和处理中,第i个权值为所述数据集中第i个链外数据对应的数额占比,所述数额占比为链外数据源中所述类型的链外数据的数额在N个链外数据源中的占比,N为所述数据集对应的链外数据源的个数,N为正整数。Wherein, in the weighted sum processing, the i-th weight is the proportion of the amount corresponding to the i-th off-chain data in the data set, and the proportion of the amount is the type of off-chain data in the off-chain data source. The proportion of the amount of data among the N off-chain data sources, where N is the number of off-chain data sources corresponding to the data set, and N is a positive integer.
在第一方面的一种可能的实现方式中,所述根据当前时刻各种类型的喂价数据向所述区块链提交喂价请求,包括:In a possible implementation of the first aspect, the submitting a price feed request to the blockchain according to various types of price feed data at the current moment includes:
对于每种类型,获取上一时刻所述类型的喂价数据;For each type, get the price feed data of the type mentioned at the previous moment;
若上一时刻所述类型的喂价数据与当前时刻所述类型的喂价数据的差值的绝对值大于预设值,则将当前时刻所述类型的喂价数据生成所述类型的喂价请求,并将向所述区块链提交所述类型的喂价请求。If the absolute value of the difference between the price feed data of the type at the previous time and the price feed data of the type at the current time is greater than the preset value, the price feed data of the type at the current time is generated into the price feed of the type Request, and submit the type of price feed request to the blockchain.
第二方面,本申请实施例提供了一种区块链喂价方法,应用于区块链节点,所述方法包括:In the second aspect, an embodiment of the present application provides a blockchain pricing method, which is applied to a blockchain node, and the method includes:
获取所述区块链中当前区块对应的至少一种类型的请求集合,其中,每种类型的请求集合包括当前区块中所述类型的所有喂价请求,每个喂价请求中包括一个喂价数据;Obtain at least one type of request set corresponding to the current block in the blockchain, where each type of request set includes all price feed requests of the type in the current block, and each price feed request includes one Feed price data;
分别计算当前区块对应的各种类型的请求集合的共识数据,并将所述共识数据添加到所述当前区块中。Calculate the consensus data of various types of request sets corresponding to the current block respectively, and add the consensus data to the current block.
在第二方面的一种可能的实现方式中,所述分别计算当前区块对应的各种类型的请求集合的共识数据,包括:In a possible implementation manner of the second aspect, the separately calculating the consensus data of various types of request sets corresponding to the current block includes:
对于每种类型,确定当前区块中所述类型的所有喂价请求对应的喂价数据的中位数,并将所述中位数记为所述类型的请求集合的共识数据。For each type, determine the median of the price feed data corresponding to all price feed requests of the type in the current block, and record the median as the consensus data of the request set of the type.
在第二方面的一种可能的实现方式中,每种类型的请求集合还包括当前区块之前的M个区块中每个区块对应的所述类型的所有喂价请求,M为正整数;In a possible implementation of the second aspect, each type of request set also includes all price feed requests of the type corresponding to each of the M blocks before the current block, and M is a positive integer ;
所述分别计算当前区块对应的各种类型的请求集合的共识数据,包括:The calculation of the consensus data of various types of request sets corresponding to the current block respectively includes:
对于每种类型,确定所述类型的请求集合中的所有喂价请求对应的喂价数据的中位数,并将所述中位数记为所述类型的喂价请求的共识数据。For each type, the median of the price feed data corresponding to all price feed requests in the request set of the type is determined, and the median is recorded as the consensus data of the price feed request of the type.
第三方面,本申请实施例提供了一种区块链喂价装置,应用于喂价节点,所述装置包括:In the third aspect, an embodiment of the present application provides a blockchain price feeding device, which is applied to a price feeding node, and the device includes:
第一获取单元,用于对于每个时刻,获取至少一种类型的数据集,其中,每种类型的数据集中包括从多个链外数据源中获取到的当前时刻的所述类型的链外数据;The first acquiring unit is configured to acquire at least one type of data set for each moment, where each type of data set includes the type of off-chain at the current moment obtained from multiple off-chain data sources data;
加权计算单元,用于根据各种类型的数据集分别计算当前时刻各种类型的喂价数据,并根据当前时刻各种类型的喂价数据向所述区块链提交喂价请求。The weighting calculation unit is used to calculate various types of price feed data at the current time according to various types of data sets, and submit a price feed request to the blockchain according to the various types of price feed data at the current time.
第四方面,本申请实施例提供了一种区块链喂价装置,应用于区块链节点,所述装置包括:In a fourth aspect, an embodiment of the present application provides a blockchain price feeding device, which is applied to a blockchain node, and the device includes:
第二获取单元,用于获取所述区块链中当前区块对应的至少一种类型的请求集合,其中,每种类型的请求集合包括当前区块中所述类型的所有喂价请求,每个喂价请求中包括一个喂价数据;The second acquiring unit is configured to acquire at least one type of request set corresponding to the current block in the blockchain, wherein each type of request set includes all price feed requests of the type in the current block, each A price feed request includes a price feed data;
共识数据计算单元,用于分别计算当前区块对应的各种类型的请求集合的共识数据,并将所述共识数据添加到所述当前区块中。The consensus data calculation unit is used to calculate the consensus data of various types of request sets corresponding to the current block, and add the consensus data to the current block.
第五方面,本申请实施例提供了一种终端设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机可读指令,其特征在于,所述处理器执行所述计算机可读指令时实现如上述第一方面中任一项所述的区块链喂价方法或第二方面中任一项所述的区块链喂价方法。In a fifth aspect, an embodiment of the present application provides a terminal device, including a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, wherein the processor When the computer-readable instruction is executed, the blockchain price feeding method according to any one of the first aspect or the blockchain price feeding method according to any one of the second aspect is implemented.
第六方面,本申请实施例提供了一种计算机可读存储介质,本申请实施例提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机可读指令,其特征在于,所述计算机可读指令被处理器执行时实现如上述第一方面中任一项所述的区块链喂价方法或第二方面中任一项所述的区块链喂价方法。In the sixth aspect, an embodiment of the present application provides a computer-readable storage medium, and an embodiment of the present application provides a computer-readable storage medium, the computer-readable storage medium stores computer-readable instructions, and is characterized in that: When the computer-readable instructions are executed by a processor, the blockchain price feeding method according to any one of the first aspect or the blockchain price feeding method according to any one of the second aspect is implemented.
第七方面,本申请实施例提供了一种计算机可读指令产品,当计算机可读指令产品在终端设备上运行时,使得终端设备执行如上述第一方面中任一项所述的区块链喂价方法或第二方面中任一项所述的区块链喂价方法。In the seventh aspect, the embodiments of the present application provide a computer-readable instruction product. When the computer-readable instruction product runs on a terminal device, the terminal device is caused to execute the blockchain as described in any one of the above-mentioned first aspects. Price feeding method or the blockchain price feeding method described in any one of the second aspect.
本申请实施例与现有技术相比存在的有益效果是:Compared with the prior art, the embodiments of this application have the following beneficial effects:
本申请实施例通过对于每个时刻,获取至少一种类型的数据集,其中,每种类型的数据集中包括从多个链外数据源中获取到的当前时刻的所述类型的链外数据,利用上述方法可以从不同的数据源中获取相同类型的多个链外数据,为后续的喂价提供了丰富的数据基础;根据各种类型的数据集分别计算当前时刻各种类型的喂价数据,对于每种类型,通过计算将该类型对应的多个链外数据合并为一个喂价数据,由于该喂价数据是基于多个链外数据得到的,因此可以降低某个不可靠的链外数据对喂价数据的影响,进而保证了喂价数据的可靠性;然后根据当前时刻各种类型的喂价数据向所述区块链提交喂价请求。通过上述方法,能够在喂价时避免不可靠的链外数据对区块链的链上数据造成的数据波动,从而保证了区块链的稳定性。The embodiment of the present application acquires at least one type of data set for each time, where each type of data set includes the type of off-chain data at the current time obtained from multiple off-chain data sources, Using the above method, multiple off-chain data of the same type can be obtained from different data sources, providing a rich data basis for subsequent price feeding; according to various types of data sets, various types of price feeding data at the current moment can be calculated separately For each type, multiple off-chain data corresponding to the type are combined into one price feed data by calculation. Since the price feed data is obtained based on multiple off-chain data, it can reduce an unreliable off-chain data. The impact of the data on the price feed data, thereby ensuring the reliability of the price feed data; and then submit a price feed request to the blockchain according to various types of price feed data at the current moment. Through the above method, the data fluctuation caused by unreliable off-chain data to the on-chain data of the blockchain can be avoided during price feeding, thereby ensuring the stability of the blockchain.
发明的有益效果The beneficial effects of the invention
对附图的简要说明Brief description of the drawings
附图说明Description of the drawings
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例或示范性技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其它的附图。In order to more clearly describe the technical solutions in the embodiments of the present application, the following will briefly introduce the accompanying drawings that need to be used in the embodiments or exemplary technical descriptions. Obviously, the accompanying drawings in the following description are only of the present application. For some embodiments, those of ordinary skill in the art can obtain other drawings based on these drawings without creative work.
图1是本申请一实施例提供的区块链喂价系统的示意图;Figure 1 is a schematic diagram of a blockchain pricing system provided by an embodiment of the present application;
图2是本申请一实施例提供的区块链喂价方法的流程示意图;2 is a schematic flowchart of a blockchain pricing method provided by an embodiment of the present application;
图3是本申请另一实施例提供的区块链喂价方法的流程示意图;FIG. 3 is a schematic flowchart of a blockchain pricing method provided by another embodiment of the present application;
图4是本申请实施例提供的区块链喂价装置的结构框图;FIG. 4 is a structural block diagram of the blockchain price feeding device provided by an embodiment of the present application;
图5是本申请另一实施例提供的区块链喂价装置的结构框图;FIG. 5 is a structural block diagram of a blockchain pricing device provided by another embodiment of the present application;
图6为本申请一实施例提供的终端设备的结构示意图。FIG. 6 is a schematic structural diagram of a terminal device provided by an embodiment of the application.
发明实施例Invention embodiment
本发明的实施方式Embodiments of the present invention
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例 ,对本申请进行详细说明。应当理解,此处所描述的具体实施例仅用以解释本申请,并不用于限定本申请。In order to make the purpose, technical solutions, and advantages of this application clearer, the following describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described here are only used to explain the application, and are not used to limit the application.
应当理解,当在本申请说明书和所附权利要求书中使用时,术语“包括”指示所描述特征、整体、步骤、操作、元素和/或组件的存在,但并不排除一个或多个其它特征、整体、步骤、操作、元素、组件和/或其集合的存在或添加。It should be understood that when used in the specification and appended claims of this application, the term "comprising" indicates the existence of the described features, wholes, steps, operations, elements and/or components, but does not exclude one or more other The existence or addition of features, wholes, steps, operations, elements, components, and/or collections thereof.
如在本申请说明书和所附权利要求书中所使用的那样,术语“若”可以依据上下文被解释为“当...时”或“一旦”或“响应于确定”或“响应于检测到”。As used in the description of this application and the appended claims, the term "if" can be construed as "when" or "once" or "in response to determination" or "in response to detecting ".
在本申请说明书中描述的参考“一个实施例”或“一些实施例”等意味着在本申请的一个或多个实施例中包括结合该实施例描述的特定特征、结构或特点。由此,在本说明书中的不同之处出现的语句“在一个实施例中”、“在一些实施例中”、“在其他一些实施例中”、“在另外一些实施例中”等不是必然都参考相同的实施例,而是意味着“一个或多个但不是所有的实施例”,除非是以其他方式另外特别强调。The reference to "one embodiment" or "some embodiments" described in the specification of this application means that one or more embodiments of this application include a specific feature, structure, or characteristic described in combination with the embodiment. Therefore, the sentences "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. appearing in different places in this specification are not necessarily All refer to the same embodiment, but mean "one or more but not all embodiments" unless it is specifically emphasized otherwise.
先介绍本申请实施例的一个应用场景。参见图1,为本申请实施例提供的区块链喂价系统的示意图。如图1所示,区块链喂价系统包括至少一个喂价节点101和至少一个区块链节点102。喂价节点用于向区块链提供喂价数据,区块链节点用于对喂价数据进行处理后得到共识数据,并将共识数据写入区块链。其中,喂价节点和区块链节点可以是处理器,或具有计算能力的终端设备。First, an application scenario of the embodiment of the present application is introduced. Refer to Fig. 1, which is a schematic diagram of a blockchain pricing system provided by an embodiment of this application. As shown in FIG. 1, the blockchain price feeding system includes at least one price feeding node 101 and at least one blockchain node 102. The price-feeding node is used to provide price-feeding data to the blockchain, and the blockchain node is used to process the price-feeding data to obtain consensus data and write the consensus data to the blockchain. Among them, the price feed node and the blockchain node can be processors or terminal devices with computing capabilities.
对于区块链而言,数据来源分为两种,一种是本身存在与区块链上的数据,即链上数据;一种是存在与区块链外的数据,即链外数据。由于区块链上的计算机协议具有被动接收数据的特性,因此,区块链只能获取链上数据、而无法主动获取链外数据。通过预言机机制,喂价节点可以将链外数据提交给区块链,即将链外数据作为喂价数据喂价给区块链;区块链节点对喂价节点提交的链外数据进行处理得到共识数据,并将共识数据添加到区块链中。通过上述方法,区块链即可获取链外数据。For the blockchain, data sources are divided into two types, one is the data that exists and on the blockchain, that is, data on the chain; the other is the data that exists and outside the blockchain, that is, off-chain data. Because the computer protocol on the block chain has the characteristic of passively receiving data, the block chain can only obtain the data on the chain, but cannot actively obtain the data outside the chain. Through the oracle mechanism, the price feeder node can submit off-chain data to the blockchain, that is, the off-chain data is fed to the blockchain as the price feed data; the blockchain node processes the off-chain data submitted by the price feeder node to get Consensus data, and add the consensus data to the blockchain. Through the above methods, the blockchain can obtain off-chain data.
在实际应用中,可以对所有区块链节点中满足授权条件的节点进行喂价授权,得到喂价授权后的区块链节点可以作为喂价节点。示例性的,授权条件可以是,需要区块链节点质押一定数量的链上代币。如果没有得到喂价授权的区块链 节点强行喂价,链上的检查机制则会删除这些区块链节点提交的喂价请求。通过授权条件,可以排除恶意的区块链节点参与喂价,从而大大降低了区块链被攻击的风险。In practical applications, the price-feeding authorization can be performed on nodes that meet the authorization conditions among all the blockchain nodes, and the blockchain node after the price-feeding authorization can be used as the price-feeding node. Exemplarily, the authorization condition may be that the blockchain node is required to pledge a certain amount of on-chain tokens. If the blockchain nodes that are not authorized to feed the price force the price, the check mechanism on the chain will delete the price feed request submitted by these blockchain nodes. Through authorization conditions, malicious blockchain nodes can be excluded from participating in price feeding, thereby greatly reducing the risk of blockchain being attacked.
图2示出了本申请一实施例提供的区块链喂价方法的流程示意图。图2实施例中的方法应用于喂价节点。作为示例而非限定,所述方法可以包括以下步骤:Fig. 2 shows a schematic flowchart of a blockchain pricing method provided by an embodiment of the present application. The method in the embodiment of Fig. 2 is applied to the price feed node. As an example and not a limitation, the method may include the following steps:
S201,对于每个时刻,获取至少一种类型的数据集。S201: For each moment, at least one type of data set is acquired.
其中,每种类型的数据集中包括从多个链外数据源中获取到的当前时刻的所述类型的链外数据。Wherein, each type of data set includes the type of off-chain data at the current moment obtained from multiple off-chain data sources.
链外数据可以是金融货币的币值、金融衍生品的单价等等。链外数据源可以是货币交易所等等。Off-chain data can be the currency value of financial currencies, the unit price of financial derivatives, and so on. The off-chain data source can be currency exchanges and so on.
示例性的,可以获取交易所A中的美元价格为6.2,获取交易所B中的美元价格为6.3。那么链外数据分别为6.2和6.3,对应的类型为美元,即美元对应的数据集中包括6.2和6.3这两个链外数据。当然,同时还可以获取日元等其他类型的链外数据。Exemplarily, the USD price in Exchange A may be obtained as 6.2, and the USD price in Exchange B may be obtained as 6.3. Then the off-chain data are 6.2 and 6.3 respectively, and the corresponding type is USD, that is, the data set corresponding to the US dollar includes two off-chain data, 6.2 and 6.3. Of course, other types of off-chain data such as yen can also be obtained at the same time.
S202,根据各种类型的数据集分别计算当前时刻各种类型的喂价数据,并根据当前时刻各种类型的喂价数据向所述区块链提交喂价请求。S202: Calculate various types of price feed data at the current moment respectively according to various types of data sets, and submit a price feed request to the blockchain according to the various types of price feed data at the current moment.
对于每种类型,每个时刻对应的都可以得到一个喂价数据。换句话说,喂价数据可以是随时间而变动的。For each type, you can get a price feed data corresponding to each moment. In other words, the price feed data can change over time.
在每个时刻,需要同时获取多个链外数据源中相同类型的数链外数据,即保证了链外数据的同时性。当某个链外数据源中的链外数据获取失败或出现异常时,还可以从其他链外数据源中获取该类型的链外数据,即可以保证了链外数据的可靠性。根据该时刻下获取到的某种类型的多个链外数据,计算出该时刻对应的一个喂价数据,即综合考虑多个链外数据,而非只考虑一个链外数据,避免了单个不可靠链外数据的影响,进一步保证了链外数据的可靠性。At each moment, it is necessary to obtain the same type of off-chain data from multiple off-chain data sources at the same time, which guarantees the simultaneity of off-chain data. When the acquisition of off-chain data in a certain off-chain data source fails or an exception occurs, the type of off-chain data can also be obtained from other off-chain data sources, which guarantees the reliability of the off-chain data. According to a certain type of multiple off-chain data obtained at that moment, a price feed data corresponding to the moment is calculated, that is, multiple off-chain data are comprehensively considered, instead of only one off-chain data, which avoids a single error. The influence of reliable off-chain data further ensures the reliability of off-chain data.
在一个实施例中,步骤S202中根据各种类型的数据集分别计算当前时刻各种类型的喂价数据,包括:In an embodiment, the calculation of various types of price feed data at the current moment according to various types of data sets in step S202 includes:
对于每种类型的数据集,对所述数据集中所有的链外数据进行加权求和处理,得到当前时刻所述类型的喂价数据。For each type of data set, weighted sum processing is performed on all off-chain data in the data set to obtain the price feed data of the type at the current moment.
其中,在所述加权求和处理中,第i个权值为所述数据集中第i个链外数据对应的数额占比,所述数额占比为链外数据源中所述类型的链外数据的数额在N个链外数据源中的占比,N为所述数据集对应的链外数据源的个数,N为正整数。Wherein, in the weighted sum processing, the i-th weight is the proportion of the amount corresponding to the i-th off-chain data in the data set, and the proportion of the amount is the type of off-chain data in the off-chain data source. The proportion of the amount of data among the N off-chain data sources, where N is the number of off-chain data sources corresponding to the data set, and N is a positive integer.
示例性的,假设当前时刻从交易所I中获取到的美元价格为6.1、从交易所II中获取到的美元价格为6.2、从交易所III中获取到的美元价格为6,那么当前时刻对应的数据集为[6.1,6.2,6],数据集对应的类型为美元。那么当前时刻美元的喂价数据为6.1w1+6.2w2+6w3。其中,w1为交易所I中美元的数额在3个交易所的美元总额中的占比,w2为交易所II中美元的数额在3个交易所的美元总额中的占比,w3为交易所III中美元的数额在3个交易所的美元总额中的占比。Exemplarily, assuming that the USD price obtained from Exchange I at the current moment is 6.1, the USD price obtained from Exchange II is 6.2, and the USD price obtained from Exchange III is 6, then the current moment corresponds to The data set of is [6.1, 6.2, 6], and the corresponding type of the data set is USD. Then the feed price data of the dollar at the current moment is 6.1w1+6.2w2+6w3. Among them, w1 is the proportion of the dollar amount in Exchange I in the total dollar amount of the three exchanges, w2 is the proportion of the dollar amount in Exchange II in the total dollar amount of the three exchanges, and w3 is the exchange The percentage of the dollar amount in the three exchanges in the total dollar amount in III.
在一个实施例中,步骤S202中根据当前时刻各种类型的喂价数据向所述区块链提交喂价请求,包括:In one embodiment, submitting a price feed request to the blockchain according to various types of price feed data at the current moment in step S202 includes:
S11,对于每种类型,获取上一时刻所述类型的喂价数据。S11: For each type, obtain price feed data of the type at the previous moment.
S12,若上一时刻所述类型的喂价数据与当前时刻所述类型的喂价数据的差值的绝对值大于预设值,则将当前时刻所述类型的喂价数据生成所述类型的喂价请求,并将向所述区块链提交所述类型的喂价请求。S12: If the absolute value of the difference between the price feed data of the type at the previous time and the price feed data of the type at the current time is greater than the preset value, generate the price feed data of the type at the current time into the type Price feed request, and submit the type of price feed request to the blockchain.
其中,上一时刻的喂价数据的计算方法与步骤S202中的当前时刻的喂价数据的计算方法相同,在此不再赘述。Wherein, the calculation method of the price feed data at the previous moment is the same as the calculation method of the price feed data at the current moment in step S202, and will not be repeated here.
实际应用中,喂价数据可能在某段时间内无变化或变化较小。通过上述方法,只有喂价数据的波动超过一定范围时,才提交喂价请求。这样可以避免提交波动性很小的喂价数据、或重复提交相同的喂价数据,有利于节约喂价成本。In actual applications, the price feed data may not change or change slightly within a certain period of time. Through the above method, only when the fluctuation of the price feed data exceeds a certain range, the price feed request is submitted. In this way, it is possible to avoid submitting price feed data with little volatility, or submitting the same price feed data repeatedly, which is conducive to saving price feed costs.
实际应用中,也可以计算当前时刻的喂价数据相比于上一时刻的喂价数据的浮动百分比。只要能够表征当前时刻和下一时刻的喂价数据的波动状况即可,方法不做具体限定。In practical applications, it is also possible to calculate the floating percentage of the price feed data at the current moment compared to the price feed data at the previous moment. As long as it can characterize the fluctuation status of the price feed data at the current moment and the next moment, the method is not specifically limited.
本申请实施例通过对于每个时刻,获取至少一种类型的数据集,其中,每种类型的数据集中包括从多个链外数据源中获取到的当前时刻的所述类型的链外数据,利用上述方法可以从不同的数据源中获取相同类型的多个链外数据,为后续的喂价提供了丰富的数据基础;根据各种类型的数据集分别计算当前时刻各种类型的喂价数据,对于每种类型,通过计算将该类型对应的多个链外数据合 并为一个喂价数据,由于该喂价数据是基于多个链外数据得到的,因此可以降低某个不可靠的链外数据对喂价数据的影响,进而保证了喂价数据的可靠性;然后根据当前时刻各种类型的喂价数据向所述区块链提交喂价请求。通过上述方法,能够在喂价时避免不可靠的链外数据对区块链的链上数据造成的数据波动,从而保证了区块链的稳定性。The embodiment of the present application obtains at least one type of data set for each time, where each type of data set includes the type of off-chain data at the current time obtained from multiple off-chain data sources, Using the above method, multiple off-chain data of the same type can be obtained from different data sources, providing a rich data basis for subsequent price feeding; according to various types of data sets, various types of price feeding data at the current moment can be calculated separately For each type, multiple off-chain data corresponding to the type are combined into one price feed data by calculation. Since the price feed data is obtained based on multiple off-chain data, it can reduce an unreliable off-chain data. The impact of the data on the price feed data, thereby ensuring the reliability of the price feed data; and then submit a price feed request to the blockchain according to various types of price feed data at the current moment. Through the above method, the data fluctuation caused by unreliable off-chain data to the on-chain data of the blockchain can be avoided during price feeding, thereby ensuring the stability of the blockchain.
图3示出了本申请又一实施例提供的区块链喂价方法的流程示意图。图3实施例中的方法应用于区块链节点。作为示例而非限定,所述方法可以包括以下步骤:Fig. 3 shows a schematic flowchart of a blockchain pricing method provided by another embodiment of the present application. The method in the embodiment of FIG. 3 is applied to a blockchain node. As an example and not a limitation, the method may include the following steps:
S301,获取所述区块链中当前区块对应的至少一种类型的请求集合。S301: Obtain at least one type of request set corresponding to the current block in the blockchain.
其中,每种类型的请求集合包括当前区块中所述类型的所有喂价请求,每个喂价请求中包括一个喂价数据。Among them, each type of request set includes all price feed requests of the type in the current block, and each price feed request includes one price feed data.
在实际应用中,建立一个区块的时间可以预先设定。在建立一个区块的一段时间内,喂价节点可能会提交同一种类型的多个喂价请求。In practical applications, the time for establishing a block can be preset. During a period of time when a block is established, the price-feeding node may submit multiple price-feeding requests of the same type.
示例性的,假设建立一个区块的时间为2s。在第1s时,喂价节点提交了一个美元的喂价请求(对应的喂价数据为6美元),在第2s时,喂价节点又提交了一个美元的喂价请求(对应的喂价数据为6.1美元)。那么该区块对应的美元这种类型的请求集合中包括上述2个喂价请求。Exemplarily, suppose the time to build a block is 2s. In the 1st s, the price feeder node submitted a USD price feed request (corresponding to the price feed data of 6 USD), and in the 2nd s, the price feeder node submitted another USD price feed request (corresponding price feed data) For US$6.1). Then the US dollar type request set corresponding to the block includes the above two price feed requests.
S302,分别计算当前区块对应的各种类型的请求集合的共识数据,并将所述共识数据添加到所述当前区块中。S302: Calculate the consensus data of various types of request sets corresponding to the current block, respectively, and add the consensus data to the current block.
图2实施例中的方法可以有效防范单个链外数据获取失败或者错误的问题,但是无法抵抗某个时间点上,某个链外数据源、特别是权重占比大的链外数据源中的数据被操控,导致短时间内(若干秒内)发生的违反数据正常波动的情况。The method in the embodiment in Figure 2 can effectively prevent the failure or error of a single off-chain data acquisition, but cannot resist at a certain point in time, a certain off-chain data source, especially the off-chain data source with a large weight. The data is manipulated, resulting in a violation of the normal data fluctuations in a short period of time (within a few seconds).
为了抵抗上述风险,在一个实施例中,步骤S302中分别计算当前区块对应的各种类型的请求集合的共识数据,包括:In order to resist the above risks, in one embodiment, in step S302, the consensus data of various types of request sets corresponding to the current block are calculated respectively, including:
S21,对于每种类型,确定当前区块中所述类型的所有喂价请求对应的喂价数据的中位数,并将所述中位数记为所述类型的请求集合的共识数据。S21: For each type, determine the median of the price feed data corresponding to all price feed requests of the type in the current block, and record the median as the consensus data of the request set of the type.
计算中位数,即将一组数据按照从大到小或从小到大的顺序排列。如果该组数 据中数据的个数为奇数,则取序列中间的那个数据为中位数;如果该组数据中数据的个数为偶数,则取序列中间的两个数据的平均数为中位数。Calculate the median, that is, arrange a set of data in ascending order or descending order. If the number of data in the group of data is odd, the data in the middle of the sequence is taken as the median; if the number of data in the group of data is even, the average of the two data in the middle of the sequence is taken as the median number.
继续步骤S301中的示例,将两个喂价数据从小到大排序为6,6.1。数据的个数为偶数,则中位数为(6+6.1)/2=6.05。Continuing the example in step S301, sort the two price feed data into 6, 6.1 from small to large. If the number of data is even, the median is (6+6.1)/2=6.05.
中位数不易受极端数值的影响,通过上述方法,对于每个区块,都取该区块对应的请求集合中的中位数作为共识数据,可以避免短时间内数据的异常波动,进而保证各个区块中共识数据的稳定性。The median is not easily affected by extreme values. Through the above method, for each block, the median in the request set corresponding to the block is taken as the consensus data, which can avoid abnormal data fluctuations in a short period of time, thereby ensuring The stability of consensus data in each block.
进一步的,为了在某一段相对较长的时间内保证共识数据的稳定性,可以采用如下方法。Further, in order to ensure the stability of the consensus data for a relatively long period of time, the following methods can be used.
在一个实施例中,每种类型的请求集合还包括当前区块之前的M个区块中每个区块对应的所述类型的所有喂价请求,M为正整数。相应的,步骤S302中分别计算当前区块对应的各种类型的请求集合的共识数据,包括:In an embodiment, each type of request set further includes all price feed requests of the type corresponding to each of the M blocks before the current block, and M is a positive integer. Correspondingly, the calculation of consensus data of various types of request sets corresponding to the current block in step S302 includes:
S22,对于每种类型,确定所述类型的请求集合中的所有喂价请求对应的喂价数据的中位数,并将所述中位数记为所述类型的喂价请求的共识数据。S22: For each type, determine the median of price feed data corresponding to all price feed requests in the request set of the type, and record the median as the consensus data of the price feed request of the type.
步骤S302的上述两个实施例中,相当于取了一个时间滑动窗口,然后计算该时间滑动窗口中的各个数据的中位数。在S21中,时间滑动窗口的大小为建立当前区块所用的时间段;在S22中,滑动窗口大小为建立当前区块和当前区块之前的M个区块所用的时间段。可见,S22中时间滑动窗口更大,这样计算出的共识数据,能够在较长的时间内保证相对的稳定。In the above two embodiments of step S302, it is equivalent to taking a time sliding window, and then calculating the median of each data in the time sliding window. In S21, the size of the time sliding window is the time period used to establish the current block; in S22, the size of the sliding window is the time period used to establish the current block and M blocks before the current block. It can be seen that the time sliding window in S22 is larger, and the consensus data calculated in this way can be relatively stable in a relatively long period of time.
本申请实施例通过获取所述区块链中当前区块对应的至少一种类型的请求集合,其中,每种类型的请求集合包括当前区块中所述类型的所有喂价请求,每个喂价请求中包括一个喂价数据,对于每种类型,根据该类型对应的请求集合中的多个喂价请求计算出一个共识数据,由于该共识数据是基于多个喂价请求得到的,因此可以避免某个不可靠的喂价请求中的喂价数据对链上数据的影响,保证了共识数据的稳定性;然后将所述共识数据添加到所述当前区块中。通过上述方法,能够在喂价时避免不可靠的链外数据对区块链的链上数据造成的数据波动,从而保证了区块链的稳定性。This embodiment of the application obtains at least one type of request set corresponding to the current block in the blockchain, where each type of request set includes all price feed requests of the type in the current block, each of which is The price request includes a price feed data. For each type, a consensus data is calculated based on multiple price feed requests in the request set corresponding to the type. Since the consensus data is obtained based on multiple price feed requests, it can be Avoid the influence of the price feed data in an unreliable price feed request on the data on the chain, and ensure the stability of the consensus data; and then add the consensus data to the current block. Through the above method, the data fluctuation caused by unreliable off-chain data to the on-chain data of the blockchain can be avoided during price feeding, thereby ensuring the stability of the blockchain.
应理解,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过 程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。It should be understood that the size of the sequence number of each step in the foregoing embodiment does not mean the order of execution. The execution sequence of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
对应于上文图2实施例所述的区块链喂价方法,图4示出了本申请实施例提供的区块链喂价装置的结构框图,为了便于说明,仅示出了与本申请实施例相关的部分。Corresponding to the block chain price feeding method described in the embodiment of Fig. 2 above, Fig. 4 shows a structural block diagram of the block chain price feeding device provided in an embodiment of the present application. The relevant part of the embodiment.
参照图4,该装置4包括:Referring to Figure 4, the device 4 includes:
第一获取单元41,用于对于每个时刻,获取至少一种类型的数据集,其中,每种类型的数据集中包括从多个链外数据源中获取到的当前时刻的所述类型的链外数据。The first obtaining unit 41 is configured to obtain at least one type of data set for each time, wherein each type of data set includes the type of chain at the current time obtained from multiple off-chain data sources External data.
加权计算单元42,用于根据各种类型的数据集分别计算当前时刻各种类型的加权数据,并根据当前时刻各种类型的加权数据向所述区块链提交喂价请求。The weighting calculation unit 42 is configured to calculate various types of weighted data at the current moment according to various types of data sets, and submit a price feed request to the blockchain according to the various types of weighted data at the current moment.
可选的,加权计算单元42还用于:Optionally, the weight calculation unit 42 is further configured to:
对于每种类型的数据集,对所述数据集中所有的链外数据进行加权求和处理,得到当前时刻所述类型的喂价数据。For each type of data set, weighted sum processing is performed on all off-chain data in the data set to obtain the price feed data of the type at the current moment.
其中,在所述加权求和处理中,第i个权值为所述数据集中第i个链外数据对应的数额占比,所述数额占比为链外数据源中所述类型的链外数据的数额在N个链外数据源中的占比,N为所述数据集对应的链外数据源的个数,N为正整数。Wherein, in the weighted sum processing, the i-th weight is the proportion of the amount corresponding to the i-th off-chain data in the data set, and the proportion of the amount is the type of off-chain data in the off-chain data source. The proportion of the amount of data among the N off-chain data sources, where N is the number of off-chain data sources corresponding to the data set, and N is a positive integer.
可选的,加权计算单元42包括:Optionally, the weight calculation unit 42 includes:
获取模块,用于对于每种类型,获取上一时刻所述类型的喂价数据。The obtaining module is used to obtain the price feed data of the type mentioned at the previous moment for each type.
生成模块,用于若上一时刻所述类型的喂价数据与当前时刻所述类型的喂价数据的差值的绝对值大于预设值,则将当前时刻所述类型的喂价数据生成所述类型的喂价请求,并将向所述区块链提交所述类型的喂价请求。The generating module is used to generate the price feed data of the type at the current time if the absolute value of the difference between the price feed data of the type at the previous time and the price feed data of the type at the current time is greater than the preset value The price feed request of the type mentioned above, and the price feed request of the type will be submitted to the blockchain.
对应于上文图3实施例所述的区块链喂价方法,图5示出了本申请另一实施例提供的区块链喂价装置的结构框图,为了便于说明,仅示出了与本申请实施例相关的部分。Corresponding to the block chain price feeding method described in the embodiment of Fig. 3 above, Fig. 5 shows a structural block diagram of a block chain price feeding device provided by another embodiment of the present application. The relevant part of the embodiment of this application.
参照图5,该装置5包括:Referring to Figure 5, the device 5 includes:
第二获取单元51,用于获取所述区块链中当前区块对应的至少一种类型的请求集合,其中,每种类型的请求集合包括当前区块中所述类型的所有喂价请求, 每个喂价请求中包括一个喂价数据。The second obtaining unit 51 is configured to obtain at least one type of request set corresponding to the current block in the blockchain, wherein each type of request set includes all price feed requests of the type in the current block, Each price feed request includes a price feed data.
共识数据计算单元52,用于分别计算当前区块对应的各种类型的请求集合的共识数据,并将所述共识数据添加到所述当前区块中。The consensus data calculation unit 52 is configured to respectively calculate consensus data of various types of request sets corresponding to the current block, and add the consensus data to the current block.
可选的,共识数据计算单元52包括:Optionally, the consensus data calculation unit 52 includes:
第一计算模块,用于对于每种类型,确定当前区块中所述类型的所有喂价请求对应的喂价数据的中位数,并将所述中位数记为所述类型的请求集合的共识数据。The first calculation module is used to determine the median of the price feed data corresponding to all price feed requests of the type in the current block for each type, and record the median as the request set of the type Consensus data.
可选的,每种类型的请求集合还包括当前区块之前的M个区块中每个区块对应的所述类型的所有喂价请求,M为正整数。Optionally, each type of request set further includes all price feed requests of the type corresponding to each of the M blocks before the current block, and M is a positive integer.
可选的,共识数据计算单元52还用于:Optionally, the consensus data calculation unit 52 is also used to:
对于每种类型,确定所述类型的请求集合中的所有喂价请求对应的喂价数据的中位数,并将所述中位数记为所述类型的喂价请求的共识数据。For each type, the median of the price feed data corresponding to all price feed requests in the request set of the type is determined, and the median is recorded as the consensus data of the price feed request of the type.
需要说明的是,上述装置/单元之间的信息交互、执行过程等内容,由于与本申请方法实施例基于同一构思,其具体功能及带来的技术效果,具体可参见方法实施例部分,此处不再赘述。It should be noted that the information interaction and execution process between the above-mentioned devices/units are based on the same concept as the method embodiment of this application, and its specific functions and technical effects can be found in the method embodiment section. I won't repeat it here.
另外,图4/5所示的区块链喂价装置可以是内置于现有的终端设备内的软件单元、硬件单元、或软硬结合的单元,也可以作为独立的挂件集成到所述终端设备中,还可以作为独立的终端设备存在。In addition, the blockchain pricing device shown in Figure 4/5 can be a software unit, a hardware unit, or a combination of software and hardware built into the existing terminal equipment, or it can be integrated into the terminal as an independent pendant. In the device, it can also exist as an independent terminal device.
所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,仅以上述各功能单元、模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能单元、模块完成,即将所述装置的内部结构划分成不同的功能单元或模块,以完成以上描述的全部或者部分功能。实施例中的各功能单元、模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中,上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。另外,各功能单元、模块的具体名称也只是为了便于相互区分,并不用于限制本申请的保护范围。上述系统中单元、模块的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that, for the convenience and conciseness of description, only the division of the above functional units and modules is used as an example. In practical applications, the above functions can be allocated to different functional units and modules as needed. Module completion, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist alone physically, or two or more units can be integrated into one unit. The above-mentioned integrated units can be hardware-based Formal realization can also be realized in the form of a software functional unit. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the protection scope of the present application. For the specific working process of the units and modules in the foregoing system, reference may be made to the corresponding process in the foregoing method embodiment, which will not be repeated here.
图6为本申请一实施例提供的终端设备的结构示意图。如图6所示,该实施例的终端设备6包括:至少一个处理器60(图6中仅示出一个)处理器、存储器61以及存储在所述存储器61中并可在所述至少一个处理器60上运行的计算机可读指令62,所述处理器60执行所述计算机可读指令62时实现上述各个区块链喂价方法实施例中的步骤。FIG. 6 is a schematic structural diagram of a terminal device provided by an embodiment of the application. As shown in FIG. 6, the terminal device 6 of this embodiment includes: at least one processor 60 (only one is shown in FIG. 6), a processor, a memory 61, and a processor that is stored in the memory 61 and can be processed in the at least one processor. The computer-readable instructions 62 running on the processor 60, when the processor 60 executes the computer-readable instructions 62, implement the steps in each of the above-mentioned blockchain pricing method embodiments.
所述终端设备可以是桌上型计算机、笔记本、掌上电脑及云端服务器等计算设备。该终端设备可包括,但不仅限于,处理器、存储器。本领域技术人员可以理解,图6仅仅是终端设备6的举例,并不构成对终端设备6的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件,例如还可以包括输入输出设备、网络接入设备等。The terminal device may be a computing device such as a desktop computer, a notebook, a palmtop computer, and a cloud server. The terminal device may include, but is not limited to, a processor and a memory. Those skilled in the art can understand that FIG. 6 is only an example of the terminal device 6 and does not constitute a limitation on the terminal device 6. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. , For example, can also include input and output devices, network access devices, and so on.
所称处理器60可以是中央处理单元(Central Processing Unit,CPU),该处理器60还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。The so-called processor 60 may be a central processing unit (Central Processing Unit, CPU), and the processor 60 may also be other general-purpose processors, digital signal processors (Digital Signal Processors, DSPs), and application specific integrated circuits (Application Specific Integrated Circuits). , ASIC), ready-made programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor or the like.
所述存储器61在一些实施例中可以是所述终端设备6的内部存储单元,例如终端设备6的硬盘或内存。所述存储器61在另一些实施例中也可以是所述终端设备6的外部存储设备,例如所述终端设备6上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。进一步地,所述存储器61还可以既包括所述终端设备6的内部存储单元也包括外部存储设备。所述存储器61用于存储操作系统、应用程序、引导装载程序(BootLoader)、数据以及其他程序等,例如所述计算机可读指令的程序代码等。所述存储器61还可以用于暂时地存储已经输出或者将要输出的数据。The memory 61 may be an internal storage unit of the terminal device 6 in some embodiments, such as a hard disk or a memory of the terminal device 6. In other embodiments, the memory 61 may also be an external storage device of the terminal device 6, such as a plug-in hard disk equipped on the terminal device 6, a smart media card (SMC), a secure digital (Secure Digital, SD) card, flash card (Flash Card), etc. Further, the memory 61 may also include both an internal storage unit of the terminal device 6 and an external storage device. The memory 61 is used to store an operating system, an application program, a boot loader (BootLoader), data, and other programs, for example, the program code of the computer-readable instruction. The memory 61 can also be used to temporarily store data that has been output or will be output.
本申请实施例还提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机可读指令,所述计算机可读指令被处理器执行时实现可实现上述各个方法实施例中的步骤。The embodiments of the present application also provide a computer-readable storage medium, the computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, they can realize step.
本申请实施例提供了一种计算机可读指令产品,当计算机可读指令产品在移动 终端上运行时,使得移动终端执行时实现可实现上述各个方法实施例中的步骤。The embodiments of the present application provide a computer-readable instruction product. When the computer-readable instruction product runs on a mobile terminal, the steps in the foregoing method embodiments can be realized when the mobile terminal is executed.
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请实现上述实施例方法中的全部或部分流程,可以通过计算机可读指令来指令相关的硬件来完成,所述的计算机可读指令可存储于一计算机可读存储介质中,该计算机可读指令在被处理器执行时,可实现上述各个方法实施例的步骤。其中,所述计算机可读指令包括计算机可读指令代码,所述计算机可读指令代码可以为源代码形式、对象代码形式、可执行文件或某些中间形式等。所述计算机可读介质至少可以包括:能够将计算机可读指令代码携带到终端设备的任何实体或装置、记录介质、计算机存储器、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、电载波信号、电信信号以及软件分发介质。例如U盘、移动硬盘、磁碟或者光盘等。在某些司法管辖区,根据立法和专利实践,计算机可读介质不可以是电载波信号和电信信号。If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium. Based on this understanding, the implementation of all or part of the processes in the above-mentioned embodiments and methods in this application can be accomplished by instructing relevant hardware through computer-readable instructions, and the computer-readable instructions can be stored in a computer-readable storage medium. When the computer-readable instructions are executed by the processor, they can implement the steps of the foregoing method embodiments. Wherein, the computer-readable instruction includes computer-readable instruction code, and the computer-readable instruction code may be in the form of source code, object code, executable file, or some intermediate form. The computer-readable medium may include at least any entity or device capable of carrying computer-readable instruction codes to a terminal device, a recording medium, a computer memory, a read-only memory (ROM, Read-Only Memory), and a random access memory ( RAM, Random Access Memory), electric carrier signal, telecommunications signal and software distribution medium. For example, U disk, mobile hard disk, floppy disk or CD-ROM, etc. In some jurisdictions, according to legislation and patent practices, computer-readable media cannot be electrical carrier signals and telecommunication signals.
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述或记载的部分,可以参见其它实施例的相关描述。In the above-mentioned embodiments, the description of each embodiment has its own focus. For parts that are not described in detail or recorded in an embodiment, reference may be made to related descriptions of other embodiments.
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。A person of ordinary skill in the art may realize that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be implemented by electronic hardware or a combination of computer software and electronic hardware. Whether these functions are executed by hardware or software depends on the specific application and design constraint conditions of the technical solution. Professionals and technicians can use different methods for each specific application to implement the described functions, but such implementation should not be considered beyond the scope of this application.
在本申请所提供的实施例中,应该理解到,所揭露的装置/网络设备和方法,可以通过其它的方式实现。例如,以上所描述的装置/网络设备实施例仅仅是示意性的,例如,所述模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通讯连接可以是通过一些接口,装置或单元的间接耦合或通讯连接,可以是电性,机械或其它的形式。In the embodiments provided in this application, it should be understood that the disclosed apparatus/network equipment and method may be implemented in other ways. For example, the device/network device embodiments described above are only illustrative. For example, the division of the modules or units is only a logical function division, and there may be other divisions in actual implementation, such as multiple units. Or components can be combined or integrated into another system, or some features can be omitted or not implemented. In addition, the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
以上所述实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围,均应包含在本申请的保护范围之内。The above-mentioned embodiments are only used to illustrate the technical solutions of the present application, not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still implement the foregoing The technical solutions recorded in the examples are modified, or some of the technical features are equivalently replaced; these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the application, and should be included in Within the scope of protection of this application.

Claims (20)

  1. 一种区块链喂价方法,其特征在于,应用于喂价节点,所述方法包括:A blockchain price feeding method, characterized in that it is applied to a price feeding node, and the method includes:
    对于每个时刻,获取至少一种类型的数据集,其中,每种类型的数据集中包括从多个链外数据源中获取到的当前时刻的所述类型的链外数据;For each moment, at least one type of data set is acquired, where each type of data set includes the type of off-chain data at the current moment obtained from multiple off-chain data sources;
    根据各种类型的数据集分别计算当前时刻各种类型的喂价数据,并根据当前时刻各种类型的喂价数据向所述区块链提交喂价请求。According to various types of data sets, various types of price feed data are calculated at the current moment, and various types of price feed data at the current moment are submitted to the blockchain to submit a price feed request.
  2. 如权利要求1所述的区块链喂价方法,其特征在于,所述根据各种类型的数据集分别计算当前时刻各种类型的喂价数据,包括:The blockchain price feeding method according to claim 1, wherein the calculation of various types of price feeding data at the current moment respectively according to various types of data sets includes:
    对于每种类型的数据集,将所述数据集中的所有链外数据进行加权求和处理,得到当前时刻所述类型的喂价数据;For each type of data set, perform weighted summation processing on all off-chain data in the data set to obtain the type of price feed data at the current moment;
    其中,在所述加权求和处理中,第i个权值为所述数据集中第i个链外数据对应的数额占比,所述数额占比为链外数据源中所述类型的链外数据的数额在N个链外数据源中的占比,N为所述数据集对应的链外数据源的个数,N为正整数。Wherein, in the weighted sum processing, the i-th weight is the proportion of the amount corresponding to the i-th off-chain data in the data set, and the proportion of the amount is the type of off-chain data in the off-chain data source. The proportion of the amount of data among the N off-chain data sources, where N is the number of off-chain data sources corresponding to the data set, and N is a positive integer.
  3. 如权利要求2所述的区块链喂价方法,其特征在于,所述根据当前时刻各种类型的喂价数据向所述区块链提交喂价请求,包括:The blockchain price feeding method according to claim 2, wherein the submitting a price feeding request to the blockchain according to various types of price feeding data at the current moment includes:
    对于每种类型,获取上一时刻所述类型的喂价数据;For each type, get the price feed data of the type mentioned at the previous moment;
    若上一时刻所述类型的喂价数据与当前时刻所述类型的喂价数据的差值的绝对值大于预设值,则将当前时刻所述类型的喂价数据生成所述类型的喂价请求,并将向所述区块链提交所述类型的喂价请求。If the absolute value of the difference between the price feed data of the type at the previous time and the price feed data of the type at the current time is greater than the preset value, the price feed data of the type at the current time is generated into the price feed of the type Request, and submit the type of price feed request to the blockchain.
  4. 一种区块链喂价方法,其特征在于,应用于区块链节点,所述方法包括:A blockchain price feeding method, characterized in that it is applied to a blockchain node, and the method includes:
    获取所述区块链中当前区块对应的至少一种类型的请求集合,其中,每种类型的请求集合包括当前区块中所述类型的所有喂价请 求,每个喂价请求中包括一个喂价数据;Obtain at least one type of request set corresponding to the current block in the blockchain, where each type of request set includes all price feed requests of the type in the current block, and each price feed request includes one Feed price data;
    分别计算当前区块对应的各种类型的请求集合的共识数据,并将所述共识数据添加到所述当前区块中。Calculate the consensus data of various types of request sets corresponding to the current block respectively, and add the consensus data to the current block.
  5. 如权利要求4所述的区块链喂价方法,其特征在于,所述分别计算当前区块对应的各种类型的请求集合的共识数据,包括:The blockchain pricing method according to claim 4, wherein said calculating the consensus data of various types of request sets corresponding to the current block respectively comprises:
    对于每种类型,确定当前区块中所述类型的所有喂价请求对应的喂价数据的中位数,并将所述中位数记为所述类型的请求集合的共识数据。For each type, determine the median of the price feed data corresponding to all price feed requests of the type in the current block, and record the median as the consensus data of the request set of the type.
  6. 如权利要求4所述的区块链喂价方法,其特征在于,每种类型的请求集合还包括当前区块之前的M个区块中每个区块对应的所述类型的所有喂价请求,M为正整数;The blockchain price feeding method according to claim 4, wherein each type of request set also includes all price feeding requests of the type corresponding to each of the M blocks before the current block , M is a positive integer;
    所述分别计算当前区块对应的各种类型的请求集合的共识数据,包括:The calculation of the consensus data of various types of request sets corresponding to the current block respectively includes:
    对于每种类型,确定所述类型的请求集合中的所有喂价请求对应的喂价数据的中位数,并将所述中位数记为所述类型的喂价请求的共识数据。For each type, the median of the price feed data corresponding to all price feed requests in the request set of the type is determined, and the median is recorded as the consensus data of the price feed request of the type.
  7. 一种区块链喂价装置,其特征在于,应用于喂价节点,所述装置包括:A blockchain price feeding device, characterized in that it is applied to a price feeding node, and the device includes:
    第一获取单元,用于对于每个时刻,获取至少一种类型的数据集,其中,每种类型的数据集中包括从多个链外数据源中获取到的当前时刻的所述类型的链外数据;The first acquiring unit is configured to acquire at least one type of data set for each moment, where each type of data set includes the type of off-chain at the current moment obtained from multiple off-chain data sources data;
    加权计算单元,用于根据各种类型的数据集分别计算当前时刻各种类型的加权数据,并根据当前时刻各种类型的加权数据向所述区块链提交喂价请求。The weighting calculation unit is used to calculate various types of weighted data at the current moment according to various types of data sets, and submit a price feed request to the blockchain according to the various types of weighted data at the current moment.
  8. 如权利要求7所述的区块链喂价装置,其特征在于,所述加权计算单元还用于:The block chain price feeding device according to claim 7, wherein the weighted calculation unit is further used for:
    对于每种类型的数据集,对所述数据集中所有的链外数据进行加权求和处理,得到当前时刻所述类型的喂价数据;For each type of data set, perform weighted summation processing on all off-chain data in the data set to obtain the type of price feed data at the current moment;
    其中,在所述加权求和处理中,第i个权值为所述数据集中第i个链外数据对应的数额占比,所述数额占比为链外数据源中所述类型的链外数据的数额在N个链外数据源中的占比,N为所述数据集对应的链外数据源的个数,N为正整数。Wherein, in the weighted sum processing, the i-th weight is the proportion of the amount corresponding to the i-th off-chain data in the data set, and the proportion of the amount is the type of off-chain data in the off-chain data source. The proportion of the amount of data among the N off-chain data sources, where N is the number of off-chain data sources corresponding to the data set, and N is a positive integer.
  9. 如权利要求8所述的区块链喂价装置,其特征在于,所述加权计算单元包括:The block chain price feeding device according to claim 8, wherein the weighted calculation unit comprises:
    获取模块,用于对于每种类型,获取上一时刻所述类型的喂价数据;The obtaining module is used to obtain the price feed data of the type mentioned at the previous moment for each type;
    生成模块,用于若上一时刻所述类型的喂价数据与当前时刻所述类型的喂价数据的差值的绝对值大于预设值,则将当前时刻所述类型的喂价数据生成所述类型的喂价请求,并将向所述区块链提交所述类型的喂价请求。The generating module is used to generate the price feed data of the type at the current time if the absolute value of the difference between the price feed data of the type at the previous time and the price feed data of the type at the current time is greater than the preset value The price feed request of the type mentioned above, and the price feed request of the type will be submitted to the blockchain.
  10. 一种区块链喂价装置,其特征在于,应用于区块链节点,所述装置包括:A block chain price feeding device is characterized in that it is applied to a block chain node, and the device includes:
    第二获取单元,用于获取所述区块链中当前区块对应的至少一种类型的请求集合,其中,每种类型的请求集合包括当前区块中所述类型的所有喂价请求,每个喂价请求中包括一个喂价数据;The second acquiring unit is configured to acquire at least one type of request set corresponding to the current block in the blockchain, wherein each type of request set includes all price feed requests of the type in the current block, each A price feed request includes a price feed data;
    共识数据计算单元,用于分别计算当前区块对应的各种类型的请求集合的共识数据,并将所述共识数据添加到所述当前区块中。The consensus data calculation unit is used to calculate the consensus data of various types of request sets corresponding to the current block, and add the consensus data to the current block.
  11. 如权利要求10所述的区块链喂价装置,其特征在于,所述共识数据计算单元包括:The blockchain pricing device of claim 10, wherein the consensus data calculation unit comprises:
    第一计算模块,用于对于每种类型,确定当前区块中所述类型的所有喂价请求对应的喂价数据的中位数,并将所述中位数记为所述类型的请求集合的共识数据。The first calculation module is used to determine the median of the price feed data corresponding to all price feed requests of the type in the current block for each type, and record the median as the request set of the type Consensus data.
  12. 如权利要求10所述的区块链喂价装置,其特征在于,每种类型的请求集合还包括当前区块之前的M个区块中每个区块对应的所述类型的所有喂价请求,M为正整数;The block chain price feeding device according to claim 10, wherein each type of request set further includes all price feeding requests of the type corresponding to each of the M blocks before the current block , M is a positive integer;
    所述共识数据计算单元还用于:The consensus data calculation unit is also used for:
    对于每种类型,确定所述类型的请求集合中的所有喂价请求对应的喂价数据的中位数,并将所述中位数记为所述类型的喂价请求的共识数据。For each type, the median of the price feed data corresponding to all price feed requests in the request set of the type is determined, and the median is recorded as the consensus data of the price feed request of the type.
  13. 一种终端设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机可读指令,其特征在于,所述处理器执行所述计算机可读指令时实现如下步骤:A terminal device including a memory, a processor, and computer-readable instructions stored in the memory and capable of running on the processor, wherein the processor executes the computer-readable instructions as follows step:
    对于每个时刻,获取至少一种类型的数据集,其中,每种类型的数据集中包括从多个链外数据源中获取到的当前时刻的所述类型的链外数据;For each moment, at least one type of data set is acquired, where each type of data set includes the type of off-chain data at the current moment obtained from multiple off-chain data sources;
    根据各种类型的数据集分别计算当前时刻各种类型的喂价数据,并根据当前时刻各种类型的喂价数据向所述区块链提交喂价请求。According to various types of data sets, various types of price feed data are calculated at the current moment, and various types of price feed data at the current moment are submitted to the blockchain to submit a price feed request.
  14. 如权利要求13所述的终端设备,其特征在于,所述根据各种类型的数据集分别计算当前时刻各种类型的喂价数据,包括:The terminal device according to claim 13, wherein the calculation of various types of price feed data at the current moment respectively according to various types of data sets comprises:
    对于每种类型的数据集,将所述数据集中的所有链外数据进行加权求和处理,得到当前时刻所述类型的喂价数据;For each type of data set, perform weighted summation processing on all off-chain data in the data set to obtain the type of price feed data at the current moment;
    其中,在所述加权求和处理中,第i个权值为所述数据集中第i个链外数据对应的数额占比,所述数额占比为链外数据源中所述类型的链外数据的数额在N个链外数据源中的占比,N为所述数据集对应的链外数据源的个数,N为正整数。Wherein, in the weighted sum processing, the i-th weight is the proportion of the amount corresponding to the i-th off-chain data in the data set, and the proportion of the amount is the type of off-chain data in the off-chain data source. The proportion of the amount of data among the N off-chain data sources, where N is the number of off-chain data sources corresponding to the data set, and N is a positive integer.
  15. 如权利要求14所述的终端设备,其特征在于,所述根据当前时刻各种类型的喂价数据向所述区块链提交喂价请求,包括:The terminal device of claim 14, wherein the submitting a price feed request to the blockchain according to various types of price feed data at the current moment includes:
    对于每种类型,获取上一时刻所述类型的喂价数据;For each type, get the price feed data of the type mentioned at the previous moment;
    若上一时刻所述类型的喂价数据与当前时刻所述类型的喂价数据的差值的绝对值大于预设值,则将当前时刻所述类型的喂价数据生成所述类型的喂价请求,并将向所述区块链提交所述类型的喂价请求。If the absolute value of the difference between the price feed data of the type at the previous time and the price feed data of the type at the current time is greater than the preset value, the price feed data of the type at the current time is generated into the price feed of the type Request, and submit the type of price feed request to the blockchain.
  16. 一种终端设备,包括存储器、处理器以及存储在所述存储器中并 可在所述处理器上运行的计算机可读指令,其特征在于,所述处理器执行所述计算机可读指令时实现如下步骤:A terminal device including a memory, a processor, and computer-readable instructions stored in the memory and capable of running on the processor, wherein the processor executes the computer-readable instructions as follows step:
    获取所述区块链中当前区块对应的至少一种类型的请求集合,其中,每种类型的请求集合包括当前区块中所述类型的所有喂价请求,每个喂价请求中包括一个喂价数据;Obtain at least one type of request set corresponding to the current block in the blockchain, where each type of request set includes all price feed requests of the type in the current block, and each price feed request includes one Feed price data;
    分别计算当前区块对应的各种类型的请求集合的共识数据,并将所述共识数据添加到所述当前区块中。Calculate the consensus data of various types of request sets corresponding to the current block respectively, and add the consensus data to the current block.
  17. 如权利要求16所述的终端设备,其特征在于,所述分别计算当前区块对应的各种类型的请求集合的共识数据,包括:The terminal device according to claim 16, wherein said separately calculating the consensus data of various types of request sets corresponding to the current block comprises:
    对于每种类型,确定当前区块中所述类型的所有喂价请求对应的喂价数据的中位数,并将所述中位数记为所述类型的请求集合的共识数据。For each type, determine the median of the price feed data corresponding to all price feed requests of the type in the current block, and record the median as the consensus data of the request set of the type.
  18. 如权利要求16所述的终端设备,其特征在于,每种类型的请求集合还包括当前区块之前的M个区块中每个区块对应的所述类型的所有喂价请求,M为正整数;The terminal device of claim 16, wherein each type of request set further includes all price feed requests of the type corresponding to each of the M blocks before the current block, and M is positive Integer
    所述分别计算当前区块对应的各种类型的请求集合的共识数据,包括:The calculation of the consensus data of various types of request sets corresponding to the current block respectively includes:
    对于每种类型,确定所述类型的请求集合中的所有喂价请求对应的喂价数据的中位数,并将所述中位数记为所述类型的喂价请求的共识数据。For each type, the median of the price feed data corresponding to all price feed requests in the request set of the type is determined, and the median is recorded as the consensus data of the price feed request of the type.
  19. 一种计算机可读存储介质,所述计算机可读存储介质存储有计算机可读指令,其特征在于,所述计算机可读指令被处理器执行时实现如权利要求1至3任一项所述的区块链喂价方法。A computer-readable storage medium, wherein the computer-readable storage medium stores computer-readable instructions, wherein when the computer-readable instructions are executed by a processor, the method according to any one of claims 1 to 3 is realized Blockchain price feeding method.
  20. 一种计算机可读存储介质,所述计算机可读存储介质存储有计算机可读指令,其特征在于,所述计算机可读指令被处理器执行时实现如权利要求4至6任一项所述的区块链喂价方法。A computer-readable storage medium, the computer-readable storage medium stores computer-readable instructions, wherein when the computer-readable instructions are executed by a processor, the method according to any one of claims 4 to 6 is realized Blockchain price feeding method.
PCT/CN2020/075846 2020-02-19 2020-02-19 Blockchain price feeding method and apparatus, and terminal device WO2021163920A1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
PCT/CN2020/075846 WO2021163920A1 (en) 2020-02-19 2020-02-19 Blockchain price feeding method and apparatus, and terminal device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2020/075846 WO2021163920A1 (en) 2020-02-19 2020-02-19 Blockchain price feeding method and apparatus, and terminal device

Publications (1)

Publication Number Publication Date
WO2021163920A1 true WO2021163920A1 (en) 2021-08-26

Family

ID=77390382

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/075846 WO2021163920A1 (en) 2020-02-19 2020-02-19 Blockchain price feeding method and apparatus, and terminal device

Country Status (1)

Country Link
WO (1) WO2021163920A1 (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190095880A1 (en) * 2017-09-22 2019-03-28 Kowala Cayman SEZC System and method of distributed, self-regulating, asset-tracking cryptocurrencies
US10354325B1 (en) * 2013-06-28 2019-07-16 Winklevoss Ip, Llc Computer-generated graphical user interface
US20190378128A1 (en) * 2018-06-08 2019-12-12 Rocket Lawyer Incorporated Cryptographic Contract Payment and Dispute Resolution System
CN110727712A (en) * 2019-10-15 2020-01-24 腾讯科技(深圳)有限公司 Data processing method and device based on block chain network, electronic equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10354325B1 (en) * 2013-06-28 2019-07-16 Winklevoss Ip, Llc Computer-generated graphical user interface
US20190095880A1 (en) * 2017-09-22 2019-03-28 Kowala Cayman SEZC System and method of distributed, self-regulating, asset-tracking cryptocurrencies
US20190378128A1 (en) * 2018-06-08 2019-12-12 Rocket Lawyer Incorporated Cryptographic Contract Payment and Dispute Resolution System
CN110727712A (en) * 2019-10-15 2020-01-24 腾讯科技(深圳)有限公司 Data processing method and device based on block chain network, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
JP7450678B2 (en) Constraint injection in unlocking transaction bytecode
US11599555B2 (en) Data manifest as a blockchain service
US11538105B2 (en) Cryptographic-asset collateral management
TWI754133B (en) Dual transaction method and system based on centralization and decentralization
JP2023134492A (en) Methods and apparatuses for cross-ledger transfers between distributed ledgers and systems using cross-ledger transfers
KR20200059234A (en) Smart contract execution with distributed reconciliation
CN112506747A (en) Business process monitoring method and device, electronic equipment and storage medium
EP4033440A1 (en) Consensus method, apparatus and device of block chain
WO2020103573A1 (en) Block chain-based network transaction signature method and device, and terminal equipment
CN115186304A (en) Transaction data verification method and system based on block chain
CN114219596B (en) Data processing method and related equipment based on decision tree model
US11743051B2 (en) Blockchain machine compute acceleration engine with a block verify and a block validate
CN111899018B (en) Order data processing method, device, server and storage medium
US20200304421A1 (en) Resource stabilization in a distributed network
WO2021163920A1 (en) Blockchain price feeding method and apparatus, and terminal device
CN109324963A (en) The method and terminal device of automatic test profitable result
CN111857883A (en) Page data checking method and device, electronic equipment and storage medium
CN111324669A (en) Block chain price feeding method, block chain price feeding device and terminal equipment
US11797644B2 (en) Identifying checksum mechanisms using linear equations
CN115471305A (en) Block chain-based electric charge reconciliation method, system, medium and electronic device

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: 20920527

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 09/12/2022)

122 Ep: pct application non-entry in european phase

Ref document number: 20920527

Country of ref document: EP

Kind code of ref document: A1