CN112291376A - Data processing method and related equipment in block chain system - Google Patents

Data processing method and related equipment in block chain system Download PDF

Info

Publication number
CN112291376A
CN112291376A CN202011618496.0A CN202011618496A CN112291376A CN 112291376 A CN112291376 A CN 112291376A CN 202011618496 A CN202011618496 A CN 202011618496A CN 112291376 A CN112291376 A CN 112291376A
Authority
CN
China
Prior art keywords
block
data
service node
service
height
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
CN202011618496.0A
Other languages
Chinese (zh)
Other versions
CN112291376B (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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202011618496.0A priority Critical patent/CN112291376B/en
Publication of CN112291376A publication Critical patent/CN112291376A/en
Application granted granted Critical
Publication of CN112291376B publication Critical patent/CN112291376B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1095Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/62Protecting access to data via a platform, e.g. using keys or access control rules
    • G06F21/6218Protecting access to data via a platform, e.g. using keys or access control rules to a system of files or objects, e.g. local or distributed file system or database
    • G06F21/6227Protecting access to data via a platform, e.g. using keys or access control rules to a system of files or objects, e.g. local or distributed file system or database where protection concerns the structure of data, e.g. records, types, queries
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/50Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols using hash chains, e.g. blockchains or hash trees

Abstract

The application relates to the technical field of block chains, and particularly provides a data processing method and related equipment in a block chain system, wherein the block chain system comprises a billing network and a service network, and the method comprises the following steps: acquiring a data archiving instruction; acquiring the latest block height in the data of the storage area block of the service node; according to the data filing instruction and the latest block height, filing the block data in the service node; after the filing processing is carried out, at least block data corresponding to a preset number of blocks closest to the block with the latest block height is reserved in the service node, so that query service is provided based on the block data reserved in the service node and the block data filed in the cold database. The method can release the data storage space in the service node and reduce the data storage pressure of the service node.

Description

Data processing method and related equipment in block chain system
Technical Field
The present application relates to the field of blockchain technologies, and in particular, to a data processing method and related device in a blockchain system.
Background
In the blockchain system, as data is continuously increased, data required to be written into the blockchain is correspondingly increased, and in this case, for nodes in the blockchain system, as the nodes need to store the blockchain, the data storage pressure of the nodes is continuously increased as the data is continuously written into the blockchain. When the data storage pressure in the node is too large, the performance of the node is reduced, and even the node is possibly paralyzed.
From the above, how to effectively solve the problem of large storage pressure of the nodes in the blockchain system is an urgent technical problem to be solved in the prior art.
Disclosure of Invention
Embodiments of the present application provide a data processing method and related apparatus in a blockchain system, so as to effectively reduce storage pressure of nodes in the blockchain system.
Other features and advantages of the present application will be apparent from the following detailed description, or may be learned by practice of the application.
According to an aspect of the embodiments of the present application, there is provided a data processing method in a blockchain system, the blockchain system including a billing network and a service network, the service network including service nodes, the billing network maintaining blockchain data, the service nodes synchronizing blockchain data from the billing network; the method is performed by the service node, the method comprising:
acquiring a data archiving instruction;
acquiring the latest block height in the data of the storage block of the service node;
according to the data archiving instruction and the latest block height, archiving the block data in the service node; after the filing processing is performed, at least block data corresponding to a preset number of blocks closest to the block with the latest block height is reserved in the service node, so that query service is provided based on the block data reserved in the service node and the block data filed in the cold database.
According to an aspect of the embodiments of the present application, there is provided a data processing method in a blockchain system, the blockchain system including a billing network and a service network, the billing network including a billing node, the service network including a service node, the billing network configured to maintain blockchain data, the service node configured to synchronize blockchain data from the billing network; the method is performed by the accounting node, the method comprising:
acquiring a data archiving instruction;
sending the data archiving instruction to the service node so that the service node archives the block data according to the data archiving instruction and the latest block height in the data of the storage block of the service node; after the filing processing is performed, at least block data corresponding to a preset number of blocks closest to the block with the latest block height is reserved in the service node, so that query service is provided based on the block data reserved in the service node and the block data filed in the cold database.
According to an aspect of the embodiments of the present application, there is provided a data processing apparatus in a blockchain system, the blockchain system including a service network and a billing network, the service network including a service node, the billing network maintaining blockchain data, the service node synchronizing blockchain data from the billing network; the device is applied to the service node, and the device comprises:
the first acquisition module is used for acquiring a data archiving instruction;
a latest block height obtaining module, configured to obtain a latest block height in the block data stored in the service node;
the archiving module is used for archiving the block data in the service node according to the data archiving instruction and the latest block height; after the filing processing is performed, at least block data corresponding to a preset number of blocks closest to the block with the latest block height is reserved in the service node, so that query service is provided based on the block data reserved in the service node and the block data filed in the cold database.
According to an aspect of the embodiments of the present application, there is provided a data processing apparatus in a blockchain system, the blockchain system including an accounting network and a service network, the accounting network including accounting nodes, the service network including service nodes, the accounting network being configured to maintain blockchain data, the service nodes synchronizing blockchain data from the accounting network; the device is applied to the accounting node, and comprises:
the second acquisition module is used for acquiring a data archiving instruction;
the sending module is used for sending the data archiving instruction to the service node so that the service node can archive the block data according to the data archiving instruction and the latest block height in the data of the storage area of the service node; after the filing processing is performed, at least block data corresponding to a preset number of blocks closest to the block with the latest block height is reserved in the service node, so that query service is provided based on the block data reserved in the service node and the block data filed in the cold database.
According to an aspect of an embodiment of the present application, there is provided an electronic device including: a processor; a memory having computer readable instructions stored thereon which, when executed by the processor, implement the method as described above.
According to an aspect of embodiments of the present application, there is provided a computer-readable storage medium having stored thereon computer-readable instructions which, when executed by a processor, implement a method as described above.
In the scheme of the application, after the service node acquires the data filing instruction, the stored block data is filed according to the data filing instruction and the latest block height in the block data stored in the service node, and it is ensured that after the filing processing is performed, the service node at least keeps the block data corresponding to the preset number of blocks closest to the block where the latest block height is located, and other block data synchronized to the service node from the accounting network are filed in the cold database, on one hand, the data storage space in the service node is released by filing part of the block data in the cold database, so that the data storage pressure of the service node is reduced, and therefore, the problem of storage capacity expansion of the service node is avoided; on the other hand, when the archiving processing is performed, it is ensured that at least block data corresponding to a preset number of blocks closest to the block with the latest block height is reserved in the service node, so that the service node can perform data witness or verification in the block chain according to the reserved block data after the data is archived, so that the service node can effectively cope with the situation that the wrong block data is received or the block data with the higher block height is received, and the accuracy of the data in the block chain system is ensured.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the application.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and together with the description, serve to explain the principles of the application. It is obvious that the drawings in the following description are only some embodiments of the application, and that for a person skilled in the art, other drawings can be derived from them without inventive effort. In the drawings:
fig. 1 shows a schematic structural diagram of a blockchain network.
Fig. 2 is a schematic diagram illustrating a connection relationship between blocks in a block chain.
Fig. 3 shows a schematic diagram of a process of generating a tile.
Fig. 4 is a block chain system architecture diagram according to one embodiment.
Fig. 5 is a block chain system architecture diagram according to another embodiment.
Fig. 6 is a block chain system architecture diagram according to another embodiment.
FIG. 7 shows a schematic diagram of an electronic invoice system, according to an embodiment of the application.
Fig. 8 is a flowchart illustrating a data processing method in a blockchain system according to an embodiment of the present application.
FIG. 9 is a flowchart illustrating steps subsequent to step 830 according to one embodiment.
Fig. 10 is a flowchart illustrating a data processing method in a blockchain system according to another embodiment of the present application.
FIG. 11 is a flow diagram of step 1020 in one embodiment.
FIG. 12 is a flow diagram of step 1010 in one embodiment.
Fig. 13 is a flowchart illustrating a data processing method in a blockchain system according to another embodiment of the present application.
Fig. 14 is a block diagram illustrating a data processing apparatus in a blockchain system according to an embodiment of the present application.
Fig. 15 is a block diagram illustrating a data processing apparatus in a blockchain system according to another embodiment of the present application.
FIG. 16 illustrates a schematic structural diagram of a computer system suitable for use in implementing the electronic device of an embodiment of the present application.
Detailed Description
Example embodiments will now be described more fully with reference to the accompanying drawings. Example embodiments may, however, be embodied in many different forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of example embodiments to those skilled in the art.
Furthermore, the described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of embodiments of the application. One skilled in the relevant art will recognize, however, that the subject matter of the present application can be practiced without one or more of the specific details, or with other methods, components, devices, steps, and so forth. In other instances, well-known methods, devices, implementations, or operations have not been shown or described in detail to avoid obscuring aspects of the application.
The block diagrams shown in the figures are functional entities only and do not necessarily correspond to physically separate entities. I.e. these functional entities may be implemented in the form of software, or in one or more hardware modules or integrated circuits, or in different networks and/or processor means and/or microcontroller means.
The flow charts shown in the drawings are merely illustrative and do not necessarily include all of the contents and operations/steps, nor do they necessarily have to be performed in the order described. For example, some operations/steps may be decomposed, and some operations/steps may be combined or partially combined, so that the actual execution sequence may be changed according to the actual situation.
It should be noted that: reference herein to "a plurality" means two or more. "and/or" describe the association relationship of the associated objects, meaning that there may be three relationships, e.g., A and/or B may mean: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship.
The Blockchain (Blockchain) is 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. The blockchain is essentially a decentralized database, which is a series of data blocks (i.e., blocks) associated by using cryptography, each data block containing information of a batch of network transactions for verifying the validity (anti-counterfeiting) of the information and generating the next block. The blockchain may include a blockchain underlying platform, a platform product services layer, and an application services layer.
The block chain underlying platform can comprise processing modules such as user management, basic service, intelligent contract and operation monitoring. The user management module is responsible for identity information management of all blockchain participants, and comprises public and private key generation maintenance (account management), key management, user real identity and blockchain address corresponding relation maintenance (authority management) and the like, and under the authorization condition, the user management module supervises and audits the transaction condition of certain real identities and provides rule configuration (wind control audit) of risk control; the basic service module is deployed on all the block chain node equipment and used for verifying the validity of the service request and recording and storing the valid request after the valid request is identified. For a new service request, the basic service firstly performs interface adaptation analysis and authentication processing (interface adaptation), then encrypts service information (consensus management) through a consensus algorithm, transmits the encrypted service information to a shared account (network communication) completely and consistently, and performs recording and storage; the intelligent contract module is responsible for registering and issuing contracts, triggering the contracts and executing the contracts, developers can define contract logics through a certain programming language, issue the contract logics to a block chain (contract registration), call keys or other event triggering and executing according to the logics of contract clauses, complete the contract logics and simultaneously provide the function of upgrading and canceling the contracts; the operation monitoring module is mainly responsible for deployment, configuration modification, contract setting, cloud adaptation in the product release process and visual output of real-time states in product operation, such as: alarm, monitoring network conditions, monitoring node equipment health status, and the like.
The platform product service layer provides basic capability and an implementation framework of typical application, and developers can complete block chain implementation of business logic based on the basic capability and the characteristics of the superposed business. The application service layer provides the application service based on the block chain scheme for the business participants to use.
Referring to the blockchain network shown in fig. 1, a plurality of nodes 101 may be included in the blockchain network, and the plurality of nodes 101 may be respective clients forming the blockchain network. Each node 101 may receive input information and maintain shared data within the blockchain network based on the received input information while operating normally. In order to ensure information intercommunication in the blockchain network, information connection can exist between each node in the blockchain network, and information transmission can be carried out between the nodes through the information connection. For example, when any node in the blockchain network receives input information, other nodes in the blockchain network acquire the input information according to a consensus algorithm, and store the input information as shared data, so that the data stored on all the nodes in the blockchain network are consistent.
Each node in the block chain network has a node identifier corresponding thereto, and each node in the block chain network may store a node identifier of another node, so that the generated block is broadcast to the other nodes in the block chain network according to the node identifiers of the other nodes in the following. Each node can maintain a node identification list, and the node name and the node identification are correspondingly stored in the node identification list. The node identifier may be an IP (Internet Protocol) address and any other information that can be used to identify the node.
Each node in the blockchain network stores one identical blockchain. The block chain is composed of a plurality of blocks, as shown in fig. 2, the block chain is composed of a plurality of blocks, the creation block includes a block header and a block main body, the block header stores input information characteristic values, version numbers, timestamps, difficulty values and the like, and the block main body stores input information; the next block of the created block takes the created 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, the difficulty value and the like, so that the block data stored in each block in the block chain is related to 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 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 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:
Figure 917080DEST_PATH_IMAGE001
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 in the data sharing system where the newly generated blocks are located according to the node identifications of the other nodes in the data sharing system, the newly generated blocks are verified by the other nodes, and the newly generated blocks are added to the block chain stored in the newly generated blocks after the verification is completed.
Each node in the blockchain network may be a server or a terminal device. The server may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a Cloud server providing basic Cloud Computing services such as a Cloud service, a Cloud database, Cloud Computing (Cloud Computing), a Cloud function, Cloud storage, a Network service, Cloud communication, a middleware service, a domain name service, a security service, a Content Delivery Network (CDN), a big data and artificial intelligence platform, and the like. The terminal device may be, but is not limited to, a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, and the like. The nodes may be directly or indirectly connected through wired or wireless communication, and the application is not limited herein.
Based on the blockchain technology, embodiments of the present application provide an architecture of a blockchain system. As shown in fig. 4, the blockchain system includes a service network 1 and a billing network 2. The accounting network 2 comprises an accounting node 21 that recognizes the data blocks and records the data blocks, also called blocks, onto a block chain. The service network 1 comprises a service node 11, the service node 11 is responsible for performing service-related operations, and may not participate in accounting consensus, and the service node may send service data to an accounting node, so that the accounting node records a data block corresponding to the service data to an accounting node 21 on a block chain; the service node 11 may verify the data blocks recorded by the accounting node 21 onto the blockchain; or may request block data from accounting node 21 to synchronize the block data to itself for storage.
Specifically, the service node 11 verifying the data blocks recorded by the accounting node to the blockchain may include the following steps: an accounting node 21 in the accounting network generates a signature based on transaction information to be included in a data block to be added to the block chain using a key specific to the accounting node; the accounting node 21 adds the transaction information and the generated signature into a data block and adds the data block to a block chain; the accounting node 21 sends the signature to a service node in the service network, and the service node verifies the signature according to a key specific to the accounting node, so that the service node 11 verifies the data block recorded by the accounting node to the block chain.
The accounting node in the accounting network is responsible for recording the data blocks to the block chain, and the service node in the service network is responsible for witnessing the results recorded by the accounting node. Specifically, the accounting node generates a signature based on transaction information to be included in a data block to be added to the block chain, and then adds the transaction information and the generated signature to the data block for uplink. And sending the signature to a service node in the service network, so that the service node performs signature verification on the signature according to a key specific to the accounting node. The service node in the service network can witness the transaction data of the whole network by verifying the signature of the accounting node on the block. Billing networks, while having monopoly billing rights, are publicly traceable in all activities because the data blocks have digital signatures representing the identity of the billers. If the billing nodes do malicious collectively, then all nodes in the business network will retain evidence that the particular billing node does malicious. Compared with the traditional centralized system and the private chain, the operation of the system in the embodiment of the application is more transparent; compared with the traditional decentralized scheme, the scheme is more controllable and more convenient to supervise.
In one embodiment of the application, the billing network 2 and the service network 1 may be connected via a proxy node 12, and the proxy node 12 may be a service node of the service network 1, and is responsible for transferring information to be transferred from the billing node 21 to the service node 11. The service node 11 is a terminal of a transaction party generating various transaction data to be linked, and may also be a terminal inquiring transaction data from the accounting network 2. The transaction data generated by the service node 11 is transmitted to the accounting node 21 through the proxy node 12, and then is recorded on the blockchain after being identified, which is beneficial to the uniform processing and supervision of the transaction data, and the service node 11 can also perform the uplink supervision and witness of the transaction data through the information sent by the accounting node 21 through the proxy node 12, which has very important significance in some scenes that need uniform supervision but also afraid collective cheating of the supervised nodes and therefore need supervision.
In the structure shown in fig. 4, the service network 1 adopts a P2P (Peer-to-Peer) network mode. The P2P network is a distributed application architecture that distributes tasks and workloads among peers, and is a form of networking or networking that the peer-to-peer computing model forms at the application layer, i.e., "peer-to-peer" or "peer-to-peer" networks. It can be defined as: participants of the network share a portion of the hardware resources (processing power, storage power, network connectivity, printers, etc.) they own, which provide services and content over the network and which can be accessed directly by other peer nodes without going through intermediate entities. Participants in this network are both providers and acquirers of resources, services and content. Therefore, in the service network 1, when the proxy node 12 receives the message transmitted from the accounting node 21, the message is transmitted to the surrounding service nodes 11, and the surrounding service nodes 11 receive the message and transmit the message to the surrounding service nodes 11, so that the message is transmitted between each service node 11 of the service network 1.
Fig. 5 shows an architecture of another blockchain system applied in the embodiment of the present application. This architecture differs from the architecture shown in fig. 4 in that: the P2P network mode is not adopted in the service network 1, but the mode of the broadcast network is adopted. In particular, the proxy node 12, upon receiving the message passed from the accounting node 21, broadcasts the message to the other service nodes 11 in the service network 1. In this way, the propagation of the message between each service node 11 of the service network 1 is also achieved.
Fig. 6 shows an architecture of another blockchain system to which embodiments of the present invention are applied. This architecture differs from that shown in fig. 4 in that: the accounting network 2 is divided into a plurality of branch accounting networks. Each branch billing network may be responsible for the recording of some type of transaction information. For example, a business may have a supply chain financial transaction and may need to record contract information, credit, etc. generated during supply and marketing to the blockchain, and the business may need to issue invoices and also record invoicing information, invoice reimbursement information, etc. to the blockchain. In this case, in order to facilitate the requirement that the accounting node is supervised by the same department, the accounting node for recording the supply chain financial service transaction and the accounting node for recording the transaction in the invoice circulation process may belong to different departments. For example, the accounting node for recording the supply chain financial service transaction is an accounting terminal set by a bank, and the accounting node for recording the transaction in the invoice circulation process is an accounting terminal set by a national tax bureau. And supply chain financial transaction and recording of transactions during invoicing may also end up on a different branch billing network. In this case, the agent node 12 transmits the transaction information to the branch accounting network corresponding to the transaction type according to the transaction type carried in the transaction information transmitted from the service node 11.
It should be noted that in the architecture of the blockchain system shown in fig. 4 to 6, the proxy node 12 is located in the service network 1, and in other embodiments of the present application, the proxy node 12 may also be located in the billing network 2, or may be independent of the service network 1 and the billing network 2.
In the block chain system, block data stored by service nodes in a service network are from accounting nodes in an accounting network, specifically, after the accounting nodes write data blocks into the block chain, the accounting nodes synchronize the data blocks to the service nodes, and the service nodes correspondingly store the data.
After the accounting node synchronizes the data block to the service node, the service node may be a full node, that is, the service node stores the data block synchronized by the accounting node in full.
In some embodiments of the present application, the service node may also be an SPV (simple Payment Verification) node, where the SPV node only stores a part of data on the block chain, and the stored data includes at least block header data. In an embodiment, the SPV node may store only chunk header data in the data chunk.
In some embodiments of the present application, based on different data permissions of the service nodes, the data permissions of the service nodes for the same data are different, and therefore, the data stored by the service node may store the service data having the data permission in the block in addition to the block header data. For example, if the service node K is a tax bureau terminal at location a, the data stored by the service node K may include block header data of each data block and service data related to the tax bureau at location a, and the service node K may not store the service data unrelated to the tax bureau at location a in the data block.
The architecture of the blockchain system shown in fig. 4 to 6 can be applied to the application scenario of electronic invoices, and is described in detail as follows:
in one embodiment of the present application, the accounting nodes in the accounting network may be respective tax administration terminals, for example, the accounting network is formed by using the tax administration terminals deployed in a plurality of regions as one accounting node. Each service node in the service network may be a local tax office terminal, an invoicing agent facilitator terminal, an invoicing enterprise terminal, a personal user terminal, etc.
Specifically, in the electronic invoice system shown in fig. 7, a service layer, a routing agent layer, and a consensus network (billing network) layer may be included. The service layer is a service network, which includes various service nodes, such as a local tax bureau in a tax private network; billing facilitators, reimbursement facilitators, enterprises, etc. in the public cloud; payment facilitators, circulation facilitators, businesses, etc. in the private cloud.
The routing agent layer includes an agent node, the agent node provides functions of routing service, certificate caching and authentication service, P2P service, and the like, and the routing agent layer performs an isolation function on the service layer and the consensus network layer, which refers to the technical solutions of the foregoing embodiments. Alternatively, the proxy node in the routing proxy layer may be in a tax private network.
The consensus network (billing network) layer is a billing network and includes a plurality of blockchains, but in other embodiments of the present application, a blockchain may be included in the consensus network (billing network) layer.
The implementation details of the technical solution of the embodiment of the present application are set forth in detail below:
fig. 8 shows a flow diagram of a data processing method in a blockchain system according to an embodiment of the present application, the blockchain system comprising a billing network and a service network, the billing network comprising billing nodes, the service network comprising service nodes, the billing network being configured to maintain the blockchain, in particular, the billing nodes being configured to perform consensus and data uplink, the service nodes synchronizing the blockchain data from the billing network; the method shown in figure 8 is performed by a service node. Specifically, referring to fig. 8, the method at least includes steps 810 to 830, which are described in detail as follows:
step 810, obtaining data archiving instructions.
The data archiving instruction is used for indicating the service node to archive the block data stored by the service node so as to reduce the data storage pressure of the service node. The archiving is to dump part of the block data stored in the service node, so that the storage space originally used for storing the dumped block data in the service node is released.
In some embodiments of the present application, the data archiving instructions may be obtained by: acquiring block data synchronized from a billing network; data archiving instructions are obtained from the block data synchronized in the accounting network.
In this implementation, the accounting node in the accounting network writes the data archiving instruction as transaction information into the blockchain, and configures the data archiving instruction to be visible to all service nodes, so that during the data synchronization process, the blockdata including the data archiving instruction is synchronized to the service nodes in the service network. By the method, the block data of the service node can be dynamically filed according to the block height of the block chain, and system resources are flexibly saved.
In some embodiments of the present application, the new block data synchronized to the service node may be the full data of the block generated by the accounting node or may be part of the data in the generated block. If the service node is a full node (i.e., a node storing a complete block chain), then the data synchronized to the service node is the full data of the generated block, in other words, the block data stored thereon is consistent with the block data in the accounting node.
If the service node is an SPV node, the new block data synchronized to the service node includes block header data and transaction information associated with its own data authority, and specifically, the transaction information associated with the data authority of the service node may be information associated with its own service of the service node in the block. When the service node is an SPV node, the chunk data stored in the service node may be referred to as SPV data.
It can be understood that, in a scenario where the service node is an SPV node, since data permissions of the service nodes are different, there is a difference in corresponding tile data synchronized to the service nodes in the tile.
In an embodiment of the application, in order to write the data archiving command into the blockchain, an archiving intelligence contract is configured in the accounting network, a writing condition for writing the data archiving command into the blockchain is defined, and when the writing condition is reached, the accounting node writes the data archiving command into the block as transaction information and performs uplink processing.
In some embodiments of the present application, the writing condition may be a defined block height, and the data archive instruction is written to the block if the block height corresponding to the newly generated block in the block chain in the accounting node reaches the defined block height. For example, the accounting node may write the data archive instruction into the block as the first transaction message in the new block. The defined block height may be the target block height, or may be a block height adjacent to the target block height, for example, a block height greater than or less than the target block height. The data archiving instruction may correspondingly indicate a target block height for indicating which block data is archived by the service node.
Of course, since the block height in the block chain is increasing with the passage of time, the block height defined by the writing condition may be multiple, and if the block height corresponding to the newly generated block in the accounting node is the same as any one of the block heights defined by the writing condition, the writing condition is considered to be satisfied.
In some embodiments of the present application, the writing condition may also be a defined first height difference, and the writing condition is considered to be satisfied if the difference between the block height corresponding to the newly generated block in the accounting node and the block height corresponding to the block of the last written data archiving instruction is not less than the first height difference. In other words, in the present embodiment, the data archiving instruction is written into the block chain once every time the first height difference blocks are newly generated. Of course, the target block height indicated by the data archive instruction written into the blockchain each time is different. In some embodiments of the present application, the data archiving instruction written into the blockchain may be configured such that all the service nodes have data authority, and then all the service nodes may receive the blockdata including the archiving indication information. Therefore, the service node may obtain the data archiving instruction from the block data.
Step 820, obtain the latest block height in the block data stored in the service node.
As described above, the accounting node synchronizes the newly generated block to the service node, which correspondingly stores the block data corresponding to the new block. The block data stored by the service node at least comprises block head data, and the block height of the block from which the block data comes can be correspondingly determined according to the block head data. On the basis, the latest block height, namely the maximum value of the block heights corresponding to the stored block data, is correspondingly determined according to the block height of the block from which the stored block data of the service node is.
Step 830, performing archive processing on the block data in the service node according to the data archive instruction and the latest block height; after the filing processing is carried out, at least block data corresponding to a preset number of blocks closest to the block with the latest block height is reserved in the service node, so that query service is provided based on the block data reserved in the service node and the block data filed in the cold database.
The cold database is a database which is arranged for data storage differently from the service node and is in communication connection with the service node, so that the service node can access the cold database. On the basis, the service node can file the data to be filed into the cold database according to the data filing instruction so as to release the data storage space of the service node.
In the scheme of the application, the service node does not archive all the block data synchronized from the accounting node, but archives part of the block data, so that at least the block data corresponding to the preset number of blocks closest to the block with the latest block height is kept in the service node. The preset number can be set according to actual needs.
In some embodiments, since the node resources and the service needs of each service node are different, the preset number may be determined by each service node according to its service needs and/or node resources, and the preset number may be stored locally in each service node, so that the number of blocks reserved in each service node may be flexibly configured. Of course, the predetermined number may also hold the accounting node and be sent to the respective service node along with the data archiving instructions.
In some embodiments, since the uplink time of the service data is earlier, the access frequency of the service data is lower, determining the preset number according to the service requirement of the service data may include determining the preset number according to the access frequency of the block data (i.e., the number of accesses of the block data in a certain time period), for example, an access frequency threshold may be predetermined, and when the average access frequency of the block data corresponding to the first number of blocks closest to the block where the latest block height is located, the lowest access frequency or the median access frequency, is greater than the access frequency threshold, the first number may be set as the preset number.
The block data retained in the service node can be used as a data basis for data verification and witness of the service node, so that the service node can effectively deal with the condition that the block data with errors are received.
In some embodiments of the present application, step 830 comprises: calculating the difference between the latest block height and the preset number to obtain a first block height; and archiving the block data corresponding to the block with the block height smaller than the first block height in the service node to the cold database according to the data archiving instruction.
In the solution of this embodiment, each time the archive processing is performed, block data corresponding to a preset number of blocks closest to the block where the latest block height is located is reserved in each service node, and the reserved block data of the preset number of blocks is used as a basis for data verification and witness.
In other embodiments of the present application, the data archive instruction indicates a target block height for which the archive processing is required, and step 830 further includes; calculating the difference between the latest block height and the target block height to obtain a block height difference; if the block height difference is not less than the preset number, according to the data filing instruction, filing the block data corresponding to the block with the block height less than the target block height in the service node into the cold database. Wherein the latest block height is greater than the target block height.
In some embodiments, the target tile height may be determined based on traffic needs and/or node resources. Determining the target block height according to the service requirement may include determining the target block height according to an access frequency of the block data (i.e., the number of accesses of the block data within a certain time period), for example, an access frequency threshold may be predetermined, and when the block height in the block chain is smaller than an average access frequency of the block data corresponding to a block with the first target block height, and the lowest access frequency or the median access frequency is smaller than the fixed access frequency threshold, the first target block height may be set as the target block height. Determining the target block height based on the node resources may include determining the target block height based on a storage capacity and/or a processing capacity of the service node, the target block height being higher as the storage capacity and/or the processing capacity of the service node is smaller, wherein the storage capacity and/or the processing capacity of the service node may be transmitted by the service node to an accounting node for the accounting node to determine the target block height. In this embodiment, the number of blocks to be archived in the service node can be flexibly determined according to service needs and/or node resources, and resources of the service node are saved.
In this embodiment, the archiving is performed only when the block height difference is not less than the predetermined number, so that it can be ensured that the service node retains the block data of at least the predetermined number of blocks closest to the latest block height after the archiving process is performed.
In other embodiments, when the block height difference is smaller than the predetermined number, the block data corresponding to the predetermined number of blocks closest to the block with the latest block height may be retained in the service node, and the remaining block data may be archived, so as to reduce the storage resource occupied by the block data of the service node to the maximum extent without affecting the service.
For example, if the predetermined number is 1000 and the target block height is 500000, the service node may only forward the corresponding block data to the cold database according to the data archiving instruction until the service node stores the block data with the latest block height of at least 501000. That is to say, before the block data is transferred, at least the latest block data corresponding to 1000 blocks is guaranteed to be reserved in the service node, and the block data reserved by the service node is used as a data basis for data verification and witness of the service node, so that the service node can effectively deal with the situation that the wrong block data is received or the block data with the block height higher than the target block is received.
In some embodiments of the present application, in the case of a service upgrade, a chain upgrade, in a blockchain system, in order to reduce the impact of the upgrade performed on data written in the blockchain, a blockchain switch may be performed. Specifically, a new blockchain is newly created, and the original old blockchain is switched to the new blockchain. Where the chain identification of the new blockchain (e.g., the chain ID configured for the blockchain) is different from the chain identification of the old blockchain, but the created block of the new blockchain is linked to the last block of the old blockchain. In other words, the last block of the old block chain is used as the previous block of the created block in the new block chain, and the height of the created block in the new block chain is equal to the height of the last block in the old block chain plus 1, so as to realize the link between the new block chain and the old block chain.
In this scenario, the data archiving instruction may be obtained by the following process: and if receiving block chain switching information sent by the accounting node, confirming to acquire a data filing instruction, wherein the block chain switching information is generated when the accounting network is switched from an old block chain to a new block chain, the last block of the old block chain is used as the last block of a created block in the new block chain, and the height of the created block in the new block chain is equal to the height of the last block in the old block chain plus 1.
Compared with a new block chain, the timeliness of data in an old block chain is low, and for a service node, the access frequency of the data in the old block chain is low, so that in order to reduce the data storage pressure of the service node, after the service node receives block chain switching information, a data archiving instruction is generated according to the block height of the last block in the old block chain to instruct the service node to archive the block data stored by the service node and corresponding to the old block chain.
In the application scenario of blockchain switching, if the data archiving instruction indicates a target block height, the target block height may be the block height of the last block in the old blockchain. Of course, if the data archiving instruction does not indicate the block height, the service node may calculate the first block height as described above, and then determine whether to perform the archiving process according to the first block height.
In some embodiments of the present application, after the step of calculating the difference between the latest block height and the target block height to obtain the block height difference, the method further includes: if the difference between the latest block height and the target block height is less than the preset number, continuing to perform block data synchronization from the accounting network; and if the difference between the block height corresponding to the newly synchronized block data from the accounting network and the target block height is not less than the preset number, filing the block data corresponding to the block with the block height less than the target block height in the service node into the cold database.
After the service node receives the data filing instruction, the stored block data is filed according to the data filing instruction and the latest block height in the block data stored in the service node, and the service node is ensured to at least keep the block data corresponding to the preset number of blocks closest to the block with the latest block height after the filing processing, and other block data synchronized to the service node from the accounting network are filed in the cold database. On one hand, the storage space of the service node is released, and the data storage pressure of the service node is reduced; on the other hand, when the archiving processing is performed, it is ensured that at least block data corresponding to the preset number of blocks closest to the block with the latest block height is reserved in the service node, so that the service node can perform data witness or verification in the block chain according to the reserved block data after the data archiving is performed, and the condition that the service node does not perform block data verification or witness data basis when receiving wrong block data is avoided.
Further, since the plurality of accounting nodes are not synchronized with the service node at the same time during the data synchronization process of the accounting node to the service node, the service node may receive the block data synchronized by the accounting node a with the block height of T1 and may also receive the block data synchronized by the accounting node B with the block height of T2 during a data synchronization period, where T1 < T2. If the service node does not retain part of the previously synchronized block data, it may directly store the block data synchronized by accounting node B with block height T2 and discard the block data synchronized by accounting node a with block height T1, in which case it may cause the service node to miss the block data if it did not previously store the block data with block height T1.
In the scheme of the application, before the service node performs data dump, the service node at least reserves block data corresponding to a preset number of blocks closest to the block where the latest block height is located, so that the service node can determine the block data stored by the service node based on the reserved block data, and avoid the situation of data missing storage.
In the scheme of the application, as part of the block data in the service node is transferred to the cold database, the service node does not need to store data related to all nodes in the accounting network, and in this respect, the decoupling of the accounting network and the block data stored in the service node is realized.
In some embodiments of the present application, as shown in fig. 9, after step 830, the method further comprises:
at step 910, a data query request is received.
In step 920, a first block height corresponding to a block storing data requested by the data query request is determined.
The first block height is a block height corresponding to a block in which data requested by the data query request is located.
While the service node stores the block data, a kv (key-value) index table is correspondingly maintained, and the kv data index table records the transaction information and the index information of the block where the transaction information is located, so as to facilitate quick query of the transaction information. It should be noted that the data requested by the data query request is derived from the transaction information written into the blockchain, and therefore, the data query is performed in the transaction information stored in the blockchain.
Therefore, after receiving the data query request, the service node determines the block where the requested data is located, i.e., the block storing the requested data, in the kv index table according to the data requested by the data query request; the block height corresponding to the determined block is the first block height. In other words, the first block height is the block height of the block in which the requested data is stored.
In step 930, if it is determined that the block in which the data requested by the data query request is located is the block archived to the cold database according to the first block height, performing data query in the cold database, and returning the target data obtained by the query to the initiator of the data query request.
In step 940, if it is determined that the block in which the data requested by the data query request is located is a block that is not archived to the cold database according to the first block height, the data query is performed from the block data stored in the service node, and the target data obtained by the query is returned to the initiator of the data query request.
In some embodiments of the present application, in an application scenario where the data archiving instruction indicates the target block height, the first block height and the target block height may be compared to determine whether the block in which the data requested by the data query is located is the block to be archived to the cold database, that is: if the first block height is smaller than the target block height, determining that the block in which the data requested by the data query request is located is the block filed to the cold database; otherwise, if the first block height is not smaller than the target block height, it is determined that the block in which the data requested by the data query request is located is not the block archived to the cold database.
In some embodiments of the present application, an archive record may also be maintained in the service node, the archive record indicating a block height in the service node corresponding to block data archived in the cold database. In the application scenario, after determining the first block height, the block in which the data requested by the data query request is located may be determined to be the block archived to the cold database by comparing the first block height with the maximum block height in the archive record if the first block height is not greater than the maximum block height; otherwise, if the first block height is larger than the maximum block height, the block in which the data requested by the data query request is located is determined not to be the block archived to the cold database.
After the block data is filed, the service node forwards the data query request to a cold database aiming at the received data query request if the requested data is located in the filed data, and correspondingly acquires corresponding data from the cold database and returns the corresponding data to the initiator of the data query request; otherwise, if the requested data is located in the block data reserved by the service node, the data query is directly performed in the service node.
Fig. 10 shows a flow diagram of a data processing method in a blockchain system including an accounting network including accounting nodes and a service network including service nodes, the accounting network for maintaining blockchain data, and the accounting nodes for performing consensus and data uplink service nodes synchronizing blockchain data from the accounting network according to one embodiment of the present application; the method shown in fig. 10 is executed by the accounting node, and as shown in fig. 10, the method at least includes steps 1010 and 1020, which are described as follows:
step 1010, a data archiving instruction is obtained.
Step 1020, sending a data archiving instruction to the service node, so that the service node archives the block data according to the data archiving instruction and the latest block height in the data of the storage block of the service node; after the filing processing is carried out, at least reserving block data corresponding to a preset number of blocks closest to the block where the latest block height is located in the service node; to provide query services based on the block data retained in the service node and the block data archived in the cold database.
The process of the service node performing the archiving processing is described above, and is not described herein again.
In some embodiments of the application, as shown in FIG. 11, step 1020 may comprise:
step 1110, obtain the block height corresponding to the newly generated block in the block chain.
In step 1120, if the block height of the newly generated block in the block chain meets the writing condition defined by the archive intelligence contract, the data archive instruction is written into the block as the transaction information and the uplink processing is performed.
At step 1130, chunk data, including data archiving instructions, is synchronized to the service node.
In the solution of the present application, the accounting node stores the complete block chain. And if the block height corresponding to the newly generated block in the block chain in the accounting node meets the writing condition of the data archiving instruction, the accounting node writes the pre-configured data archiving instruction into the block according to the archiving intelligent contract.
The writing condition may be that a specified block height is reached, that is, if the block height corresponding to the latest generated block in the block chain reaches the specified block height, the writing condition is defined by the archive intelligence contract; otherwise, it is not satisfied.
And when the uplink condition is met, writing the data archiving instruction into the blockchain as transaction information according to the configured archiving intelligent contract. Then, the accounting node synchronizes the block data including the data archiving instruction to a service node in the service network correspondingly, so that the service node archives the block data according to the data archiving instruction, that is, part of the block data is archived in the cold database. The process of block data archiving performed by a specific service node is described above, and is not described herein again.
In some embodiments of the present application, the data archiving instruction written in the block is configured such that all the service nodes have data permission, so that it can be ensured that all the service nodes in the service network can obtain the data archiving instruction.
In some embodiments of the present application, the service node comprises an SPV node. Since different service nodes have different data authorities, in order to ensure that the archiving indication information written into the block chain can be received by all service nodes in the service network, the data archiving instruction on the block chain in the accounting network is configured to ensure that all SPV nodes have the data authority, so that the service nodes can be ensured to correspondingly archive the block data according to the archiving indication information.
In other embodiments of the present application, as shown in FIG. 12, step 1010, comprises:
step 1210, if the old block chain in the accounting node needs to be switched to the new block chain, taking the last block of the old block chain as the last block of the created block in the new block chain, wherein the height of the created block in the new block chain is equal to the height of the block corresponding to the last block of the old block chain plus 1.
Step 1220, generating a block chain switching information according to the block chain identifier of the new block chain and the block height corresponding to the last block in the old block chain, and using the block chain switching information as a data archiving instruction.
In some embodiments of the present application, whether to perform a blockchain handover may be determined according to a consensus algorithm in the blockchain. Specifically, the block height is set for the last block in the old block chain in advance, and if the accounting node in the accounting network is determined to complete the creation of the last block in the old block chain through the consensus algorithm, the new block chain is correspondingly switched. And after switching to the new block chain, taking the last block in the old block chain as the previous block of the created block in the new block chain, and correspondingly, setting the block height of the created block in the new block chain to be 1 plus the block height of the last block in the old block chain, thereby realizing seamless switching from the old block chain to the new block chain and continuously providing service for the outside. After switching to the new blockchain, the node corresponding to the old blockchain is switched to a state of non-common identification and no block, and only the query of the data in the old blockchain is provided.
In this embodiment, while the blockchain is upgraded across chains, the service node may be instructed to archive the blockchain data corresponding to the old blockchain according to the generated blockchain switching information. For the service nodes in the service side (service network), when the block chain is upgraded in a cross-chain mode, the basic data structure of the block data stored in the service node of the store is not needed, and the service can be provided continuously and seamlessly. Moreover, based on the cross-link upgrade performed in the accounting network, the service node is triggered to perform the transfer of the block data, so that part of the data storage space in the service node is released, and the data storage pressure in the service node is reduced.
In some embodiments of the present application, as shown in fig. 13, the data processing method in the blockchain system performed by the accounting node further includes:
step 1310, authority information of the service node is obtained, and the authority information indicates data authority corresponding to the service node.
Step 1320, extracting the block head data and the target service data with data authority of the service node from the new block to be synchronized according to the authority information.
Step 1330, synchronizing the block header data and the target service data corresponding to the new block to the service node.
In the solution of this embodiment, the data permissions corresponding to the service nodes are different, and therefore, the block data synchronized with the service node needs to be determined according to the data permissions corresponding to the service nodes.
The data authority corresponding to the service node may be configured by the registry according to the node information of the service node when the service node registers in the registry of the blockchain system. For example, if the service node is a terminal where an enterprise is located, the node information of the service node may be registration information of the enterprise, such as an enterprise name, a unified social credit code, enterprise financial account information, an enterprise operation range, and the like; if the service node is a terminal where the consumer is located, the node information may be identity information of the consumer, such as an identification number, a name, financial account information, and the like. Of course, the node information may also be other information in different application scenarios.
Embodiments of the apparatus of the present application are described below, which may be used to perform the methods of the above-described embodiments of the present application. For details which are not disclosed in the embodiments of the apparatus of the present application, reference is made to the above-described embodiments of the method of the present application.
Fig. 14 is a block diagram illustrating a data processing apparatus in a blockchain system including a billing network including a billing node and a service network including a service node, the billing network for maintaining blockchain data, the billing node for performing consensus and data uplink, the service node synchronizing blockchain data from the billing network, according to one embodiment; the apparatus shown in fig. 14 can be applied to a service node, and as shown in fig. 14, the data processing apparatus in the blockchain system includes:
the first obtaining module 1410 is configured to obtain a data archiving instruction.
A latest block height obtaining module 1420, configured to obtain a latest block height in the block data stored in the service node.
The archiving module 1430 is configured to archive the block data in the service node according to the data archiving instruction and the latest block height; after the filing processing is carried out, at least reserving block data corresponding to a preset number of blocks closest to the block where the latest block height is located in the service node; to provide query services based on the block data retained in the service node and block data archived in a cold database.
In some embodiments of the present application, archive module 1430 includes: the first calculating unit is used for calculating the difference between the height of the latest block and the preset number to obtain the height of the first block; and the first filing unit is used for filing the block data corresponding to the block with the block height smaller than the first block height in the service node into the cold database according to the data filing instruction.
In other embodiments of the present application, the data archive instruction indicates a target block height for which the archive processing is required, and the archive module 1430 includes: the second calculation unit is used for calculating the difference between the height of the latest block and the height of the target block to obtain the block height difference; and if the block height difference is not less than the preset number, the second filing unit is used for filing the block data corresponding to the block with the block height less than the target block height in the service node to the cold database according to the data filing instruction.
In some embodiments of the present application, the first obtaining module 1410 includes: a first acquiring unit, configured to acquire block data synchronized from the billing network; a data archiving instruction obtaining unit, configured to obtain the data archiving instruction from the block data synchronized in the billing network.
In other embodiments of the present application, the first obtaining module 1410 is configured to: if block chain switching information sent by an accounting node is received, confirming to acquire the data filing instruction, wherein the block chain switching information is generated when the accounting network is switched from an old block chain to a new block chain, the last block of the old block chain is used as the last block of a created block in the new block chain, and the block height of the created block in the new block chain is equal to the block height of the last block in the old block chain plus 1; the target block height is the block height of the last block in the old block chain.
In some embodiments of the present application, the data processing apparatus in the blockchain system further includes: a first synchronization module, configured to continue to perform block data synchronization from the billing network if a difference between the latest block height and the target block height is smaller than a height threshold; and a second filing module, configured to file, to the cold database, the block data corresponding to the block with the block height smaller than the target block height in the service node, if a difference between the block height corresponding to the newly synchronized block data from the accounting network and the target block height is not smaller than the height threshold.
In some embodiments of the present application, the data processing apparatus in the blockchain system further includes: the data query request receiving module is used for receiving a data query request; the first query module is used for querying data in the cold database and returning target data obtained by query to an initiator of the data query request if a block where the data requested by the data query request is located is a block filed to the cold database; and the second query module is used for performing data query from the block data stored by the service node and returning the target data obtained by query to the initiator of the data query request if the block in which the data requested by the data query request is located is a block which is not archived to the cold database.
In some embodiments of the application, the block data to which the service node is synchronized from the accounting network comprises block header data and transaction information associated with data rights of the service node in a block.
Fig. 15 is a block diagram illustrating a data processing apparatus in a blockchain system including a billing network including a billing node and a service network including a service node, the billing network for maintaining blockchain data, the billing node for performing consensus and data uplink, the service node synchronizing blockchain data from the billing network, according to one embodiment of the present application; the apparatus shown in fig. 15 may be applied to a billing node, and as shown in fig. 15, the apparatus at least includes:
the second obtaining module 1510 is configured to obtain a data archiving instruction.
A sending module 1520, configured to send the data archiving instruction to the service node, so that the service node is enabled to send the data archiving instruction
Filing the block data according to the data filing instruction and the latest block height in the data of the storage area of the block data; after the filing processing is carried out, at least reserving block data corresponding to a preset number of blocks closest to the block where the latest block height is located in the service node; to provide query services based on the block data retained in the service node and block data archived in a cold database.
In some embodiments of the present application, the transmitting module 1520 includes: the block height acquisition unit is used for acquiring the block height corresponding to the latest generated block in the block chain; the writing module is used for writing the data archiving instruction as transaction information into the block and performing uplink processing if the block height of the latest generated block in the block chain meets the writing condition defined by the archiving intelligent contract; a second synchronization module to synchronize the chunk data including the data archiving instruction to the service node.
In some embodiments of the present application, the data archiving instructions written to the blocks are configured such that all of the service nodes have data authority.
In some embodiments of the present application, the second obtaining module 1510 comprises: a new block chain creating unit, configured to, if an old block chain in the accounting node needs to be switched to a new block chain, take a last block of the old block chain as a previous block of a created block in the new block chain, where a block height of the created block in the new block chain is equal to a block height corresponding to the last block of the old block chain plus 1; and the block chain switching information generating unit is used for generating block chain switching information according to the block chain identifier of the new block chain and the block height corresponding to the last block in the old block chain, and taking the block chain switching information as the data archiving instruction.
In some embodiments of the present application, the data processing apparatus in the blockchain system further includes: the authority information acquisition module is used for acquiring authority information of the service node, and the authority information indicates the data authority corresponding to the service node; the extraction module is used for extracting block head data and target transaction information related to the data authority of the service node from the block to be synchronized according to the authority information; a third synchronization module, configured to synchronize the block header data and the target transaction information to the service node.
FIG. 16 illustrates a schematic structural diagram of a computer system suitable for use in implementing the electronic device of an embodiment of the present application.
It should be noted that the computer system 1600 of the electronic device shown in fig. 16 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present application.
As shown in fig. 16, the computer system 1600 includes a Central Processing Unit (CPU) 1601 which can perform various appropriate actions and processes, such as executing the method in the above-described embodiment, according to a program stored in a Read-Only Memory (ROM) 1602 or a program loaded from a storage portion 1608 into a Random Access Memory (RAM) 1603. In the RAM 1603, various programs and data necessary for system operation are also stored. The CPU1601, ROM1602, and RAM 1603 are connected to each other via a bus 1604. An Input/Output (I/O) interface 1605 is also connected to the bus 1604.
The following components are connected to the I/O interface 1605: an input portion 1606 including a keyboard, a mouse, and the like; an output section 1607 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, a speaker, and the like; a storage portion 1608 including a hard disk and the like; and a communication section 1609 including a Network interface card such as a LAN (Local Area Network) card, a modem, or the like. The communication section 1609 performs communication processing via a network such as the internet. The driver 1610 is also connected to the I/O interface 1605 as needed. A removable medium 1611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 1610 as necessary, so that a computer program read out therefrom is mounted in the storage portion 1608 as necessary.
In particular, according to embodiments of the application, the processes described above with reference to the flow diagrams may be implemented as computer software programs. For example, embodiments of the present application include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated by the flow chart. In such embodiments, the computer program may be downloaded and installed from a network via the communication portion 1609, and/or installed from the removable media 1611. When the computer program is executed by a Central Processing Unit (CPU) 1601, various functions defined in the system of the present application are executed.
It should be noted that the computer readable medium shown in the embodiments of the present application may be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a Read-Only Memory (ROM), an Erasable Programmable Read-Only Memory (EPROM), a flash Memory, an optical fiber, a portable Compact Disc Read-Only Memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present application, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In this application, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. Each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present application may be implemented by software, or may be implemented by hardware, and the described units may also be disposed in a processor. Wherein the names of the elements do not in some way constitute a limitation on the elements themselves.
As another aspect, the present application also provides a computer-readable storage medium, which may be contained in the electronic device described in the above embodiments; or may exist separately without being assembled into the electronic device. The computer-readable storage medium carries computer-readable instructions that, when executed by a processor, implement the method in the embodiments described above.
According to an aspect of the present application, there is also provided an electronic device, including: a processor; a memory having computer readable instructions stored thereon which, when executed by the processor, implement the method of the above embodiments.
According to an aspect of an embodiment of the present application, there is provided a computer program product or a computer program comprising computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions to cause the computer device to perform the method provided in the above-mentioned alternative embodiments.
It should be noted that although in the above detailed description several modules or units of the device for action execution are mentioned, such a division is not mandatory. Indeed, the features and functionality of two or more modules or units described above may be embodied in one module or unit, according to embodiments of the application. Conversely, the features and functions of one module or unit described above may be further divided into embodiments by a plurality of modules or units.
Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein may be implemented by software, or by software in combination with necessary hardware. Therefore, the technical solution according to the embodiments of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a usb disk, a removable hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the embodiments of the present application.
Other embodiments of the present application will be apparent to those skilled in the art from consideration of the specification and practice of the embodiments disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains.
It will be understood that the present application is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the application is limited only by the appended claims.

Claims (15)

1. A data processing method in a blockchain system, wherein the blockchain system comprises an accounting network and a service network, the service network comprises service nodes, the accounting network is used for maintaining blockchain data, and the service nodes synchronize the blockchain data from the accounting network; the method is performed by the service node, the method comprising:
acquiring a data archiving instruction;
acquiring the latest block height in the data of the storage block of the service node;
according to the data archiving instruction and the latest block height, archiving the block data in the service node; after the filing processing is performed, at least block data corresponding to a preset number of blocks closest to the block with the latest block height is reserved in the service node, so that query service is provided based on the block data reserved in the service node and the block data filed in the cold database.
2. The method of claim 1, wherein the archiving the block data in the service node according to the data archiving instruction and the latest block height comprises:
calculating the difference between the height of the latest block and the preset number to obtain the height of a first block;
and archiving the block data corresponding to the block with the block height smaller than the first block height in the service node to the cold database according to the data archiving instruction.
3. The method of claim 1, wherein the data archive instructions indicate a target block height for which archive processing is required;
the archiving processing of the block data in the service node according to the data archiving instruction and the latest block height includes:
calculating the difference between the height of the latest block and the height of the target block to obtain the block height difference;
if the block height difference is not smaller than the preset number, according to the data filing instruction, filing the block data corresponding to the block with the block height smaller than the target block height in the service node to the cold database.
4. The method of any of claims 1-3, wherein the obtaining data archiving instructions comprises:
acquiring block data synchronized from the billing network;
obtaining the data archiving instructions in the block data synchronized from the accounting network.
5. The method of any of claims 1-3, wherein the obtaining data archiving instructions comprises:
and if block chain switching information sent by an accounting node is received, confirming to acquire the data filing instruction, wherein the block chain switching information is generated when the accounting network is switched from an old block chain to a new block chain, the last block of the old block chain is used as the last block of a created block in the new block chain, and the block height of the created block in the new block chain is equal to the block height of the last block in the old block chain plus 1.
6. The method of claim 1, wherein after performing the archive processing on the block data in the service node according to the data archive instruction and the latest block height, the method further comprises:
receiving a data query request;
if the block where the data requested by the data query request is located is a block filed to a cold database, performing data query in the cold database, and returning the target data obtained by query to the initiator of the data query request;
and if the block where the data requested by the data query request is located is a block which is not filed to a cold database, performing data query from the block data stored by the service node, and returning the target data obtained by query to the initiator of the data query request.
7. The method of claim 1, wherein the block data synchronized to by the service node from the billing network comprises: block header data and transaction information in a block associated with data permissions of the service node.
8. A data processing method in a blockchain system, wherein the blockchain system comprises an accounting network and a service network, wherein the accounting network comprises accounting nodes, wherein the service network comprises service nodes, wherein the accounting network is used for maintaining blockchain data, and wherein the service nodes synchronize blockchain data from the accounting network; the method is performed by the accounting node, the method comprising:
acquiring a data archiving instruction;
sending the data archiving instruction to the service node so that the service node archives the block data according to the data archiving instruction and the latest block height in the data of the storage block of the service node; after the filing processing is performed, at least block data corresponding to a preset number of blocks closest to the block with the latest block height is reserved in the service node, so that query service is provided based on the block data reserved in the service node and the block data filed in the cold database.
9. The method of claim 8, wherein sending the data archiving instruction to the service node comprises:
acquiring the block height corresponding to the latest generated block in the block chain;
if the block height of the newly generated block in the block chain meets the writing condition defined by the filing intelligent contract, writing the data filing instruction as transaction information into the block and performing uplink processing;
synchronizing block data comprising the data archiving instructions to the service node.
10. The method of claim 8, wherein obtaining data archiving instructions comprises:
if the old block chain in the accounting node needs to be switched to a new block chain, taking the last block of the old block chain as the last block of the created block in the new block chain, wherein the height of the created block in the new block chain is equal to the height of the block corresponding to the last block of the old block chain plus 1;
and generating block chain switching information according to the block chain identifier of the new block chain and the block height corresponding to the last block in the old block chain, and taking the block chain switching information as the data archiving instruction.
11. The method according to any one of claims 8-10, further comprising:
acquiring authority information of the service node, wherein the authority information indicates data authority corresponding to the service node;
extracting block head data and target transaction information associated with the data authority of the service node from a block to be synchronized according to the authority information;
synchronizing the block header data and the target transaction information to the service node.
12. A data processing apparatus in a blockchain system, the blockchain system comprising an accounting network and a service network, the service network comprising service nodes, the accounting network being configured to maintain blockchain data, the service nodes synchronizing blockchain data from the accounting network; the device is applied to the service node, and the device comprises:
the first acquisition module is used for acquiring a data archiving instruction;
a latest block height obtaining module, configured to obtain a latest block height in the block data stored in the service node;
the archiving module is used for archiving the block data in the service node according to the data archiving instruction and the latest block height; after the filing processing is performed, at least block data corresponding to a preset number of blocks closest to the block with the latest block height is reserved in the service node, so that query service is provided based on the block data reserved in the service node and the block data filed in the cold database.
13. A data processing apparatus in a blockchain system, the blockchain system comprising an accounting network and a service network, the accounting network comprising accounting nodes, the service network comprising service nodes, the accounting network for maintaining blockchain data, the service nodes synchronizing blockchain data from the accounting network; the device is applied to the accounting node, and comprises:
the second acquisition module is used for acquiring a data archiving instruction;
the sending module is used for sending the data archiving instruction to the service node so that the service node can archive the block data according to the data archiving instruction and the latest block height in the data of the storage area of the service node; after the filing processing is carried out, at least reserving block data corresponding to a preset number of blocks closest to the block where the latest block height is located in the service node; to provide query services based on the block data retained in the service node and block data archived in a cold database.
14. An electronic device, comprising:
a processor;
a memory having computer-readable instructions stored thereon which, when executed by the processor, implement the method of any of claims 1-11.
15. A computer-readable storage medium having computer-readable instructions stored thereon, which when executed by a processor, implement the method of any one of claims 1-11.
CN202011618496.0A 2020-12-31 2020-12-31 Data processing method and related equipment in block chain system Active CN112291376B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011618496.0A CN112291376B (en) 2020-12-31 2020-12-31 Data processing method and related equipment in block chain system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011618496.0A CN112291376B (en) 2020-12-31 2020-12-31 Data processing method and related equipment in block chain system

Publications (2)

Publication Number Publication Date
CN112291376A true CN112291376A (en) 2021-01-29
CN112291376B CN112291376B (en) 2021-04-09

Family

ID=74425283

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011618496.0A Active CN112291376B (en) 2020-12-31 2020-12-31 Data processing method and related equipment in block chain system

Country Status (1)

Country Link
CN (1) CN112291376B (en)

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112925479A (en) * 2021-02-20 2021-06-08 京东数字科技控股股份有限公司 Block chain data management method and device, electronic equipment and medium
CN112948350A (en) * 2021-02-02 2021-06-11 中央财经大学 Distributed account book model cold data archiving and migration storage method based on MPT verification
CN113220665A (en) * 2021-05-20 2021-08-06 成都质数斯达克科技有限公司 Block chain data archiving method and device, electronic equipment and readable storage medium
CN113360456A (en) * 2021-08-11 2021-09-07 腾讯科技(深圳)有限公司 Data archiving method, device, equipment and storage medium
CN113610527A (en) * 2021-08-24 2021-11-05 上海点融信息科技有限责任公司 Alliance chain transaction method, device, system, terminal device and storage medium
CN115174599A (en) * 2022-05-13 2022-10-11 达闼机器人(成都)有限公司 Method, device, equipment and medium for creating service filing node and processing data
WO2023111882A1 (en) * 2021-12-17 2023-06-22 National Payments Corporation Of India A system for data archival in a blockchain network and a method thereof
CN116361271A (en) * 2023-05-09 2023-06-30 中航信移动科技有限公司 Block chain data modification and migration method, electronic equipment and storage medium
CN117806876A (en) * 2024-03-01 2024-04-02 北京邮电大学 Marine satellite Internet of things blockchain lightweight storage and recovery method and device

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109523385A (en) * 2018-12-07 2019-03-26 深圳市智税链科技有限公司 Method, accounting nodes and the medium of Transaction Information are inquired in block chain network
CN110011788A (en) * 2019-04-10 2019-07-12 深圳市网心科技有限公司 A kind of data processing method based on block chain, system and relevant device
CN110442644A (en) * 2019-07-08 2019-11-12 深圳壹账通智能科技有限公司 Block chain data filing storage method, device, computer equipment and storage medium
CN111209346A (en) * 2020-04-24 2020-05-29 腾讯科技(深圳)有限公司 Block chain data archiving method and device and computer readable storage medium
CN111966538A (en) * 2020-10-20 2020-11-20 支付宝(杭州)信息技术有限公司 Block chain data recovery method and device
CN111984735A (en) * 2020-09-03 2020-11-24 深圳壹账通智能科技有限公司 Data archiving method and device, electronic equipment and storage medium
CN112015697A (en) * 2020-10-27 2020-12-01 暗链科技(深圳)有限公司 Method and system for archiving data on block chain

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109523385A (en) * 2018-12-07 2019-03-26 深圳市智税链科技有限公司 Method, accounting nodes and the medium of Transaction Information are inquired in block chain network
CN110011788A (en) * 2019-04-10 2019-07-12 深圳市网心科技有限公司 A kind of data processing method based on block chain, system and relevant device
CN110442644A (en) * 2019-07-08 2019-11-12 深圳壹账通智能科技有限公司 Block chain data filing storage method, device, computer equipment and storage medium
CN111209346A (en) * 2020-04-24 2020-05-29 腾讯科技(深圳)有限公司 Block chain data archiving method and device and computer readable storage medium
CN111984735A (en) * 2020-09-03 2020-11-24 深圳壹账通智能科技有限公司 Data archiving method and device, electronic equipment and storage medium
CN111966538A (en) * 2020-10-20 2020-11-20 支付宝(杭州)信息技术有限公司 Block chain data recovery method and device
CN112015697A (en) * 2020-10-27 2020-12-01 暗链科技(深圳)有限公司 Method and system for archiving data on block chain

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112948350A (en) * 2021-02-02 2021-06-11 中央财经大学 Distributed account book model cold data archiving and migration storage method based on MPT verification
CN112948350B (en) * 2021-02-02 2023-08-01 中央财经大学 Distributed ledger model cold data archiving and migration storage method based on MPT verification
CN112925479A (en) * 2021-02-20 2021-06-08 京东数字科技控股股份有限公司 Block chain data management method and device, electronic equipment and medium
CN113220665A (en) * 2021-05-20 2021-08-06 成都质数斯达克科技有限公司 Block chain data archiving method and device, electronic equipment and readable storage medium
CN113220665B (en) * 2021-05-20 2023-10-20 成都质数斯达克科技有限公司 Block chain data archiving method and device, electronic equipment and readable storage medium
CN113360456A (en) * 2021-08-11 2021-09-07 腾讯科技(深圳)有限公司 Data archiving method, device, equipment and storage medium
CN113610527A (en) * 2021-08-24 2021-11-05 上海点融信息科技有限责任公司 Alliance chain transaction method, device, system, terminal device and storage medium
WO2023111882A1 (en) * 2021-12-17 2023-06-22 National Payments Corporation Of India A system for data archival in a blockchain network and a method thereof
CN115174599A (en) * 2022-05-13 2022-10-11 达闼机器人(成都)有限公司 Method, device, equipment and medium for creating service filing node and processing data
CN116361271A (en) * 2023-05-09 2023-06-30 中航信移动科技有限公司 Block chain data modification and migration method, electronic equipment and storage medium
CN116361271B (en) * 2023-05-09 2024-01-23 中航信移动科技有限公司 Block chain data modification and migration method, electronic equipment and storage medium
CN117806876A (en) * 2024-03-01 2024-04-02 北京邮电大学 Marine satellite Internet of things blockchain lightweight storage and recovery method and device

Also Published As

Publication number Publication date
CN112291376B (en) 2021-04-09

Similar Documents

Publication Publication Date Title
CN112291376B (en) Data processing method and related equipment in block chain system
EP4120114A1 (en) Data processing method and apparatus, smart device and storage medium
CN110827097B (en) Tax management method, apparatus, medium and electronic device based on block chain system
CN112733174B (en) Authentication management method and system of block chain system and electronic equipment
CN112232823B (en) Transaction processing method, device, medium and electronic equipment of block chain system
CN109658097B (en) Authentication management method, device, medium and electronic equipment of block chain system
US11128470B2 (en) Methods and systems for automatic blockchain deployment based on cloud platform
CN112231741B (en) Data processing method, device, medium and electronic equipment based on block chain system
US20230316273A1 (en) Data processing method and apparatus, computer device, and storage medium
CN112287031B (en) Data synchronization method and device of block chain system, readable medium and electronic equipment
KR102569409B1 (en) Systems and methods for virtual distributed ledger networks
CN112291372B (en) Asynchronous posting method, device, medium and electronic equipment for block chain
CN110730081B (en) Block chain network-based certificate revocation method, related equipment and medium
CN114493865A (en) Decentralized internet cooperative system and data interaction method based on block chain
CN116150260A (en) Data processing method, device, medium and electronic equipment of block chain system
CN112532753B (en) Data synchronization method, device, medium and electronic equipment of block chain system
CN112231414B (en) Data synchronization method and device of block chain system, readable medium and electronic equipment
CN116647326A (en) Block chain-based embedded gateway system
CN112565104B (en) Flow control method, device, medium and electronic equipment of block chain system
CN112926981B (en) Transaction information processing method, device and medium for block chain and electronic equipment
CN116126480A (en) Cross-region block chain processing method and device for transaction, intelligent equipment, medium and product
CN116233139A (en) Data processing method, device, medium and electronic equipment of block chain system
CN116186786A (en) Block chain-based service processing method and device, electronic equipment and readable medium
CN116186749A (en) Block chain-based service processing method and device, electronic equipment and readable medium
CN111464311A (en) Method for integrated authorization management of mechanical-fixed multi-nodes

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
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40038169

Country of ref document: HK