CN108920523A - Data query method, apparatus, equipment, system and medium on block chain - Google Patents

Data query method, apparatus, equipment, system and medium on block chain Download PDF

Info

Publication number
CN108920523A
CN108920523A CN201810565553.XA CN201810565553A CN108920523A CN 108920523 A CN108920523 A CN 108920523A CN 201810565553 A CN201810565553 A CN 201810565553A CN 108920523 A CN108920523 A CN 108920523A
Authority
CN
China
Prior art keywords
block
data
new
chain
maximum
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201810565553.XA
Other languages
Chinese (zh)
Other versions
CN108920523B (en
Inventor
颜亮
王晓明
陈延
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Lexin Software Technology Co Ltd
Original Assignee
Shenzhen Lexin Software Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Lexin Software Technology Co Ltd filed Critical Shenzhen Lexin Software Technology Co Ltd
Priority to CN201810565553.XA priority Critical patent/CN108920523B/en
Publication of CN108920523A publication Critical patent/CN108920523A/en
Application granted granted Critical
Publication of CN108920523B publication Critical patent/CN108920523B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

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

Abstract

The embodiment of the invention discloses data query method, apparatus, equipment, system and media on a kind of block chain.Wherein, method includes:Maximum history block block number derived from data has been carried out from reading in storage unit, and has obtained block block number on maximum chain from block chain;If the maximum history block block number is identical as block block number on the maximum chain, monitors new block on the block chain and event is added;When listening to the new block addition event, new block block number is obtained from the new block addition event;Data in the corresponding block of the new block block number are exported to Storage Middleware Applying, and add the new block block number in the storage unit, as new maximum history block block number;Multidimensional data query is carried out by the Storage Middleware Applying.The embodiment of the present invention can accurately export block data in real time, and realize that various dimensions are inquired.

Description

Data query method, apparatus, equipment, system and medium on block chain
Technical field
The present embodiments relate to data query method, apparatus in block chain technology more particularly to a kind of block chain, set Standby, system and medium.
Background technique
Block chain is a kind of solution of distributed common recognition cooperative system, is in the nature a distributed account book data Library.Block chain, which can be used for storing, is related to multi transaction record, the sensitive significant data of record etc. of transferring accounts.Pass through being total to for block chain itself Know the mechanism such as algorithm, cryptographic algorithm to guarantee the dates back charged in block chain, can not distort, and is respectively participated in block chain Necessarily are reached to the data of write-in by common recognition in a way for side.
In practical applications, it is often necessary to the data on block chain be inquired, with a bill based on block chain For system, write-in block chain is some bills collected money or pay the bill, query statistic a period of time under this business The total amount of fund or all bills of certain a kind of user are inside received, are necessary demands.And current block platform chain The data query scheme of block chain is not yet provided.
Summary of the invention
The embodiment of the present invention provides data query method, apparatus, equipment, system and medium on a kind of block chain, to realize The export of block data and various dimensions inquiry.
In a first aspect, the embodiment of the invention provides a kind of data query methods on block chain, including:
Maximum history block block number derived from data has been carried out from reading in storage unit, and has obtained maximum from block chain Block block number on chain;
If the maximum history block block number is identical as block block number on the maximum chain, monitor new on the block chain Event is added in block;
When listening to the new block addition event, new block block number is obtained from the new block addition event;
Data in the corresponding block of the new block block number are exported to Storage Middleware Applying, and in the storage unit The new block block number is added, as new maximum history block block number;
Multidimensional data query is carried out by the Storage Middleware Applying.
Second aspect, the embodiment of the invention also provides data query device on a kind of block chain, which includes:
Read module, for having carried out derived from data maximum history block block number from reading in storage unit, and from area Block block number on maximum chain is obtained on block chain;
Module is monitored, if identical as block block number on the maximum chain for the maximum history block block number, is monitored Event is added in new block on the block chain;
Module is obtained, for being obtained from the new block addition event when listening to the new block addition event New block block number;
Export and adding module, it is intermediate to storage for exporting the data in the corresponding block of the new block block number Part, and the new block block number is added in the storage unit, as new maximum history block block number;
Data inquiry module, for carrying out multidimensional data query by the Storage Middleware Applying.
The third aspect, the embodiment of the invention also provides a kind of data query equipment, data query equipment includes:
One or more processors;
Memory, for storing one or more programs,
When one or more of programs are executed by one or more of processors, so that one or more of processing Device realizes data query method on block chain described in any embodiment.
Fourth aspect, the embodiment of the invention also provides data query systems on a kind of block chain, including data query to set Standby, storage unit, Storage Middleware Applying;
The data query equipment is connect with the storage unit and the Storage Middleware Applying respectively;
The data query equipment, for having carried out derived from data maximum history block from reading in the storage unit Block number, and block block number on maximum chain is obtained from block chain;If in the maximum history block block number and the maximum chain Block block number is identical, monitors new block on the block chain and event is added;When listening to the new block addition event, from institute State acquisition new block block number in new block addition event;Data in the corresponding block of the new block block number are exported to storage Middleware, and new block block number is added in the storage unit, as new maximum history block block number;Pass through the storage Middleware carries out multidimensional data query;
The storage unit, for storing the block number for having carried out block derived from data;
The Storage Middleware Applying for the data in memory block and carries out multidimensional data query.
5th aspect, the embodiment of the invention also provides a kind of computer readable storage mediums, are stored thereon with computer Program realizes data query method on block chain described in any embodiment when the program is executed by processor.
In the embodiment of the present invention, by having carried out derived from data maximum history block block number from reading in storage unit, And block block number on maximum chain is obtained from block chain, if block block on the maximum history block block number and the maximum chain It is number identical, it monitors new block on the block chain and event is added, avoid the data for not saving the block being newly added;When listening to When stating new block event is added, new block block number is obtained from the new block addition event, and by the new block block number pair The data in block answered are exported to Storage Middleware Applying, on the basis of the block number of block, the block being newly added are navigated to, due to area Block block number has uniqueness, can accurately export the data of corresponding block, moreover, can be real by monitoring new block addition event When export new block data;By adding the new block block number in the storage unit, as new maximum history area Block block number, to be recorded in real time to derived block, when so as to export next time newer maximum history block block number and Block block number on maximum chain;Multidimensional data query is carried out by the Storage Middleware Applying, so that the data in block be exported Into Storage Middleware Applying, then in storage between various dimensions inquiry is realized in part, without relying on the query function of block chain itself.
Further, since the block on block chain is to connect according to chronological order, and block chain itself can Retrospect, can not distort.And the present embodiment pass through maximum history block block number it is identical as block block number on the maximum chain when, will supervise The data that the new block heard is added in the corresponding block of event are exported to Storage Middleware Applying, thus according to block on block chain Sequencing is added and carries out export operation, i.e., data sequencing and data content and block chain in certifiable Storage Middleware Applying Sequence and the data content difference of upper block are identical, guarantee accuracy derived from data.
Detailed description of the invention
Fig. 1 is the flow chart of data query method on a kind of block chain of the offer of the embodiment of the present invention one;
Fig. 2 is the flow chart of data query method on a kind of block chain provided by Embodiment 2 of the present invention;
Fig. 3 is the structural schematic diagram of data query device on a kind of block chain of the offer of the embodiment of the present invention three;
Fig. 4 is a kind of structural schematic diagram for data query equipment that the embodiment of the present invention four provides;
Fig. 5 is the structural schematic diagram of data query system on a kind of block chain of the offer of the embodiment of the present invention five.
Specific embodiment
The present invention is described in further detail with reference to the accompanying drawings and examples.It is understood that this place is retouched The specific embodiment stated is used only for explaining the present invention rather than limiting the invention.It also should be noted that in order to just Only the parts related to the present invention are shown in description, attached drawing rather than entire infrastructure.
Embodiment one
The present embodiment is applicable to the case where inquiring the data in block chain in block, and this method can be by block Data query device executes on chain.The main thought of the present embodiment is to export data into Storage Middleware Applying from block, Various dimensions inquiry is carried out to data using the various dimensions query function of Storage Middleware Applying in part between in storage.
Fig. 1 be the embodiment of the present invention one provide a kind of block chain on data query method flow chart, specifically include as Lower step:
S110, maximum history block block number has been carried out derived from data from reading in storage unit, and obtained from block chain Take block block number on maximum chain.
Block block number is the block number of block itself, is the unique identification of block.For example, the block number of wound generation block is 0, with wound The block number of the block of generation block connection is 1, and the block number followed by the block of connection is 2, and so on.In the present embodiment, often into The data of one block of row export, and are intended to store the block number of the block into storage unit, are based on this, storage unit is stored with The block number of whole block derived from data is carried out.In order to facilitate describing and distinguish, the block number in storage unit is known as history The block number of block on block chain is known as block block number on chain by block block number.Since block chain is ascending according to block number Chain type connection, the application is also the sequence ascending according to block number, the data of corresponding block is exported, so in storage unit most Big history block block number corresponds to block derived from newest progress data.In one example, storage unit be stored with block number 0,1,2, 3,3 be maximum history block block number, illustrates that the corresponding block of block number 3 is block derived from newest progress data, it is assumed that block number 3 is right The block number of the next block for the block answered is 4, then should carry out data export since the corresponding block of block number 4 next time.
The length of block chain be not it is unalterable, after a period of time, the end of block chain also has new block and is added. Sometimes, data query device exits data query system on block chain on block chain, can within data query device exit time There can be new block to be added.In this way, can be monitored new less than aforementioned when data query device accesses the system again on block chain The block of addition.In order to avoid the data in the block of not stored new addition, and lead to loss of data, in the present embodiment, preferably Ground reads from storage unit and has been counted after data query system on data query device access block chain on block chain According to derived maximum history block block number, and block block number on maximum chain is obtained from block chain.Certainly, block is being monitored every time On chain before new block addition event, executable S110.
If S120, maximum history block block number are identical as block block number on maximum chain, monitor new block on block chain and add Incoming event.
S130, when listen to new block be added event when, from new block addition event obtain new block block number.
If maximum history block block number is identical as block block number on maximum chain, illustrate on block chain newest block into The export of row data is then begun listening for new on block chain alternatively, being added within data query device exit time without new block Event is added in block.
Optionally, on Fabric block platform chain, whenever thering is new block to be added in a block chain, Fabric block Platform chain can issue a block event event, and event is added in referred to as new block, which includes the block number of new block.Area Data query device can monitor the new block in real time and event is added on block chain.When listening to new block addition event, from new district New block block number is obtained in block addition event.
S140, the data in the corresponding block of new block block number are exported to Storage Middleware Applying, and added in the memory unit Add new block block number, as new maximum history block block number.
Optionally, the data in the corresponding block of new block block number are exported to Storage Middleware Applying, including:Determining and new district The access interface of the corresponding block of block block number;It exports from access interface by the data in block to Storage Middleware Applying.Specifically, from Access interface parses the data in block, and the content parsed is copied in Storage Middleware Applying.
It exports by the data in block to Storage Middleware Applying, adds new block block number in the memory unit.Due to The block number is the block number for the block being newly added, and the block number for the block being newly added is greater than the block number of added block, then this is new Block block number is maximum history block block number new in storage unit.
S150, multidimensional data query is carried out by Storage Middleware Applying.
Storage Middleware Applying has data storage function and multidimensional data query function, and Storage Middleware Applying is to data therein Various dimensions statistics is carried out, summarizes, extract multiple critical fielies, so that business personnel carries out multidimensional data query.
Illustratively, querying condition is obtained, which includes block query context and inquiry field.Wherein it is possible to The inquiry request for receiving business personnel, obtains querying condition from inquiry request;Alternatively, presetting querying condition.Block is looked into It askes range and refers to the data for inquiring which block, can be the data of some block, be also possible to multiple continuous blocks or not The data of continuous block.Inquiry field refers to the content that needs are inquired, and in order to realize that various dimensions are inquired, inquiry field is that storage is intermediate The combination of at least one corresponding critical field of data in part.Then, block query context and inquiry field are transferred to and are deposited Middleware is stored up, for the determining data with the matched target block of query context of Storage Middleware Applying, and in the data of target block In, data query is carried out according to inquiry field.
In one example, the data for 3 blocks that block number is 1,2,3 are stored in Storage Middleware Applying.Wherein, block number 1 The data of block include expenditure and income of the user A in 2017, and the data of the block of block number 2 included user A in 2018 Expenditure and income, the data of the block of block number 3 include expenditure and income of the user B at 2017 and 2018.Storage Middleware Applying The data of 3 blocks are counted, summarized, extract critical field:User A, user B, 2017,2018, expenditure, income. Assuming that query context is the corresponding block of block number 3, inquiry field is user B, 2017, then Storage Middleware Applying is corresponding in block number 3 Block data in inquire expenditure and income of the user B in 2017.Assuming that query context is the corresponding area of block number 1,2,3 Block, inquiry field are user A, user B, income, then Storage Middleware Applying inquires in the data of the corresponding block of block number 1,2,3 User A and B was 2017 and income in 2018.
In some embodiments, Storage Middleware Applying itself has the function of the acquisition of querying condition, then is obtained by Storage Middleware Applying Querying condition is taken, and then in internal queries and the matched data of querying condition.
In the present embodiment, by having carried out derived from data maximum history block block number from reading in storage unit, and from Block block number on maximum chain is obtained on block chain, if maximum history block block number is identical as block block number on maximum chain, is monitored Event is added in new block on block chain, avoids the data for not saving the block being newly added;When listening to new block addition event, New block block number is obtained from new block addition event, and the data in the corresponding block of new block block number are exported into storage Between part navigate to the block being newly added on the basis of the block number of block, due to block block number have uniqueness, can accurately lead The data of block are corresponded to out, moreover, can export the data of new block in real time by monitoring new block addition event;By depositing New block block number is added in storage unit, as new maximum history block block number, so that derived block is recorded in real time, Newer maximum history block block number and block block number on maximum chain when so as to export next time;It is carried out by Storage Middleware Applying more Dimension data inquiry, so that the data in block be exported in Storage Middleware Applying, then in storage between realize various dimensions in part Inquiry, without relying on the query function of block chain itself.
Further, since the block on block chain is to connect according to chronological order, and block chain itself can Retrospect, can not distort.And the present embodiment pass through maximum history block block number it is identical as block block number on maximum chain when, will listen to The data that are added in the corresponding block of event of new block export to Storage Middleware Applying, thus according to the addition of block on block chain Sequencing carries out export operation, i.e., data sequencing and data content and the area block Lian Shang in certifiable Storage Middleware Applying Sequence and the data content difference of block are identical, guarantee accuracy derived from data.
Embodiment two
The present embodiment advanced optimizes above-described embodiment, specifically joined maximum on the basis of the above embodiments History block block number is less than the case where block block number on maximum chain.Fig. 2 is on a kind of block chain provided by Embodiment 2 of the present invention The flow chart of data query method, includes the following steps:
S210, maximum history block block number has been carried out derived from data from reading in storage unit, and obtained from block chain Take block block number on maximum chain.
Wherein, on maximum chain block block number be the block being newly joined on current time block chain block number.
S220, judge whether maximum history block block number and block block number on maximum chain are identical, if they are the same, continue to execute S230.If maximum history block block number is less than block block number on maximum chain, S270 is jumped to.If maximum history block block number Greater than block block number on maximum chain, S290 is jumped to.
S230, new block addition event on block chain is monitored.
When maximum history block block number is identical as block block number on maximum chain, illustrate number in the block on current block chain According to exporting into Storage Middleware Applying, then it can monitor new block and event is added.
Data query device can monitor new block in real time and event is added on block chain, until data query device on block chain Exit data query system on block chain.
S240, when listen to new block be added event when, from new block addition event obtain new block block number.
S250, the data in the corresponding block of new block block number are exported to Storage Middleware Applying, and added in the memory unit Add new block block number, as new maximum history block block number.Continue to execute S260;Meanwhile S240 is jumped to, to continue to store Data in new block.
S260, multidimensional data query is carried out by Storage Middleware Applying, terminates this operation.
In the present embodiment, Storage Middleware Applying is search server.Search server carries out various dimensions system to data therein It counts, summarize, extracting multiple critical fielies, so that business personnel carries out multidimensional data query.
Illustratively, which is the search server Elasticsearch based on Lucene. Elasticsearch is the full-text search engine of a distributed multi-user ability, is developed based on Java, and conduct Open source code publication under Apache license terms, is Enterprise search engine currently popular.Designed in cloud computing, energy Enough reach real-time search, stablizes, it is reliably, quickly, easy to install and use.
Elasticsearch is substantially a distributed data base, and multiple servers is allowed to cooperate.For write-in Data therein, Elasticsearch can index all critical fielies, be written in a reverse indexing after treatment (Inverted Index).When carrying out data query, the index is directly searched, all correlations are indexed by the index Critical field enrich querying condition to support the inquiry field that is obtained by any combination of critical field.
S270, the data in 1 corresponding block are added to export to Storage Middleware Applying maximum history block block number.It continues to execute S280。
If maximum history block block number is less than block block number on maximum chain, illustrate to add from maximum history block block number 1 to Data on maximum chain in the corresponding block of block block number do not import in Storage Middleware Applying.Then, from maximum history block block number Add 1, successively exports the data in the block on block chain into Storage Middleware Applying.
The block number of the new derived block of S280, in the memory unit addition, as new maximum history block block number.It jumps To S210.
As soon as the data of every export block, the block number of the block are added in storage unit, so as to by comparing most Block block number is to determine whether there are also the blocks not being directed into Storage Middleware Applying in big history block block number and maximum chain.
Optionally, storage unit is distributed application program coordination service software or database, distributed application program Coordination service software is, for example, zookeeper.
S290, block block number on chain maximum in Storage Middleware Applying is added 1 to the block number pair between maximum history block block number The data of the block answered are deleted, and block block number on chain maximum in storage unit is added 1 between maximum history block block number Block number is deleted.Jump to S210.
If maximum history block block number is greater than block block number on maximum chain, illustrate that data are wrong in Storage Middleware Applying, then By block block number on chain maximum in Storage Middleware Applying add 1 to the corresponding block of block number between maximum history block block number data It deletes, and adds 1 to delete to the block number between maximum history block block number block block number on chain maximum in storage unit.Then, It returns and executes S210.
In the present embodiment, if maximum history block block number is less than block block number on maximum chain, by maximum history block block Number plus 1 corresponding block in data export to Storage Middleware Applying;The block number of the new derived block of addition in the memory unit, makees For new maximum history block block number, until new maximum history block block number is identical as block block number on maximum chain, monitoring New block is added event and avoids loss of data so that the data on block chain are directed into Storage Middleware Applying on block chain, protects Demonstrate,prove accuracy derived from data.
Embodiment three
Fig. 3 is the structural schematic diagram of data query device on a kind of block chain of the offer of the embodiment of the present invention three, including:It reads Modulus block 31 monitors module 32, obtains module 33, export and adding module 34, data inquiry module 35.
Read module 31, for having carried out derived from data maximum history block block number from reading in storage unit, and from Block block number on maximum chain is obtained on block chain;
Module 32 is monitored, if identical as block block number on maximum chain for maximum history block block number, monitors block chain Event is added in upper new block;
Module 33 is obtained, for obtaining new block from new block addition event when listening to new block addition event Block number;
Export and adding module 34, for exporting the data in the corresponding block of new block block number to Storage Middleware Applying, And new block block number is added in the memory unit, as new maximum history block block number;
Data inquiry module 35, for carrying out multidimensional data query by Storage Middleware Applying.
In the present embodiment, by having carried out derived from data maximum history block block number from reading in storage unit, and from Block block number on maximum chain is obtained on block chain, if maximum history block block number is identical as block block number on maximum chain, is monitored Event is added in new block on block chain, avoids the data for not saving the block being newly added;When listening to new block addition event, New block block number is obtained from new block addition event, and the data in the corresponding block of new block block number are exported into storage Between part navigate to the block being newly added on the basis of the block number of block, due to block block number have uniqueness, can accurately lead The data of block are corresponded to out, moreover, can export the data of new block in real time by monitoring new block addition event;By depositing New block block number is added in storage unit, as new maximum history block block number, so that derived block is recorded in real time, Newer maximum history block block number and block block number on maximum chain when so as to export next time;It is carried out by Storage Middleware Applying more Dimension data inquiry, so that the data in block be exported in Storage Middleware Applying, then in storage between realize various dimensions in part Inquiry, without relying on the query function of block chain itself.
Further, since the block on block chain is to connect according to chronological order, and block chain itself can Retrospect, can not distort.And the present embodiment pass through maximum history block block number it is identical as block block number on maximum chain when, will listen to The data that are added in the corresponding block of event of new block export to Storage Middleware Applying, thus according to the addition of block on block chain Sequencing carries out export operation, i.e., data sequencing and data content and the area block Lian Shang in certifiable Storage Middleware Applying Sequence and the data content difference of block are identical, guarantee accuracy derived from data.
In an optional embodiment, export and adding module 34 are less than most if being also used to maximum history block block number Block block number on big chain, adds the data in 1 corresponding block to export to Storage Middleware Applying maximum history block block number;It is storing The block number that new derived block is added in unit returns as new maximum history block block number and executes maximum history block block Number read operation, until maximum history block block number is identical as block block number on maximum chain.
In an optional embodiment, exports and led with adding module 34 by the data in the corresponding block of new block block number When out to Storage Middleware Applying, specifically for determining the access interface of block corresponding with new block block number;From access interface by area Data in block are exported to Storage Middleware Applying.
In an optional embodiment, Storage Middleware Applying is search server;Storage unit is distributed application program association Adjust service software or database.
In an optional embodiment, data inquiry module 35 is carrying out multidimensional data query by Storage Middleware Applying When, for obtaining querying condition, querying condition includes block query context and inquiry field, and inquiry field is in Storage Middleware Applying At least one corresponding critical field of data combination;Block query context and inquiry field are transferred to Storage Middleware Applying, For the determining data with the matched target block of query context of Storage Middleware Applying, and in the data of target block, according to looking into It askes field and carries out data query.
Data query device can be performed any embodiment of that present invention and be provided on block chain provided by the embodiment of the present invention Block chain on data query method, have the corresponding functional module of execution method and beneficial effect.
Example IV
Fig. 4 is a kind of structural schematic diagram for data query equipment that the embodiment of the present invention four provides, as shown in figure 4, the number It include processor 40, memory 41 according to query facility;The quantity of processor 40 can be one or more in data query equipment, In Fig. 4 by taking a processor 40 as an example;Processor 40, memory 41 in data query equipment can pass through bus or its other party Formula connects, in Fig. 4 for being connected by bus.
Memory 41 is used as a kind of computer readable storage medium, can be used for storing software program, journey can be performed in computer Sequence and module, if the corresponding program instruction/module of data query method on the block chain in the embodiment of the present invention is (for example, area Read module 31, monitoring module 32, acquisition module 33, export and adding module 34, data on block chain in data query device Enquiry module 35).Software program, instruction and the module that processor 40 is stored in memory 41 by operation, thereby executing The various function application and data processing of data query equipment realize data query method on above-mentioned block chain.
Memory 41 can mainly include storing program area and storage data area, wherein storing program area can store operation system Application program needed for system, at least one function;Storage data area, which can be stored, uses created data etc. according to terminal.This Outside, memory 41 may include high-speed random access memory, can also include nonvolatile memory, for example, at least a magnetic Disk storage device, flush memory device or other non-volatile solid state memory parts.In some instances, memory 41 can be further Including the memory remotely located relative to processor 40, these remote memories can be set by network connection to data query It is standby.The example of above-mentioned network includes but is not limited to internet, intranet, local area network, mobile radio communication and combinations thereof.
Embodiment five
Fig. 5 is the structural schematic diagram of data query system on a kind of block chain of the offer of the embodiment of the present invention five, including number According to query facility 51, storage unit 52, Storage Middleware Applying 53, in addition, Fig. 5 also shows the area connecting with data query equipment 51 Block chain 50.Data query equipment 51 is connect with storage unit 52 and Storage Middleware Applying 53 respectively.Storage Middleware Applying is search service Device;Storage unit is distributed application program coordination service software or database.
Data query equipment 51, for having carried out derived from data maximum history block block from reading in storage unit 52 Number, and block block number on maximum chain is obtained from block chain 50;If block block number on maximum history block block number and maximum chain It is identical, it monitors new block on block chain and event is added;When listening to new block addition event, obtained from new block addition event Take new block block number;Data in the corresponding block of new block block number are exported to Storage Middleware Applying 53, and in storage unit 52 Middle addition new block block number, as new maximum history block block number;Multidimensional data query is carried out by Storage Middleware Applying 53.
Storage unit 52, for storing the block number for having carried out block derived from data.
Storage Middleware Applying 53 for the data in memory block and carries out multidimensional data query.
In an optional embodiment, data query equipment 51 is also used to counted reading from storage unit 52 It is obtained on maximum chain after block block number according to derived maximum history block block number, and from block chain 50, if maximum history Block block number is less than block block number on maximum chain, adds the data in 1 corresponding block to export to depositing maximum history block block number Store up middleware 53;The block number that new derived block is added in storage unit 52 is returned as new maximum history block block number The read operation for executing maximum history block block number, until maximum history block block number is identical as block block number on maximum chain.
In an optional embodiment, data query equipment 51 is exported by the data in the corresponding block of new block block number When to Storage Middleware Applying, it is used for:Determine the access interface of block corresponding with new block block number;It will be in block from access interface Data are exported to Storage Middleware Applying.
In an optional embodiment, data query equipment 51 is carrying out multidimensional data query by Storage Middleware Applying 53 When, it is specifically used for:Querying condition is obtained, querying condition includes block query context and inquiry field, and inquiry field is in storage Between at least one corresponding critical field of data in part combination;Block query context and inquiry field are transferred in storage Between part 53, for the determining data with the matched target block of query context of Storage Middleware Applying 53, and in the data of target block In, data query is carried out according to inquiry field.
Embodiment six
The embodiment of the present invention six also provides a kind of computer readable storage medium for being stored thereon with computer program, calculates When being executed by computer processor for executing a kind of data query method on block chain, this method includes machine program:
Maximum history block block number derived from data has been carried out from reading in storage unit, and has obtained maximum from block chain Block block number on chain;
If maximum history block block number is identical as block block number on maximum chain, monitors new block on block chain and thing is added Part;
When listening to new block addition event, new block block number is obtained from new block addition event;
Data in the corresponding block of new block block number are exported to Storage Middleware Applying, and add new district in the memory unit Block block number, as new maximum history block block number;
Multidimensional data query is carried out by Storage Middleware Applying.
Certainly, a kind of computer-readable storage medium being stored thereon with computer program provided by the embodiment of the present invention Matter, computer program are not limited to method operation as above, block chain provided by any embodiment of the invention can also be performed Relevant operation in upper data query method.
By the description above with respect to embodiment, it is apparent to those skilled in the art that, the present invention It can be realized by software and required common hardware, naturally it is also possible to which by hardware realization, but in many cases, the former is more Good embodiment.Based on this understanding, technical solution of the present invention substantially in other words contributes to the prior art Part can be embodied in the form of software products, which can store in computer readable storage medium In, floppy disk, read-only memory (Read-Only Memory, ROM), random access memory (Random such as computer Access Memory, RAM), flash memory (FLASH), hard disk or CD etc., including some instructions are with so that a computer is set The method that standby (can be personal computer, server or the network equipment etc.) executes each embodiment of the present invention.
It is worth noting that, on above-mentioned block chain in the embodiment of data query device, included each unit and mould Block is only divided according to the functional logic, but is not limited to the above division, and is as long as corresponding functions can be realized It can;In addition, the specific name of each functional unit is also only for convenience of distinguishing each other, the protection model being not intended to restrict the invention It encloses.
Note that the above is only a better embodiment of the present invention and the applied technical principle.It will be appreciated by those skilled in the art that The invention is not limited to the specific embodiments described herein, be able to carry out for a person skilled in the art it is various it is apparent variation, It readjusts and substitutes without departing from protection scope of the present invention.Therefore, although being carried out by above embodiments to the present invention It is described in further detail, but the present invention is not limited to the above embodiments only, without departing from the inventive concept, also It may include more other equivalent embodiments, and the scope of the invention is determined by the scope of the appended claims.

Claims (10)

1. a kind of data query method on block chain, which is characterized in that including:
Maximum history block block number derived from data has been carried out from reading in storage unit, and has been obtained on maximum chain from block chain Block block number;
If the maximum history block block number is identical as block block number on the maximum chain, new block on the block chain is monitored Addition event;
When listening to the new block addition event, new block block number is obtained from the new block addition event;
Data in the corresponding block of the new block block number are exported to Storage Middleware Applying, and are added in the storage unit The new block block number, as new maximum history block block number;
Multidimensional data query is carried out by the Storage Middleware Applying.
2. the method according to claim 1, wherein having carried out data export in described read from storage unit Maximum history block block number, and obtain from block chain on maximum chain after block block number, further include:
If the maximum history block block number is less than block block number on the maximum chain, maximum history block block number is added 1 pair The data in block answered are exported to the Storage Middleware Applying;
The block number that new derived block is added in the storage unit is returned and is executed as new maximum history block block number The read operation of maximum history block block number, until maximum history block block number is identical as block block number on the maximum chain.
3. the method according to claim 1, wherein the data in the corresponding block of the new block block number are led Out to Storage Middleware Applying, including:
Determine the access interface of block corresponding with the new block block number;
It exports from the access interface by the data in the block to Storage Middleware Applying.
4. the method according to claim 1, wherein the Storage Middleware Applying is search server;
The storage unit is distributed application program coordination service software or database.
5. method according to claim 1-4, which is characterized in that described more by Storage Middleware Applying progress Dimension data inquiry, including:
Querying condition is obtained, the querying condition includes block query context and inquiry field, and the inquiry field is described deposits Store up the combination of at least one corresponding critical field of data in middleware;
The block query context and the inquiry field are transferred to the Storage Middleware Applying, so that the Storage Middleware Applying is true The fixed data with the matched target block of the query context, and in the data of the target block, according to the inquiry word Duan Jinhang data query.
6. data query device on a kind of block chain, which is characterized in that including:
Read module, for having carried out derived from data maximum history block block number from reading in storage unit, and from block chain Block block number on the maximum chain of upper acquisition;
Module is monitored, if identical as block block number on the maximum chain for the maximum history block block number, described in monitoring Event is added in new block on block chain;
Module is obtained, for obtaining new district from the new block addition event when listening to the new block addition event Block block number;
Export and adding module, for exporting the data in the corresponding block of the new block block number to Storage Middleware Applying, and The new block block number is added in the storage unit, as new maximum history block block number;
Data inquiry module, for carrying out multidimensional data query by the Storage Middleware Applying.
7. device according to claim 6, which is characterized in that
The export and adding module, if being also used to the maximum history block block number is less than block block on the maximum chain Number, add the data in 1 corresponding block to export to the Storage Middleware Applying maximum history block block number;
The block number that new derived block is added in the storage unit is returned and is executed as new maximum history block block number The read operation of maximum history block block number, until maximum history block block number is identical as block block number on the maximum chain.
8. a kind of data query equipment, which is characterized in that the data query equipment includes:
One or more processors;
Memory, for storing one or more programs,
When one or more of programs are executed by one or more of processors, so that one or more of processors are real Now such as data query method on block chain as claimed in any one of claims 1 to 5.
9. data query system on a kind of block chain, including data query equipment, storage unit, Storage Middleware Applying;
The data query equipment is connect with the storage unit and the Storage Middleware Applying respectively;
The data query equipment, for having carried out derived from data maximum history block block from reading in the storage unit Number, and block block number on maximum chain is obtained from block chain;If the maximum history block block number and the maximum area Lian Shang Block block number is identical, monitors new block on the block chain and event is added;When listening to the new block event being added, from described New block block number is obtained in new block addition event;Data in the corresponding block of the new block block number are exported into storage Between part, and in the storage unit add new block block number, as new maximum history block block number;By in the storage Between part carry out multidimensional data query;
The storage unit, for storing the block number for having carried out block derived from data;
The Storage Middleware Applying for the data in memory block and carries out multidimensional data query.
10. a kind of computer readable storage medium, is stored thereon with computer program, which is characterized in that the program is by processor It is realized when execution such as data query method on block chain as claimed in any one of claims 1 to 5.
CN201810565553.XA 2018-06-04 2018-06-04 Method, device, equipment, system and medium for querying data on block chain Active CN108920523B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810565553.XA CN108920523B (en) 2018-06-04 2018-06-04 Method, device, equipment, system and medium for querying data on block chain

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810565553.XA CN108920523B (en) 2018-06-04 2018-06-04 Method, device, equipment, system and medium for querying data on block chain

Publications (2)

Publication Number Publication Date
CN108920523A true CN108920523A (en) 2018-11-30
CN108920523B CN108920523B (en) 2020-09-29

Family

ID=64419634

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810565553.XA Active CN108920523B (en) 2018-06-04 2018-06-04 Method, device, equipment, system and medium for querying data on block chain

Country Status (1)

Country Link
CN (1) CN108920523B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110046914A (en) * 2019-03-14 2019-07-23 海南鑫镁科技有限公司 A kind of block chain retroactive method towards food and drug safety supervision
CN110069533A (en) * 2019-04-09 2019-07-30 深圳前海微众银行股份有限公司 A kind of event subscription method and device based on block chain
CN111177182A (en) * 2019-12-19 2020-05-19 达闼科技成都有限公司 Data query method and device, storage medium and electronic equipment
CN111831744A (en) * 2020-06-05 2020-10-27 广东科学技术职业学院 DAPP on-chain data retrieval system, method and medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102779127A (en) * 2011-05-11 2012-11-14 宏碁股份有限公司 Terminal device and file synchronization method
CN103605809A (en) * 2013-12-10 2014-02-26 厦门诚创网络有限公司 Data synchronization method
US20170091726A1 (en) * 2015-09-07 2017-03-30 NXT-ID, Inc. Low bandwidth crypto currency transaction execution and synchronization method and system
CN106777272A (en) * 2016-12-29 2017-05-31 成都康赛信息技术有限公司 A kind of comparing and synchronous method
CN107657059A (en) * 2017-10-20 2018-02-02 中国银行股份有限公司 Method of data synchronization, middleware and system based on block chain application system
CN107943951A (en) * 2017-11-24 2018-04-20 中钞信用卡产业发展有限公司杭州区块链技术研究院 A kind of search method and system of block chain business information

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102779127A (en) * 2011-05-11 2012-11-14 宏碁股份有限公司 Terminal device and file synchronization method
CN103605809A (en) * 2013-12-10 2014-02-26 厦门诚创网络有限公司 Data synchronization method
US20170091726A1 (en) * 2015-09-07 2017-03-30 NXT-ID, Inc. Low bandwidth crypto currency transaction execution and synchronization method and system
CN106777272A (en) * 2016-12-29 2017-05-31 成都康赛信息技术有限公司 A kind of comparing and synchronous method
CN107657059A (en) * 2017-10-20 2018-02-02 中国银行股份有限公司 Method of data synchronization, middleware and system based on block chain application system
CN107943951A (en) * 2017-11-24 2018-04-20 中钞信用卡产业发展有限公司杭州区块链技术研究院 A kind of search method and system of block chain business information

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110046914A (en) * 2019-03-14 2019-07-23 海南鑫镁科技有限公司 A kind of block chain retroactive method towards food and drug safety supervision
CN110069533A (en) * 2019-04-09 2019-07-30 深圳前海微众银行股份有限公司 A kind of event subscription method and device based on block chain
CN111177182A (en) * 2019-12-19 2020-05-19 达闼科技成都有限公司 Data query method and device, storage medium and electronic equipment
CN111831744A (en) * 2020-06-05 2020-10-27 广东科学技术职业学院 DAPP on-chain data retrieval system, method and medium
CN111831744B (en) * 2020-06-05 2023-06-06 广东科学技术职业学院 System, method and medium for searching data on DAPP chain

Also Published As

Publication number Publication date
CN108920523B (en) 2020-09-29

Similar Documents

Publication Publication Date Title
CN108920523A (en) Data query method, apparatus, equipment, system and medium on block chain
CN108536761A (en) Report data querying method and server
CN108681590A (en) Incremental data processing method and processing device, computer equipment, computer storage media
CN110245145A (en) Structure synchronization method and apparatus of the relevant database to Hadoop database
CN110912757B (en) Service monitoring method and server
CN111400288A (en) Data quality inspection method and system
CN103152391A (en) Journal output method and device
CN111258978A (en) Data storage method
CN115408193A (en) Method and device for processing error codes among multiple modules
CN114297204A (en) Data storage and retrieval method and device for heterogeneous data source
CN104750806A (en) Large data query method and system
CN106940710B (en) Information pushing method and device
CN108664322A (en) Data processing method and system
CN109710263B (en) Code compiling method and device, storage medium and electronic equipment
CN104317820B (en) Statistical method and device for report forms
CN116501761A (en) Query optimization method, device and storage medium
CN102402420B (en) Resolve observable collections
CN110363515B (en) Rights and interests card account information inquiry method, system, server and readable storage medium
CN114116908A (en) Data management method and device and electronic equipment
CN113190731A (en) Label construction method, device, equipment and storage medium
CN113297245A (en) Method and device for acquiring execution information
CN111651479A (en) Article evaluation method, device and related equipment
CN111090670A (en) Data pre-polymerization method, system, computing equipment and storage medium
CN112784119B (en) Data query and synchronization optimization method and device
US8423532B1 (en) Managing data indexed by a search engine

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
PE01 Entry into force of the registration of the contract for pledge of patent right
PE01 Entry into force of the registration of the contract for pledge of patent right

Denomination of invention: Data query methods, devices, devices, systems, and media on blockchain

Effective date of registration: 20230925

Granted publication date: 20200929

Pledgee: Luohu sub branch of Shenzhen Rural Commercial Bank Co.,Ltd.

Pledgor: SHENZHEN LEXIN SOFTWARE TECHNOLOGY Co.,Ltd.

Registration number: Y2023980058548