CN110727655B - Method, device, equipment and medium for building shadow database of block chain - Google Patents
Method, device, equipment and medium for building shadow database of block chain Download PDFInfo
- Publication number
- CN110727655B CN110727655B CN201910852917.7A CN201910852917A CN110727655B CN 110727655 B CN110727655 B CN 110727655B CN 201910852917 A CN201910852917 A CN 201910852917A CN 110727655 B CN110727655 B CN 110727655B
- Authority
- CN
- China
- Prior art keywords
- data
- block
- information
- block chain
- tool
- 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.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/21—Design, administration or maintenance of databases
- G06F16/211—Schema design and management
- G06F16/212—Schema design and management with details for data modelling support
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/22—Indexing; Data structures therefor; Storage structures
- G06F16/2282—Tablespace storage structures; Management thereof
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/23—Updating
- G06F16/2358—Change logging, detection, and notification
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/27—Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Computing Systems (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention discloses a method, a device, equipment and a medium for constructing a shadow database of a block chain, wherein the method comprises the steps of acquiring a configuration file, wherein the configuration file records block chain configuration information, shadow database configuration information, an extraction strategy and analysis information; positioning a current data table according to the configuration information of the shadow database in the configuration file; positioning a target block according to the block chain configuration information and the extraction strategy information in the configuration file, and extracting block data in the target block; acquiring an analysis strategy corresponding to the block data according to analysis information in the configuration file, and analyzing the block data into corresponding service data according to the analysis strategy; and storing the service data into a current data table. The invention carries out statistical analysis and data mining on the service data pointed by the data on the block chain by constructing the block chain shadow database, thereby supporting the access to the service data.
Description
Technical Field
The present invention relates to the field of blockchains, and in particular, to a method, an apparatus, a device, and a medium for constructing a shadow database of a blockchain.
Background
The blockchain is essentially a decentralized database, which is a string of data blocks associated by using cryptography, each data block contains information of a batch of network transactions, and the information is used for verifying the validity (anti-counterfeiting) of the information and generating the next block. The block chain has a wide application prospect as a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like, but a data structure in the block chain is incompatible with a data structure used in actual service, and data information stored in the block chain is discontinuous in service, so that specified service data are difficult to effectively inquire from the block chain, and service-level data analysis and data mining are more difficult to perform based on the data in the block chain.
Disclosure of Invention
In order to solve the technical problems that data in a blockchain is difficult to be directly used in a service and is difficult to be directly used for data analysis and data mining in a service level in the prior art, embodiments of the present invention provide a shadow database construction method, apparatus, device, and medium for a blockchain.
In one aspect, the present invention provides a method for constructing a shadow database of a block chain, where the method includes:
acquiring a configuration file, wherein the configuration file records block chain configuration information, block chain shadow database configuration information, extraction strategy information and analysis information;
positioning a current data table according to the configuration information of the block chain shadow database in the configuration file;
positioning a target block according to the block chain configuration information and the extraction strategy information in the configuration file, and extracting block data in the target block;
acquiring an analysis strategy corresponding to the block data according to analysis information in the configuration file, and analyzing the block data into corresponding service data according to the analysis strategy;
and storing the service data into a current data table.
In another aspect, the present invention provides a shadow database construction apparatus for a block chain, including:
the configuration file acquisition module is used for acquiring a configuration file, wherein the configuration file records block chain configuration information, block chain shadow database configuration information, extraction strategy information and analysis information;
the current data table positioning module is used for positioning a current data table according to the configuration information of the block chain shadow database in the configuration file;
the data extraction module is used for positioning a target block according to the block chain configuration information and the extraction strategy information in the configuration file and extracting block data in the target block;
the data analysis module is used for acquiring an analysis strategy corresponding to the block data according to analysis information in the configuration file and analyzing the block data into corresponding service data according to the analysis strategy;
and the data storage module is used for storing the service data into a current data table.
In another aspect, the present invention provides a shadow database building apparatus of a blockchain, where the apparatus includes a processor and a memory, where the memory stores at least one instruction, at least one program, a code set, or a set of instructions, and the at least one instruction, the at least one program, the code set, or the set of instructions is loaded and executed by the processor to implement a shadow database building method of a blockchain.
In another aspect, the present invention provides a computer storage medium, wherein at least one instruction, at least one program, a set of codes, or a set of instructions is stored in the storage medium, and the at least one instruction, at least one program, a set of codes, or a set of instructions is loaded by a processor and executes a shadow database construction method for a blockchain.
The invention provides a shadow database construction method, a shadow database construction device, shadow database construction equipment and a shadow database construction medium of a block chain. The invention can lead the block data on the block chain into the appointed database in a form of service data in batch by a customized configuration method to form a block chain shadow database, and the block chain shadow database can carry out statistical analysis and data mining on the service data pointed by the block data on the block chain, thereby supporting the service system to access the service data.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions and advantages of the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
FIG. 1 is a schematic diagram of an implementation environment of a shadow database construction method for a blockchain according to the present invention;
FIG. 2 is a block chain structure diagram according to the present invention;
FIG. 3 is a block chain logic structure diagram provided by the present invention;
FIG. 4 is a flowchart of a shadow database construction method for a blockchain according to the present invention;
FIG. 5 is a flowchart of the present invention for locating a current data table according to the configuration information of the blockchain shadow database in the configuration file;
FIG. 6 is a flowchart of recording the target block and the access result of the target block according to the present invention;
FIG. 7 is a schematic diagram of the types of data provided by the present invention;
FIG. 8 is a flowchart of a method for storing the service data in a current data table according to the present invention;
FIG. 9 is a diagram of a system for building a blockchain shadow database according to the present invention;
FIG. 10 is a schematic diagram of an embodiment of a block chain shadow database construction method provided in the present invention;
FIG. 11 is a block diagram of a shadow database construction apparatus for a blockchain according to the present invention;
fig. 12 is a hardware structural diagram of an apparatus for implementing the method provided by the embodiment of the invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be obtained by a person skilled in the art without any inventive step based on the embodiments of the present invention, are within the scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or server that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
In order to make the objects, technical solutions and advantages disclosed in the embodiments of the present invention more clearly apparent, the embodiments of the present invention are described in further detail below with reference to the accompanying drawings and the embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the embodiments of the invention and are not intended to limit the embodiments of the invention.
In the following, the terms "first", "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of the present embodiment, "a plurality" means two or more unless otherwise specified. In order to facilitate understanding of the technical solutions and the technical effects thereof described in the embodiments of the present invention, the embodiments of the present invention first explain related terms:
in order to solve the technical problems that data in a block chain is difficult to be directly used in business and is difficult to be directly used for data analysis and data mining of a business layer in the prior art, the embodiment of the invention discloses a shadow database construction method of the block chain. First, the embodiment of the present invention discloses an implementation environment of the shadow database construction method for a blockchain in a feasible embodiment.
Referring to fig. 1, the implementation environment includes: at least one client 01, server 03, blockchain 05, and blockchain shadow database 07.
The blocks are one storage unit, and all communication information of each block node within a certain time is recorded. The blocks are linked by random hashing (also called hashing algorithm), the next block contains the hash value of the previous block, as the information exchange expands, one block is continued with another block, and the result is called a block chain 05.
The blockchain shadow database 07 stores therein service data, the blockchain 05 stores therein blockchain data, and data information included in the service data is a subset of data information included in the blockchain data, that is, the service data is constructed by the blockchain data and has consistency with the blockchain data. The blockchain shadow database 07 may support database operations such as dynamic editing of business data, index construction, and the like, and the blockchain shadow database 07 may be a relational database or a non-relational database.
The block chain shadow sub-database in the embodiment of the invention can be reintroduced, deleted, incrementally introduced and the like at any time according to the business needs, the related operations are all recorded into the related logs to facilitate the follow-up, meanwhile, a data verification mechanism is provided, the data of the related block chain shadow sub-database can be randomly checked, and the data can be deleted and reintroduced if the data is inconsistent.
The client 01 may include: the physical devices may also include software running in the physical devices, such as applications that require application block data information. The application programs needing the application block data information can be financial application programs, payment application programs, financial management application programs, payment management application programs and the like. The Client 01 may be communicatively connected to the Server 03 based on a Browser/Server mode (Browser/Server, B/S) or a Client/Server mode (Client/Server, C/S).
The client 01 may send a service request to the server 03, where the service request may include a service query request, a service statistics request, and a service data mining related request.
In order to respond to the service request, the server 03 needs to access the block data information related to the service request, and the discontinuity of data in the block chain in service and the incompatibility with service logic make it difficult for the data in the block chain to be directly used for responding to the service request, so in the embodiment of the present invention, a block chain shadow database 07 compatible with the service is constructed. The server 03 obtains the service data by accessing the blockchain shadow database 07, and responds the service request to the client 01.
The server 03 may comprise an independently operating server, or a distributed server, or a server cluster composed of a plurality of servers.
The block chain 05 may be composed of a plurality of blocks, as shown in fig. 2, a starting block includes a block header and a block main body, the block header stores an input information characteristic value, a version number, a timestamp and a difficulty value, and the block main body stores input information; the next block of the starting block takes the starting block as a parent block, the next block also comprises a block head and a block main body, the block head stores the input information characteristic value of the current block, the block head characteristic value of the parent block, the version number, the timestamp and the difficulty value, and the like, so that the block data stored in each block in the block chain is associated with the block data stored in the parent block, and the safety of the input information in the block is ensured.
When each block in the block chain is generated, referring to fig. 3, when the node where the block chain is located receives the input information, the input information is verified, after the verification is completed, the input information is stored in the memory pool, and the hash tree for recording the input information is updated; and then, updating the updating time stamp to the time when the input information is received, trying different random numbers, and calculating the characteristic value for multiple times, so that the calculated characteristic value can meet the following formula:
SHA256(SHA256(version+prev_hash+merkle_root+ntime+nbits+x))<TARGET
wherein, SHA256 is a characteristic value algorithm used for calculating a characteristic value; version is version information of the relevant block protocol in the block chain; prev _ hash is a block head characteristic value of a parent block of the current block; merkle _ root is a characteristic value of the input information; ntime is the update time of the update timestamp; nbits is the current difficulty, is a fixed value within a period of time, and is determined again after exceeding a fixed time period; x is a random number; TARGET is a feature threshold, which can be determined from nbits.
Therefore, when the random number meeting the formula is obtained through calculation, the information can be correspondingly stored, and the block head and the block main body are generated to obtain the current block. And then, the node where the block chain is located respectively sends the newly generated blocks to other nodes according to the node identifiers of other nodes in the block chain, the newly generated blocks are verified by the other nodes, and the newly generated blocks are added into the block chain stored in the newly generated blocks after the verification is completed.
Referring to fig. 4, a flowchart of a shadow database construction method of a block chain is shown, where the method may be implemented by a server in the implementation environment described in fig. 1 as an execution subject, and the method may include:
s101, obtaining a configuration file, wherein the configuration file records block chain configuration information, block chain shadow database configuration information, extraction strategy information and analysis information.
Specifically, the blockchain configuration information may be used to access a blockchain; the configuration information of the block chain shadow database can comprise block information table information, batch record table information, service table information and/or system table information; the extraction strategy information may include batch extraction strategy information and/or information about extracted locations in the blockchain; the analysis information includes analysis policy related information required for analyzing the block data in the block chain into the service data in the block chain shadow database.
In one possible embodiment, the blockchain configuration information may include the following:
blockchain system URL (uniform resource locator): url ═ http://. x
Version information of the blockchain system JSONRPC: block _ version ═ 2.0(JSONRPC refers to stateless and lightweight remote procedure call transfer protocol)
Block chain system identification information: block chain. id ═ x-
Account alias in blockchain: alicac count is a unit of block chain
In one possible embodiment, the extraction policy information may include the following:
extracting the paging size: extract, rule, pagesize 50
Extracting data related parameters according to a user-defined method:
extract.rule.custommethod=eth_getNumber;
extract.rule.custommeparams[0]=p1;
extract.rule.custommeparams[1]=p2
inquiring whether the block information inquires the block details: "true" shows transaction detail, otherwise, shows transaction hash value
In one possible embodiment, the parsing information may include the following:
a type of service data; a parsing policy corresponding to the service data type;
in one possible embodiment, the following may be included:
database connection pool configuration (development environment);
the database verifies the switch configuration.
S103, positioning a current data table according to the configuration information of the block chain shadow database in the configuration file, wherein the current data table is block information table information, batch record table information, service table information and/or system table information.
Specifically, the locating the current data table according to the configuration information of the shadow database of the block chain in the configuration file, as shown in fig. 5, includes:
and S1031, judging whether the current data table exists in the block chain shadow database according to the configuration information of the block chain shadow database.
And S1033, if yes, opening the current data table.
And S1035, if not, creating the current data table according to the configuration information of the block chain shadow database.
And S105, positioning a target block according to the block chain configuration information and the extraction strategy information in the configuration file, and extracting block data in the target block.
In the embodiment of the invention, the block data is extracted by accessing the target block, the data extraction is mainly performed through an application program interface which is provided by a block chain and used for extracting data according to the block number, the position of the data extraction is convenient to record when the data extraction is performed through the block number, so that the continuity and the non-repeatability of the data extraction are ensured, and in a preferred embodiment, the target block and the access result of the target block can be recorded.
Specifically, the recording the target block and the access result of the target block, as shown in fig. 6, includes:
s1051, obtaining the extraction result of the block data in the target block.
S1053, recording the target block and the extraction result in an extraction log.
The extraction log may be used to prevent repeated extraction of block data that has been successfully extracted and to perform supplementary extraction of block data that has not been successfully extracted subsequently.
In a preferred embodiment, in order to ensure that the extraction of block data in a block chain does not significantly affect the performance of the block chain, and limit the extraction amount of block data in a single time, paging information and a batch extraction policy may be configured in the extraction policy information of the configuration file, and accordingly, when block data extraction is performed for the first time, block data is extracted according to the paging information so as to prevent significant impact on the performance of the block chain, and the paging capacity defined by the paging information may cover one or more blocks. And after the block data is successfully extracted for the first time, extracting the block data in batches according to a batch extraction strategy. The implementation of the batch extraction strategy can be driven based on a timer so as to achieve the purpose of extracting block data on time and ensure the real-time performance of the data.
S107, acquiring an analysis strategy corresponding to the block data according to the analysis information in the configuration file, and analyzing the block data into corresponding service data according to the analysis strategy.
The main responsibility of data parsing is to translate block data into service data used by the service system. As shown in fig. 7, the Block chain Data stored in the blocks includes Block volume Data (Block) and transaction Data (transition), the Block volume Data and the transaction Data are Data conforming to a standard format of the Block chain, and the service Data stored in the Block chain shadow database is Data conforming to a custom format of a service requirement, wherein the service Data may include first Data (Data) and second Data (bizMsg Data). The first data comprises a type of the second data, and the second data points to a specific business logic. In the data analysis process, the block data obtained from the block needs to be analyzed layer by layer, and then the block data is translated into the service data through the configured analysis strategy.
Please refer to table 1, which shows the basic contents of the tile data; referring to table 2, the basic contents of the transaction data are shown; please refer to table 3, which shows the basic content of the first data, the bizMsg field and the bizmame field in the first data, and the second data structure (bizMsg) corresponding to different bizmame values are different, for example, the second data structure may be multiple, and respectively support specific services such as including the transformation of applying for entering a chain for binding a card, the transformation of confirming entering a chain for binding a card, the transformation of applying for entering a chain for adding a value, the transformation of confirming entering a chain for adding a value, and the transformation of applying for entering a chain for withdrawing a cash.
TABLE 1 Block data
TABLE 2 transaction data
TABLE 3 first data
And S109, storing the service data into a current data table.
Specifically, the service data obtained after the analysis is stored in the current data table of the block chain shadow database in a persistent manner.
As shown in fig. 8, the storing the service data into the current data table includes:
s1091, constructing a structured query statement according to the business data.
S1093, the structured query statement is operated so as to store the service data in the current data table.
Specifically, the structured query statement can also be constructed and operated in batch, so that the purpose of storing the service data in batch in the current data table is achieved.
And S1095, updating the database log according to the storage result.
In order to facilitate efficient operation of the method for building a shadow database of a blockchain according to the embodiment of the present invention, each functional module implementing the method may be further packaged to obtain a system for building a shadow database of a blockchain, as shown in fig. 9, the system for building a shadow database of a blockchain includes a toolbox, an initialization tool, a task operation tool, an extraction tool, an analysis tool, a storage tool, an entity object tool, and an extraction log tool.
The tool box is used for providing various tool classes for the block chain shadow database construction system; the initialization tool is used for initializing the block chain shadow database construction system; the task running tool is used for driving batch data extraction and batch data storage; the extraction tool is used for extracting block data; the analysis tool is used for analyzing the block data to obtain service data; the storage tool is used for storing the business data to the block chain shadow database in batches; the entity object tool is used for defining various data objects; the extraction log tool is used for recording an extraction log.
Referring to fig. 10, which is a schematic diagram illustrating an implementation of a shadow database construction method for a blockchain according to an embodiment of the present invention, the blockchain data is extracted and stored in a relational database or a non-relational database through an analysis and storage link, where operation bases of the extraction, analysis, and storage links are generated based on a configuration file in an initialization stage.
The shadow database construction method of the block chain can lead the block data on the block chain into a designated database in batch in the form of service data by a customized configuration method to form the shadow database of the block chain, and the shadow database of the block chain can perform statistical analysis and data mining on the service data pointed by the block data on the block chain, so that the service system can be supported to access the service data.
An embodiment of the present invention further provides a shadow database construction apparatus for a block chain, as shown in fig. 11, the apparatus includes:
a configuration file obtaining module 201, configured to obtain a configuration file, where the configuration file records blockchain configuration information, blockchain shadow database configuration information, extraction policy information, and analysis information;
a current data table positioning module 203, configured to position a current data table according to the configuration information of the blockchain shadow database in the configuration file;
a data extraction module 205, configured to locate a target block according to the block chain configuration information and the extraction policy information in the configuration file, and extract block data in the target block;
a data analysis module 207, configured to obtain an analysis policy corresponding to the block data according to analysis information in the configuration file, and analyze the block data into service data corresponding to the block data according to the analysis policy;
and the data storage module 209 is configured to store the service data into the current data table.
Specifically, the shadow database construction apparatus and method for a block chain according to the embodiments of the present invention are all based on the same inventive concept. For details, please refer to the method embodiment, which is not described herein.
The embodiment of the invention also provides a computer storage medium, and the computer storage medium can store a plurality of instructions. The instructions may be adapted to be loaded by a processor and execute a shadow database construction method of a blockchain according to an embodiment of the present invention, where the method includes at least the following steps:
a shadow database construction method of a blockchain, the method comprising:
acquiring a configuration file, wherein the configuration file records block chain configuration information, block chain shadow database configuration information, extraction strategy information and analysis information;
positioning a current data table according to the configuration information of the block chain shadow database in the configuration file;
positioning a target block according to the block chain configuration information and the extraction strategy information in the configuration file, and extracting block data in the target block;
acquiring an analysis strategy corresponding to the block data according to analysis information in the configuration file, and analyzing the block data into corresponding service data according to the analysis strategy;
and storing the service data into a current data table.
In a preferred embodiment, said locating the current data table according to the configuration information of the block chain shadow database in the configuration file includes:
judging whether the current data table exists in a block chain shadow database or not according to the configuration information of the block chain shadow database;
if yes, opening the current data table;
and if not, creating the current data table according to the configuration information of the block chain shadow database.
In a preferred embodiment, the recording the target block and the access result of the target block further includes:
acquiring an extraction result of block data in the target block;
and recording the target block and the extraction result in an extraction log.
In a preferred embodiment, further comprising:
allocating paging information and a batch extraction strategy in extraction strategy information of a configuration file, correspondingly, extracting block data according to the paging information when extracting the block data for the first time, wherein the paging capacity limited by the paging information covers at least one block;
and after the block data is successfully extracted for the first time, extracting the block data in batches according to a batch extraction strategy.
In a preferred embodiment, the block data includes block volume data and transaction data, the block volume data and the transaction data are data conforming to a standard format of a block chain, and the service data stored in the block chain shadow database is data conforming to a custom format of a service requirement, wherein the service data may include first data and second data; the first data includes a type of the second data, the second data being directed to business logic.
In a preferred embodiment, the storing the service data into the current data table includes:
constructing a structured query statement according to the business data;
executing the structured query statement to facilitate storing the business data in the current data table;
and updating the database log according to the storage result.
Further, fig. 12 is a schematic hardware structure diagram of an apparatus for implementing the method provided by the embodiment of the present invention, and the apparatus may participate in forming or containing the device or system provided by the embodiment of the present invention. As shown in fig. 12, the device 10 may include one or more (shown as 102a, 102b, … …, 102 n) processors 102 (the processors 102 may include, but are not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 104 for storing data, and a transmission device 106 for communication functions. Besides, the method can also comprise the following steps: a display, an input/output interface (I/O interface), a Universal Serial Bus (USB) port (which may be included as one of the ports of the I/O interface), a network interface, a power source, and/or a camera. It will be understood by those skilled in the art that the structure shown in fig. 12 is only an illustration and is not intended to limit the structure of the electronic device. For example, device 10 may also include more or fewer components than shown in FIG. 12, or have a different configuration than shown in FIG. 12.
It should be noted that the one or more processors 102 and/or other data processing circuitry described above may be referred to generally herein as "data processing circuitry". The data processing circuitry may be embodied in whole or in part in software, hardware, firmware, or any combination thereof. Further, the data processing circuitry may be a single, stand-alone processing module, or incorporated in whole or in part into any of the other elements in the device 10 (or mobile device). As referred to in the embodiments of the application, the data processing circuit acts as a processor control (e.g. selection of a variable resistance termination path connected to the interface).
The memory 104 may be used to store software programs and modules of application software, such as program instructions/data storage devices corresponding to the method described in the embodiment of the present invention, and the processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, implementing one of the above-described shadow database construction methods of a block chain. The memory 104 may include high speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, memory 104 may further include memory located remotely from processor 102, which may be connected to device 10 via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission device 106 is used for receiving or transmitting data via a network. Specific examples of such networks may include wireless networks provided by the communication provider of the device 10. In one example, the transmission device 106 includes a network adapter (NIC) that can be connected to other network devices through a base station so as to communicate with the internet. In one example, the transmission device 106 can be a Radio Frequency (RF) module, which is used for communicating with the internet in a wireless manner.
The display may be, for example, a touch screen type Liquid Crystal Display (LCD) that may enable a user to interact with a user interface of the device 10 (or mobile device).
It should be noted that: the precedence order of the above embodiments of the present invention is only for description, and does not represent the merits of the embodiments. And specific embodiments thereof have been described above. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, as for the device and server embodiments, since they are substantially similar to the method embodiments, the description is simple, and the relevant points can be referred to the partial description of the method embodiments.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, where the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.
Claims (8)
1. A shadow database construction method of a block chain is characterized by comprising the following steps:
acquiring a configuration file, wherein the configuration file records block chain configuration information, block chain shadow database configuration information, extraction strategy information and analysis information, and the analysis information comprises a service data type and an analysis strategy corresponding to the service data type;
positioning a current data table according to the configuration information of the block chain shadow database in the configuration file;
allocating paging information and batch extraction strategies in extraction strategy information of a configuration file, positioning a target block according to block chain allocation information and the extraction strategy information in the configuration file, and extracting block data in the target block; extracting block data according to the paging information when block data extraction is carried out for the first time, wherein the paging capacity limited by the paging information covers at least one block; after the block data are extracted successfully for the first time, extracting the block data in batches according to a batch extraction strategy; the block data comprises block volume data and transaction data, the block volume data and the transaction data are data in a block chain standard format, and the service data stored in the block chain shadow database is data in a user-defined format meeting service requirements, wherein the service data comprises first data and second data; the first data comprises the type of the second data, the second data of different types has different structures, and the second data points to corresponding business logic;
acquiring an analysis strategy corresponding to the block data according to analysis information in the configuration file, and analyzing the block data into corresponding service data according to the analysis strategy;
storing the service data into a current data table;
the method is implemented based on a tool box, an initialization tool, a task running tool, an extraction tool, an analysis tool, a storage tool, an entity object tool and an extraction log tool which are provided by a block chain shadow database construction system;
the tool box is used for providing various tool classes for the block chain shadow database construction system; the initialization tool is used for initializing the block chain shadow database construction system; the task running tool is used for driving batch data extraction and batch data storage; the extraction tool is used for extracting block data; the analysis tool is used for analyzing the block data to obtain service data; the storage tool is used for storing the business data to the block chain shadow database in batches; the entity object tool is used for defining various data objects; the extraction log tool is used for recording an extraction log.
2. The method of claim 1, wherein locating a current data table according to the configuration information of the blockchain shadow database in the configuration file comprises:
judging whether the current data table exists in a block chain shadow database or not according to the configuration information of the block chain shadow database;
if yes, opening the current data table;
and if not, creating the current data table according to the configuration information of the block chain shadow database.
3. The method of claim 1, further comprising recording the target block and the access result of the target block, wherein recording the target block and the access result of the target block comprises:
acquiring an extraction result of block data in the target block;
and recording the target block and the extraction result in an extraction log.
4. The method of claim 1, wherein storing the service data into a current data table comprises:
constructing a structured query statement according to the business data;
executing the structured query statement to facilitate storing the business data in the current data table;
and updating the database log according to the storage result.
5. The method of claim 1, wherein:
when each block in the block chain is generated, when a node where the block chain is located receives input information, the input information is verified, after the verification is completed, the input information is stored in a memory pool, and a hash tree used for recording the input information is updated; and then, updating the updating time stamp to the time when the input information is received, trying different random numbers, and calculating the characteristic value for multiple times to enable the calculated characteristic value to meet the following formula:
SHA256(SHA256(version+prev_hash+merkle_root+ntime+nbits+x))<TARGET;
wherein, SHA256 is a characteristic value algorithm used for calculating a characteristic value; version is version information of a related block protocol in the block chain; prev _ hash is a block head characteristic value of a parent block of the current block; merkle _ root is a characteristic value of the input information; ntime is the update time of the update timestamp; nbits is the current difficulty, is a fixed value within a period of time, and is determined again after exceeding a fixed time period; x is a random number; TARGET is a feature threshold, which can be determined from nbits.
6. An apparatus for shadow database construction of a blockchain, the apparatus comprising:
the system comprises a configuration file acquisition module, a configuration file acquisition module and a configuration file management module, wherein the configuration file is used for acquiring a configuration file, and the configuration file records block chain configuration information, block chain shadow database configuration information, extraction strategy information and analysis information, and the analysis information comprises a service data type and an analysis strategy corresponding to the service data type;
the current data table positioning module is used for positioning a current data table according to the configuration information of the block chain shadow database in the configuration file;
the data extraction module is used for configuring paging information and batch extraction strategies in the extraction strategy information of the configuration file, positioning a target block according to the block chain configuration information and the extraction strategy information in the configuration file, and extracting block data in the target block; extracting block data according to the paging information when block data extraction is carried out for the first time, wherein the paging capacity limited by the paging information covers at least one block; after the block data are extracted successfully for the first time, extracting the block data in batches according to a batch extraction strategy; the block data comprises block volume data and transaction data, the block volume data and the transaction data are data in a block chain standard format, and the service data stored in the block chain shadow database is data in a user-defined format meeting service requirements, wherein the service data comprises first data and second data; the first data comprises the type of the second data, the second data of different types has different structures, and the second data points to corresponding business logic;
the data analysis module is used for acquiring an analysis strategy corresponding to the block data according to analysis information in the configuration file and analyzing the block data into corresponding service data according to the analysis strategy;
the data storage module is used for storing the service data into a current data table;
the device is implemented based on a tool box, an initialization tool, a task running tool, an extraction tool, an analysis tool, a storage tool, an entity object tool and an extraction log tool which are provided by a block chain shadow database construction system;
the tool box is used for providing various tool classes for the block chain shadow database construction system; the initialization tool is used for initializing the block chain shadow database construction system; the task running tool is used for driving batch data extraction and batch data storage; the extraction tool is used for extracting block data; the analysis tool is used for analyzing the block data to obtain service data; the storage tool is used for storing the business data to the block chain shadow database in batches; the entity object tool is used for defining various data objects; the extraction log tool is used for recording an extraction log.
7. A computer storage medium having stored therein at least one instruction, at least one program, a set of codes, or a set of instructions, which is loaded and executed by a processor to implement a method of shadow database construction of a blockchain as claimed in any one of claims 1 to 5.
8. A shadow database construction device of a blockchain, comprising a processor and a memory, wherein the memory stores at least one instruction, at least one program, a set of codes or a set of instructions, and the at least one instruction, the at least one program, the set of codes or the set of instructions is loaded by the processor and executes a shadow database construction method of a blockchain according to any one of claims 1 to 5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910852917.7A CN110727655B (en) | 2019-09-10 | 2019-09-10 | Method, device, equipment and medium for building shadow database of block chain |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910852917.7A CN110727655B (en) | 2019-09-10 | 2019-09-10 | Method, device, equipment and medium for building shadow database of block chain |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110727655A CN110727655A (en) | 2020-01-24 |
CN110727655B true CN110727655B (en) | 2022-03-15 |
Family
ID=69218090
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910852917.7A Active CN110727655B (en) | 2019-09-10 | 2019-09-10 | Method, device, equipment and medium for building shadow database of block chain |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110727655B (en) |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107391649A (en) * | 2017-07-14 | 2017-11-24 | 浙商银行股份有限公司 | A kind of system and method for lifting block chain query efficiency |
CN107657059A (en) * | 2017-10-20 | 2018-02-02 | 中国银行股份有限公司 | Method of data synchronization, middleware and system based on block chain application system |
CN108647361A (en) * | 2018-05-21 | 2018-10-12 | 中国工商银行股份有限公司 | A kind of date storage method, apparatus and system based on block chain |
CN108920670A (en) * | 2018-07-06 | 2018-11-30 | 深圳市小牛在线互联网信息咨询有限公司 | Cache synchronization method, device, system and storage medium |
CN109086325A (en) * | 2018-06-29 | 2018-12-25 | 阿里巴巴集团控股有限公司 | Data processing method and device based on block chain |
CN109461079A (en) * | 2018-10-29 | 2019-03-12 | 众安信息技术服务有限公司 | Transaction processing method and device based on block chain |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109344172B (en) * | 2018-08-31 | 2022-05-17 | 深圳市元征科技股份有限公司 | High-concurrency data processing method and device and client server |
CN110062028A (en) * | 2019-03-21 | 2019-07-26 | 深圳壹账通智能科技有限公司 | Data synchronous method, apparatus, computer equipment and computer storage medium |
-
2019
- 2019-09-10 CN CN201910852917.7A patent/CN110727655B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107391649A (en) * | 2017-07-14 | 2017-11-24 | 浙商银行股份有限公司 | A kind of system and method for lifting block chain query efficiency |
CN107657059A (en) * | 2017-10-20 | 2018-02-02 | 中国银行股份有限公司 | Method of data synchronization, middleware and system based on block chain application system |
CN108647361A (en) * | 2018-05-21 | 2018-10-12 | 中国工商银行股份有限公司 | A kind of date storage method, apparatus and system based on block chain |
CN109086325A (en) * | 2018-06-29 | 2018-12-25 | 阿里巴巴集团控股有限公司 | Data processing method and device based on block chain |
CN108920670A (en) * | 2018-07-06 | 2018-11-30 | 深圳市小牛在线互联网信息咨询有限公司 | Cache synchronization method, device, system and storage medium |
CN109461079A (en) * | 2018-10-29 | 2019-03-12 | 众安信息技术服务有限公司 | Transaction processing method and device based on block chain |
Also Published As
Publication number | Publication date |
---|---|
CN110727655A (en) | 2020-01-24 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110535938B (en) | Data processing method, equipment and storage medium based on intelligent contract | |
CN100527080C (en) | Method for software program synchronization | |
CN107172169A (en) | Method of data synchronization, device, server and storage medium | |
CN107947954B (en) | System, method and server for dynamically adjusting log level | |
CN111382073A (en) | Automatic test case determination method, device, equipment and storage medium | |
CN110932918B (en) | Log data acquisition method and device and storage medium | |
CN111597388B (en) | Sample collection method, device, equipment and medium based on distributed system | |
CN113010378B (en) | Log processing method and device of microservice module, storage medium and electronic device | |
CN112887451B (en) | Domain name resolution method and device and computer equipment | |
CN112631924A (en) | Automatic testing method and device, computer equipment and storage medium | |
CN111158711A (en) | Application program deployment method and device for multiple android system terminals | |
CN112860662A (en) | Data blood relationship establishing method and device, computer equipment and storage medium | |
CN111885177A (en) | Biological information analysis cloud computing method and system based on cloud computing technology | |
CN111736938A (en) | Information display method and device, storage medium and electronic device | |
CN112311624B (en) | Cloud host testing method and device, storage medium and electronic equipment | |
CN110928681A (en) | Data processing method and device, storage medium and electronic device | |
CN111488286B (en) | Method and device for independently developing Android modules | |
CN110727655B (en) | Method, device, equipment and medium for building shadow database of block chain | |
CN112579406B (en) | Log call chain generation method and device | |
CN110287070B (en) | ESB special protocol interface test method, server and computer readable storage medium | |
CN111026047B (en) | Software configuration method and device | |
CN112181822A (en) | Test method and test method for starting time consumption of application program | |
CN113992739B (en) | Local area network OTA firmware upgrading device, method and system | |
CN110347683B (en) | Data table merging processing method and device | |
CN113704120A (en) | Data transmission method, device, equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |