Blockchain node access method, device, equipment, storage medium and product
By obtaining data from the nodes of the target blockchain and generating data indexes when accessing nodes, and migrating to the target server, the problem of waste of storage resources during access to blockchain nodes is solved, and access efficiency is improved.
Patent Information
- Application Number
- CN202210833912.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-14
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2042-07-14
AI Technical Summary
Blockchain nodes need to download a large amount of data during access, resulting in excessive storage resources allocation and waste of resources.
By obtaining data from the nodes of the target blockchain and generating data indexes, and migrating to the target server, the access node querys data based on the data index to avoid directly downloading data to the access node.
The storage resource requirements of the access nodes are reduced, the storage resource waste is avoided, and the efficiency of the access nodes is improved.
Smart Images

Figure CN117407389B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of blockchain technology, and in particular to a method, device, equipment, storage medium and product for accessing a blockchain node. Background Art
[0002] With the rapid development of blockchain technology, the amount of blockchain data is increasing. Nodes newly connected to the blockchain generally obtain data in the blockchain by downloading it to achieve the consensus function of the node. This results in a large amount of data that the node needs to download, and therefore more storage resources need to be configured for each node. Summary of the Invention
[0003] The embodiments of the present application provide a blockchain node access method, apparatus, device, storage medium, and product, which can reduce the storage resources required to configure access nodes and avoid waste of storage resources. The technical solution is as follows:
[0004] In one aspect, a method for accessing a blockchain node is provided, the method comprising:
[0005] Responding to the access request from the access node, obtaining data of the target blockchain from a node of the target blockchain;
[0006] Generate a data index based on the data and the storage location of the data on the node, where the data index represents a mapping relationship between the data and the storage location of the data;
[0007] Connecting the access node to the target blockchain;
[0008] The data index is migrated to a target server, so that the access node queries the data from the node based on the data index in the target server.
[0009] In some embodiments, obtaining data of the target blockchain from a node of the target blockchain includes:
[0010] In response to the access request of the access node, determining, from the target blockchain, a target node marked with a target identifier, wherein the target identifier indicates that the marked node stores data generated by the target blockchain from the creation time to the current time;
[0011] Acquire backup data of the data stored in the target node to obtain the data.
[0012] In some embodiments, the method further comprises:
[0013] querying multiple servers that are allowed to access the access node, determining access paths between the multiple servers and the access node, and using the server with the shortest access path as the target server; or,
[0014] The server whose access path distance is within a preset distance is used as the target server.
[0015] In some embodiments, the data consists of blocks on the target blockchain, the data index includes a first index and a second index, and generating the data index based on the data and a storage location of the data on the node includes:
[0016] Dividing the blocks on the target blockchain into a plurality of block groups, each block group including a preset number of adjacent blocks;
[0017] Create an index key value and index identifier for each block group;
[0018] Generate a first index based on the index key values and index identifiers of the plurality of block groups, where the first index represents a mapping relationship between the index key values of the block groups and the index identifiers of the block groups;
[0019] Obtain the storage location of each block group on the node;
[0020] Based on the index identifiers and storage locations of the plurality of block groups, a second index is generated, where the second index represents a mapping relationship between the index identifiers of the block groups and the storage locations of the block groups.
[0021] In some embodiments, connecting the access node to the target blockchain includes:
[0022] Obtaining node information of the access node and configuration information of the target blockchain;
[0023] When it is determined based on the node information and the configuration information that the access node has passed verification, the access node is connected to the target blockchain.
[0024] In some embodiments, the node information includes the node name of the access node, the organization to which the access node belongs, the blockchain certificate of the access node, the network information of the access node, the channel joined by the access node, and the chain code installed by the access node. The network information is used by the access node to access other nodes, and the channel is used by the access node to communicate with other nodes. The configuration information includes the nodes allowed to access the target blockchain and the target network information, target channel, and target chain code that match the target blockchain.
[0025] The method further comprises:
[0026] If, based on the node name, the organization, and the blockchain certificate, it is determined that the access node is a node allowed to access the target blockchain, and the network information, the channel, and the chain code match the target network information, the target channel, and the target chain code, respectively, then it is determined that the access node verification has passed.
[0027] In another aspect, a blockchain node access device is provided, the device comprising:
[0028] An acquisition module, configured to acquire data of the target blockchain from a node of the target blockchain in response to an access request from the access node;
[0029] a generating module, configured to generate a data index based on the data and a storage location of the data on the node, wherein the data index represents a mapping relationship between the data and the storage location of the data;
[0030] An access module, configured to connect the access node to the target blockchain;
[0031] A migration module is used to migrate the data index to a target server so that the access node can query the data from the node based on the data index in the target server.
[0032] In some embodiments, the acquisition module is used to:
[0033] In response to the access request of the access node, determining, from the target blockchain, a target node marked with a target identifier, wherein the target identifier indicates that the marked node stores data generated by the target blockchain from the creation time to the current time;
[0034] Acquire backup data of the data stored in the target node to obtain the data.
[0035] In some embodiments, the apparatus further comprises:
[0036] querying multiple servers that are allowed to access the access node, determining access paths between the multiple servers and the access node, and using the server with the shortest access path as the target server; or,
[0037] The server whose access path distance is within a preset distance is used as the target server.
[0038] In some embodiments, the data consists of blocks on the target blockchain, the data index includes a first index and a second index, and the generation module is configured to:
[0039] Dividing the blocks on the target blockchain into a plurality of block groups, each block group including a preset number of adjacent blocks;
[0040] Create an index key value and index identifier for each block group;
[0041] Generate a first index based on the index key values and index identifiers of the plurality of block groups, where the first index represents a mapping relationship between the index key values of the block groups and the index identifiers of the block groups;
[0042] Obtain the storage location of each block group on the node;
[0043] Based on the index identifiers and storage locations of the plurality of block groups, a second index is generated, where the second index represents a mapping relationship between the index identifiers of the block groups and the storage locations of the block groups.
[0044] In some embodiments, the access module is configured to:
[0045] Obtaining node information of the access node and configuration information of the target blockchain;
[0046] When it is determined based on the node information and the configuration information that the access node has passed verification, the access node is connected to the target blockchain.
[0047] In some embodiments, the node information includes the node name of the access node, the organization to which the access node belongs, the blockchain certificate of the access node, the network information of the access node, the channel joined by the access node, and the chain code installed by the access node. The network information is used by the access node to access other nodes, and the channel is used by the access node to communicate with other nodes. The configuration information includes the nodes allowed to access the target blockchain and the target network information, target channel, and target chain code that match the target blockchain.
[0048] The device also includes: a determination module, configured to determine that the access node has passed verification if, based on the node name, the organization, and the blockchain certificate, it is determined that the access node is a node allowed to access the target blockchain, and the network information, the channel, and the chain code respectively match the target network information, the target channel, and the target chain code.
[0049] On the other hand, a computer device is provided, comprising one or more processors and one or more memories, wherein at least one program code is stored in the one or more memories, and the at least one program code is loaded and executed by the one or more processors to implement the blockchain node access method described in any of the above implementations.
[0050] On the other hand, a computer-readable storage medium is provided, in which at least one program code is stored. The at least one program code is loaded and executed by a processor to implement the blockchain node access method described in any of the above implementations.
[0051] On the other hand, a computer program product is provided, including a computer program, which, when executed by a processor, implements the blockchain node access method described in any of the above implementations.
[0052] An embodiment of the present application provides a method for accessing a blockchain node. The method obtains data of the blockchain from an existing node of the target blockchain when accessing the node, and generates a data index based on the data and the storage location of the data on the node. After migrating the data index to the target server, the access node can query the data from the node storing the data based on the data index, avoiding downloading the data to the access node, thereby reducing the storage resources that need to be configured for the access node and avoiding waste of storage resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0054] Figure 1 This is a schematic diagram of an implementation environment provided by an embodiment of the present application;
[0055] Figure 2 This is a flowchart of a blockchain node access method provided by an embodiment of the present application;
[0056] Figure 3 This is a flowchart of another blockchain node access method provided by an embodiment of the present application;
[0057] Figure 4 This is a schematic diagram of a binary tree in a binary tree index provided in an embodiment of the present application;
[0058] Figure 5 This is a schematic diagram of a node access interface provided by an embodiment of the present application;
[0059] Figure 6 This is a flowchart of another blockchain node access method provided by an embodiment of the present application;
[0060] Figure 7This is a block diagram of an access device for a blockchain node provided in an embodiment of the present application;
[0061] Figure 8 This is a block diagram of a terminal provided in an embodiment of the present application;
[0062] Figure 9 This is a block diagram of a server provided in an embodiment of the present application. DETAILED DESCRIPTION
[0063] In order to make the objectives, technical solutions and advantages of this application clearer, the implementation methods of this application will be further described in detail below with reference to the accompanying drawings.
[0064] The terms "first," "second," "third," and "fourth," etc. in the specification and claims of this application and the accompanying drawings are used to distinguish different objects, not to describe a specific order. In addition, the terms "including" and "having," and any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus comprising a series of steps or elements is not limited to the listed steps or elements, but may optionally include steps or elements not listed, or may optionally include other steps or elements inherent to the process, method, product, or apparatus.
[0065] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.), and signals involved in this application are all authorized by the user or fully authorized by all parties, and the collection, use, and processing of relevant data must comply with the relevant laws, regulations, and standards of the relevant countries and regions. For example, the data involved in this application were obtained with full authorization.
[0066] The blockchain node access method provided in the embodiments of the present application can be executed by a computer device. In some embodiments, the computer device is at least one of the terminal 10 or the server 20. Figure 1 , Figure 1Schematic diagram of the implementation environment of the access method of the blockchain node provided in the embodiment of the present application, the implementation environment includes at least one of the terminal 10 and the server 20, and the terminal 10 and the server 20 can be directly or indirectly connected through wired or wireless communication, and the present application does not limit this. The access method of the blockchain node provided in the embodiment of the present application can be executed by the terminal 10 alone, or by the server 20 alone, or by the terminal 10 and the server 20 through data interaction, and the embodiment of the present application does not limit this. In some embodiments, the server 20 undertakes the main computing work and the terminal 10 undertakes the secondary computing work; or, the server 20 undertakes the secondary computing work and the terminal 10 undertakes the main computing work; or, the server 20 and the terminal 10 adopt a distributed computing architecture for collaborative computing.
[0067] The terminal 10 is at least one of a mobile phone, a tablet computer, a PC (Personal Computer), etc. The server 20 can be at least one of a single server 20, a server 20 cluster consisting of multiple servers 20, a cloud server 20, a cloud computing platform, and a virtualization center.
[0068] Figure 2 This is a flowchart of a blockchain node access method provided in an embodiment of the present application. The method can be implemented by at least one of a terminal and a server. In the embodiment of the present application, the terminal and the server are collectively referred to as computer devices. Therefore, the method is executed with the computer device as the execution subject. The method includes:
[0069] 201. The computer device obtains data of the target blockchain from the node of the target blockchain in response to the access request of the access node.
[0070] In an embodiment of the present application, the access request is used to request that the access node be connected to the target blockchain. The data of the target blockchain is composed of blocks on the target blockchain and is stored on the node of the target blockchain.
[0071] 202. The computer device generates a data index based on the data and the storage location of the data on the node. The data index represents a mapping relationship between the data and the storage location of the data.
[0072] In the embodiment of the present application, a data index is generated, and since the data index represents a mapping relationship between data and a storage location of the data, it is convenient to query data from a node based on the data index.
[0073] 203. The computer device connects the access node to the target blockchain.
[0074] In an embodiment of the present application, after the access node accesses the target blockchain, it can store the data generated by the target blockchain after it accesses the target blockchain.
[0075] 204. The computer device migrates the data index to the target server, so that the access node queries data from the node based on the data index in the target server.
[0076] In an embodiment of the present application, the target server is a storage unit of the access node. By migrating the data index to the target server, the data index is migrated to the access node, thereby facilitating the access node to perform data query based on the data index.
[0077] In an embodiment of the present application, after an access node accesses a target blockchain, it needs to be able to query all data generated by the target blockchain. Since the access node can store data generated by the target blockchain after it accesses the target blockchain, the access node can query data generated by the target blockchain after it accesses the blockchain. Furthermore, since the access node can query data generated by the target blockchain before it accesses the blockchain based on a data index, the access node can query all data on the target blockchain and avoids storing data before it accesses the blockchain, thereby reducing the storage resources required for the access node.
[0078] An embodiment of the present application provides a method for accessing a blockchain node. The method obtains data of the blockchain from an existing node of the target blockchain when accessing the node, and generates a data index based on the data and the storage location of the data on the node. After migrating the data index to the target server, the access node can query the data from the node storing the data based on the data index, avoiding downloading the data to the access node, thereby reducing the storage resources that need to be configured for the access node and avoiding waste of storage resources.
[0079] Figure 3 This is a flowchart of a blockchain node access method provided by an embodiment of the present application. The method is executed by a server as the execution subject, and the method includes:
[0080] 301. In response to the access request of the access node, the server determines a target node marked with a target identifier from the target blockchain, where the target identifier indicates that the marked node stores data generated by the target blockchain from the creation time to the current time.
[0081] In one implementation, a terminal is provided at the access node. This terminal acts as the access node's manager and can control the access node's execution of tasks. Accordingly, the terminal can control the access node to trigger an access request, thereby sending the access request to the server. In another implementation, the target blockchain is associated with a terminal that can control access to nodes in the target blockchain. Optionally, the terminal can control any access node to trigger an access request, thereby sending the access request to the server.
[0082] 302. The server obtains the backup data of the data stored by the target node to obtain the data of the target blockchain.
[0083] Optionally, the target node stores data through a mount, and the server obtains a backup file of the data stored in the mount to obtain the backup data, that is, the data of the target blockchain.
[0084] In this embodiment of the present application, steps 301-302 are used to obtain data from the target blockchain node. Since the target node stores data generated by the target blockchain from its creation to the current time, the accuracy and comprehensiveness of the obtained data are guaranteed.
[0085] 303. The server generates a data index based on the data and the storage location of the data on the node. The data index represents a mapping relationship between the data and the storage location of the data.
[0086] In an embodiment of the present application, the data consists of blocks on the target blockchain, and there is at least one block on the target blockchain, that is, the data index further represents the mapping relationship between each block and the storage location of the block on the node.
[0087] In some embodiments, to improve indexing efficiency, the data index includes a first index and a second index. The process of the server generating the data index based on the data and the storage location of the data on the node includes the following steps:
[0088] The server divides the blocks on the target blockchain into multiple block groups, each of which includes a preset number of adjacent blocks. The server establishes an index key value and an index identifier for each block group. The server generates a first index based on the index key values and index identifiers of the multiple block groups. The server obtains the storage location of each block group on the node. The server generates a second index based on the index identifiers and storage locations of the multiple block groups. The first index represents a mapping relationship between the index key value of the block group and the index identifier of the block group, and the second index represents a mapping relationship between the index identifier of the block group and the storage location of the block group.
[0089] In this embodiment, since the block group includes a preset number of adjacent blocks, the storage location of the block group optionally includes a preset number of adjacent sub-storage locations. The preset number of sub-storage locations corresponds one-to-one with the preset number of blocks. Based on the sorting position of any block in the block group, the sub-storage location of the block can be obtained from the storage location. For example, if a block is the second block in the block group, the second sub-storage location in the storage location is the sub-storage location corresponding to the block.
[0090] In some embodiments, the first index is a binary tree index; see Figure 4 , Figure 4 A schematic diagram of a binary tree in a binary tree index provided in an embodiment of the present application. The nodes in the binary tree include a root node, a left node, and a right node. Each node includes an index key value (key) and an index identifier (value) of a block group. The index key value of the left node is smaller than the index key value of the root node, and the index key value of the right node is larger than the index key value of the root node. Optionally, the server generates the following based on the index key value and index identifier of each block group: Figure 4 In the user table shown on the left, a block group corresponds to a row of fields in the user table, the index key value corresponds to the id field, and the index identifier corresponds to the name field, thereby generating a binary tree based on the user table.
[0091] It should be noted that when querying data based on a binary tree index, the query speed is negatively correlated with the height of the binary tree. That is, the taller the binary tree, the more nodes it has, the slower the query speed. In the embodiment of the present application, because the index key value of the left node of the binary tree is greater than the index key value of the root node, and the index key value of the right node is greater than the index key value of the root node, querying data based on this special sorting principle of the index key values in the binary tree can reduce the amount of data that needs to be traversed during the query, thereby improving the efficiency of data query.
[0092] In an embodiment of the present application, the index identifier is used to map to a storage location; accordingly, when the access node queries a block based on the first index and the second index, it first obtains the index key value of the block group where the block is located, and then determines an index identifier based on the index key value and the first index, and then determines a storage location in the target node based on the index identifier and the second index, and then finds the sub-storage location of the block from the storage location based on the sorting position of the block in the block group, and thus the block can be found.
[0093] The preset number can be set and changed as needed and is not specifically limited here; for example, the preset number is 10. In the embodiment of the present application, by dividing the blocks on the target blockchain to obtain multiple block groups, a data index is generated based on the index key values, index identifiers, and storage locations of the multiple block groups, thereby reducing the amount of data in the data index and avoiding the waste of resources caused by establishing an index for each block. Moreover, since the amount of data in the data index is small, the efficiency of querying data based on the data index can be improved.
[0094] In some embodiments, after generating the data index, the server deletes the acquired data of the target blockchain to avoid the data occupying the storage space of the server.
[0095] 304. The server connects the access node to the target blockchain.
[0096] In some embodiments, when connecting an access node to a target blockchain, the server needs to verify the access node to ensure the security of the target blockchain. Accordingly, the process of connecting the access node to the target blockchain by the server includes the following steps: the server obtains node information of the access node and configuration information of the target blockchain; if the server determines that the access node has passed verification based on the node information and configuration information, it connects the access node to the target blockchain.
[0097] The node information includes the node name of the access node, the organization to which the access node belongs, the blockchain certificate of the access node, the network information of the access node, the channel to which the access node joins, and the chain code installed by the access node. The network information is used by the access node to access other nodes, and the channel is used by the access node to communicate with other nodes. The configuration information includes the nodes allowed to access the target blockchain and the target network information, target channel, and target chain code that match the target blockchain. Accordingly, the process of the server determining whether the access node has passed the verification includes the following implementation methods:
[0098] If the access node is determined to be a node allowed to access the target blockchain based on the node name, organization, and blockchain certificate, and the network information, channel, and chain code match the target network information, target channel, and target chain code respectively, the server determines that the access node verification has passed.
[0099] The "organization" refers to the company, department, or other organization to which the node belongs. The blockchain certificate confirms the organization to which the node belongs. Network information includes the IP address and port number of the access node, which allows the access node to access other nodes. Chaincode, also known as a smart contract, is a piece of code installed on a node and running on the blockchain to implement specific business logic.
[0100] Among them, if the node name, organization and blockchain certificate of the access node match the node name, organization and blockchain certificate of the target blockchain allowed access node respectively, the server determines that the access node is a node allowed access by the target blockchain.
[0101] In some embodiments, if, based on the node name, organization, and blockchain certificate, it is determined that the access node is not a node allowed to access the target blockchain, the server determines that the access node verification has failed; or, if the network information, channel, and chain code do not match the target network information, target channel, and target chain code, respectively, the server determines that the access node verification has failed; or, if, based on the node name, organization, and blockchain certificate, it is determined that the access node is not a node allowed to access the target blockchain, and the network information, channel, and chain code do not match the target network information, target channel, and target chain code, respectively, the server determines that the access node verification has failed.
[0102] In the embodiments of the present application, the access node is only connected to the target blockchain if it passes verification based on its node information and the configuration information of the target blockchain, thereby ensuring the security of the target blockchain. Furthermore, the access node is not only verified as a permitted node based on the node name, organization, and blockchain certificate, but also verified based on network information, channels, and chain codes to determine whether it matches the target blockchain. This ensures the rationality and comprehensiveness of the verification, thereby effectively ensuring the accuracy of the target blockchain access node and the security of the access node.
[0103] 305. The server migrates the data index to the target server, so that the access node queries data from the node based on the data index in the target server.
[0104] In the embodiment of the present application, the target server serves as a storage unit of the access node. The access node needs to obtain a data index from the target server to query data. Therefore, communication between the target server and the access node must be facilitated. Therefore, the server determines the target server in the following ways:
[0105] (1) The server queries multiple servers that are allowed to access the access node, determines the access paths between the multiple servers and the access node, and selects the server with the shortest access path as the target server.
[0106] In the embodiment of the present application, by using the server with the shortest access path as the target server, the access efficiency between the access node and the server can be improved, thereby improving the efficiency of the access node in querying data.
[0107] (2) The server will access the server within the preset distance as the target server.
[0108] In the embodiments of the present application, by selecting a server within a preset access path distance as the target server, the access path distance between the target server and the access node is limited to a certain range, thereby improving the access efficiency between the access node and the target server. The preset distance can be set and changed as needed and is not specifically limited here.
[0109] In some embodiments, the target server is used only to store data indexes, so the target server's storage space can be limited to a preset storage space to avoid wasting storage resources. In other embodiments, the target server is used not only to store data indexes but also to store data generated by the target blockchain after the access node accesses the target blockchain. This places higher storage requirements on the target server and requires the target server to meet a minimum storage space, which is determined based on historical experience, such as 400GB.
[0110] In some embodiments, before connecting the access node to the target blockchain, the server performs a link test on the server, the node of the target blockchain, the target server, and the access node to ensure that the server, the node of the target blockchain, the target server, and the access node are all properly connected to the network.
[0111] In some embodiments, if an access node fails to connect or data index migration fails, the server supports data rollback of the target blockchain, restoring the target blockchain to its state before accessing the access node. In some embodiments, data index migration also supports automatic recovery, that is, the data index migrated to the target server can be restored to the server. This allows the data index to be directly migrated to the target server when the node that failed to connect is reconnected, thereby improving access efficiency.
[0112] See also Figure 5 , Figure 5A schematic diagram of a node access interface provided in an embodiment of the present application. The server uses this node access interface to obtain data from the target blockchain and node information for the access node. The terminal displays the node access interface, which includes a target server selection box, a node information selection box, a data selection box, a migration confirmation box, and a selection box for information about the connected node. The target server selection box prompts you to select the target server. The node information selection box includes selection boxes for the node name, organization, blockchain certificate, network information, channel, and chain code. The node name selection box prompts you to enter the node name, and the organization selection box prompts you to enter the organization's MSP (Managed Service Provider). The blockchain certificate selection box prompts you to upload the node certificate and has a corresponding "Select File" button. The network information selection box prompts you to upload the node configuration file and has a corresponding "Select File" button. The node configuration file stores network information such as the IP address and port number. The "Select File" button is surrounded by a message stating, "The node configuration file is in YAML (a configuration file format). It is recommended that you download the node configuration template file, modify it, and then upload it." The channel acquisition box features an Add button, prompting the user to add a new channel record. This record includes the channel's serial number, channel name, channel genesis block, and operation information, including instructions for deleting the channel record. The chaincode acquisition box also features an Add button, prompting the user to add a new chaincode record. This record includes the chaincode's serial number, chaincode name, chaincode language, uploaded source code, and operation information, including instructions for deleting the chaincode record. The data acquisition box prompts the user to upload node backup data, with a Select File button. The migration confirmation box prompts the user to execute the migration. The connected node information box includes the serial number of each connected node, as well as the connection time, node name, corresponding target server, and the node's operating status.
[0113] See also Figure 6 , Figure 6A flowchart of a blockchain node access method provided in an embodiment of the present application. After the process begins, the user triggers an access request to the access node through a terminal on the access node side or a terminal on the server side, then enters the target server information, node name, and node organization on the node access interface in sequence, then uploads the node certificate and node configuration file. If the upload fails, re-upload; if the upload is successful, enter the channel the node joins and the chain code installed by the node in sequence; then upload the mount backup file. If the upload fails, re-upload; if the upload is successful, execute migration; if the administrator of the target blockchain fails to review the input information, the migration fails, and the user needs to re-enter the information on the node access interface and re-execute the migration. If the administrator reviews the input information, the migration succeeds, and the process ends.
[0114] In the embodiments of the present application, the target blockchain can be a public chain or a consortium chain, and the target node and access node are all full nodes. In the related art, the full node in the blockchain needs to synchronize all the data in the blockchain. As time goes by, after the blockchain has been running for a long time, as the scale of users and transaction volume on the chain increases, the amount of data in the blockchain will increase exponentially; accordingly, there is a higher demand for the storage resources of the full node, resulting in the need to configure more storage resources when accessing the node, and when accessing the node, it takes a long time to synchronize the data to the access node, thereby reducing the efficiency of the blockchain access node. In the embodiments of the present application, by establishing a data index, the newly connected node does not need to synchronize all the data of the blockchain, reducing the demand for storage resources and reducing the access time. In another implementation, if the storage resources of the access node are sufficient, the access node can also synchronize the blockchain data to the access node based on the data index to further improve the efficiency of querying data.
[0115] In the embodiments of the present application, data migration between different physical entities is achieved by migrating the data index to the target server. Furthermore, the blockchain node access method in the embodiments of the present application supports hot migration, meaning that obtaining data from the target blockchain and migrating the data index do not affect the normal operation of the target blockchain, allowing the node access process to be completed during the normal operation of the target blockchain.
[0116] An embodiment of the present application provides a method for accessing a blockchain node. The method obtains data of the blockchain from an existing node of the target blockchain when accessing the node, and generates a data index based on the data and the storage location of the data on the node. After migrating the data index to the target server, the access node can query the data from the node storing the data based on the data index, avoiding downloading the data to the access node, thereby reducing the storage resources that need to be configured for the access node and avoiding waste of storage resources.
[0117] See also Figure 7 , Figure 7 An access device for a blockchain node provided in an embodiment of the present application includes:
[0118] An acquisition module 701 is configured to acquire data of a target blockchain from a node of the target blockchain in response to an access request from an access node;
[0119] A generating module 702 is configured to generate a data index based on the data and the storage location of the data on the node, where the data index represents a mapping relationship between the data and the storage location of the data;
[0120] Access module 703, used to connect the access node to the target blockchain;
[0121] The migration module 704 is configured to migrate the data index to the target server so that the access node can query data from the node based on the data index in the target server.
[0122] In some embodiments, the acquisition module 701 is configured to:
[0123] In response to the access request from the access node, determine, from the target blockchain, a target node marked with a target identifier, where the target identifier indicates that the marked node stores data generated by the target blockchain from the creation time to the current time;
[0124] Obtain the backup data of the data stored in the target node to obtain the data.
[0125] In some embodiments, the apparatus further comprises:
[0126] querying multiple servers that are allowed to access the access node, determining access paths between the multiple servers and the access node, and selecting the server with the shortest access path as the target server; or,
[0127] The server whose access path distance is within the preset distance is used as the target server.
[0128] In some embodiments, the data consists of blocks on a target blockchain, the data index includes a first index and a second index, and the generation module 702 is configured to:
[0129] Divide the blocks on the target blockchain into multiple block groups, each block group including a preset number of adjacent blocks;
[0130] Create an index key value and index identifier for each block group;
[0131] Generate a first index based on the index key values and index identifiers of the plurality of block groups, where the first index represents a mapping relationship between the index key values of the block groups and the index identifiers of the block groups;
[0132] Get the storage location of each block group on the node;
[0133] Based on the index identifiers and storage locations of the plurality of block groups, a second index is generated, where the second index represents a mapping relationship between the index identifiers of the block groups and the storage locations of the block groups.
[0134] In some embodiments, the access module 703 is configured to:
[0135] Obtain node information of the access node and configuration information of the target blockchain;
[0136] When the access node passes verification based on the node information and configuration information, the access node is connected to the target blockchain.
[0137] In some embodiments, the node information includes the node name of the access node, the organization to which the access node belongs, the blockchain certificate of the access node, the network information of the access node, the channel joined by the access node and the chain code installed by the access node. The network information is used for the access node to access other nodes, the channel is used for the access node to communicate with other nodes, and the configuration information includes the nodes allowed to access by the target blockchain and the target network information, target channel and target chain code that match the target blockchain; the device also includes: a determination module for determining that the access node is a node allowed to access by the target blockchain based on the node name, organization and blockchain certificate, and the network information, channel and chain code match the target network information, target channel and target chain code respectively, then determining that the access node verification has passed.
[0138] An embodiment of the present application provides an access device for a blockchain node, which obtains data of the blockchain from an existing node of the target blockchain when accessing the node, and generates a data index based on the data and the storage location of the data on the node; after migrating the data index to the target server, the access node can query the data from the node storing the data based on the data index, avoiding downloading the data to the access node, thereby reducing the storage resources that need to be configured for the access node and avoiding waste of storage resources.
[0139] In some embodiments, the computer device is configured as a terminal; Figure 8 The following is a block diagram of the structure of a terminal 800 provided in an embodiment of the present application. The terminal 800 can be a portable mobile terminal, such as a smartphone, a tablet computer, an MP3 player (Moving Picture Experts Group Audio Layer III), an MP4 player (Moving Picture Experts Group Audio Layer IV), a laptop computer, or a desktop computer. The terminal 800 may also be referred to as a user equipment, a portable terminal, a laptop terminal, a desktop terminal, or other similar names.
[0140] Typically, the terminal 800 includes a processor 801 and a memory 802 .
[0141] The processor 801 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 801 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), or PLA (Programmable Logic Array). The processor 801 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 801 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 801 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.
[0142] Memory 802 may include one or more computer-readable storage media, which may be non-transitory. Memory 802 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices and flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in memory 802 is used to store at least one program code, which is executed by processor 801 to implement the blockchain node access method provided in the method embodiment of the present application.
[0143] In some embodiments, terminal 800 may optionally include a peripheral device interface 803 and at least one peripheral device. The processor 801, memory 802, and peripheral device interface 803 may be connected via a bus or signal lines. Each peripheral device may be connected to peripheral device interface 803 via a bus, signal lines, or circuit boards. Specifically, the peripheral device may include at least one of a radio frequency circuit 804, a display screen 805, a camera assembly 806, an audio circuit 807, a positioning assembly 808, and a power supply 809.
[0144] The peripheral device interface 803 can be used to connect at least one I / O (Input / Output)-related peripheral device to the processor 801 and the memory 802. In some embodiments, the processor 801, the memory 802, and the peripheral device interface 803 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 801, the memory 802, and the peripheral device interface 803 can be implemented on separate chips or circuit boards, which is not limited in this embodiment.
[0145] The radio frequency circuit 804 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The radio frequency circuit 804 communicates with communication networks and other communication devices via electromagnetic signals. The radio frequency circuit 804 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals into electrical signals. Optionally, the radio frequency circuit 804 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, etc. The radio frequency circuit 804 can communicate with other terminals via at least one wireless communication protocol. Such wireless communication protocols include, but are not limited to, the World Wide Web, a metropolitan area network, an intranet, various generations of mobile communication networks (2G, 3G, 4G, and 5G), a wireless local area network, and / or a WiFi (Wireless Fidelity) network. In some embodiments, the radio frequency circuit 804 may also include circuits related to NFC (Near Field Communication), which is not limited in this application.
[0146] Display screen 805 is used to display a user interface (UI). This UI may include graphics, text, charts, videos, or any combination thereof. When display screen 805 is a touchscreen display, it is also capable of collecting touch signals on or above the surface of display screen 805. These touch signals can be input as control signals to processor 801 for processing. Display screen 805 can also be used to provide virtual buttons and / or a virtual keyboard, also known as soft buttons and / or a soft keyboard. In some embodiments, there can be a single display screen 805, located on the front panel of terminal 800. In other embodiments, there can be at least two display screens 805, located on different surfaces of terminal 800 or in a foldable design. In still other embodiments, display screen 805 can be a flexible display, located on a curved or foldable surface of terminal 800. Display screen 805 can also be configured as a non-rectangular, irregular shape, also known as a special-shaped screen. Display screen 805 can be made of materials such as LCD (Liquid Crystal Display) and OLED (Organic Light-Emitting Diode).
[0147] The camera assembly 806 is used to capture images or videos. Optionally, the camera assembly 806 includes a front camera and a rear camera. Typically, the front camera is arranged on the front panel of the terminal, and the rear camera is arranged on the back of the terminal. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth of field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, the fusion of the main camera and the wide-angle camera to realize panoramic shooting and VR (Virtual Reality) shooting function or other fusion shooting functions. In some embodiments, the camera assembly 806 may also include a flash. The flash can be a monochrome temperature flash or a dual-color temperature flash. A dual-color temperature flash refers to a combination of a warm light flash and a cold light flash, which can be used for light compensation at different color temperatures.
[0148] The audio circuit 807 may include a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, and convert the sound waves into electrical signals that are input into the processor 801 for processing, or input into the radio frequency circuit 804 to achieve voice communication. For the purpose of stereo sound collection or noise reduction, there may be multiple microphones, each located in different parts of the terminal 800. The microphone may also be an array microphone or an omnidirectional collection microphone. The speaker is used to convert electrical signals from the processor 801 or the radio frequency circuit 804 into sound waves. The speaker may be a traditional thin film speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can not only convert electrical signals into sound waves audible to humans, but also convert electrical signals into sound waves inaudible to humans for purposes such as ranging. In some embodiments, the audio circuit 807 may also include a headphone jack.
[0149] Positioning component 808 is used to locate the current geographic location of terminal 800 to implement navigation or LBS (Location Based Service). Positioning component 808 can be a positioning component based on the US GPS (Global Positioning System), China's Beidou system, or the EU's Galileo system.
[0150] Power supply 809 is used to power various components in terminal 800. Power supply 809 can be AC power, DC power, a disposable battery, or a rechargeable battery. When power supply 809 includes a rechargeable battery, the rechargeable battery can be a wired rechargeable battery or a wireless rechargeable battery. A wired rechargeable battery is a battery that is charged via a wired line, while a wireless rechargeable battery is a battery that is charged via a wireless coil. The rechargeable battery can also be used to support fast charging technology.
[0151] In some embodiments, the terminal 800 further includes one or more sensors 810 , including but not limited to: an acceleration sensor 811 , a gyroscope sensor 812 , a pressure sensor 813 , a fingerprint sensor 814 , an optical sensor 815 , and a proximity sensor 816 .
[0152] The accelerometer 811 can detect the magnitude of acceleration along the three coordinate axes of the coordinate system established by the terminal 800. For example, the accelerometer 811 can be used to detect the components of gravity acceleration along the three coordinate axes. The processor 801 can control the display screen 805 to display the user interface in a landscape or portrait view based on the gravity acceleration signal collected by the accelerometer 811. The accelerometer 811 can also be used to collect game or user motion data.
[0153] The gyroscope sensor 812 can detect the orientation and rotation angle of the terminal 800. It can work in conjunction with the accelerometer 811 to collect the user's 3D movements of the terminal 800. Based on the data collected by the gyroscope sensor 812, the processor 801 can implement the following functions: motion sensing (for example, changing the UI based on the user's tilt operation), image stabilization during shooting, game control, and inertial navigation.
[0154] The pressure sensor 813 can be provided on the side frame of the terminal 800 and / or below the display screen 805. When the pressure sensor 813 is provided on the side frame of the terminal 800, it can detect the user's gripping signal of the terminal 800. The processor 801 performs left-hand or right-hand identification or shortcut operations based on the gripping signal collected by the pressure sensor 813. When the pressure sensor 813 is provided below the display screen 805, the processor 801 controls the operable controls on the UI interface based on the user's pressure operation on the display screen 805. Operable controls include at least one of a button control, a scroll bar control, a chart control, and a menu control.
[0155] The fingerprint sensor 814 is used to collect the user's fingerprint. The processor 801 identifies the user's identity based on the fingerprint collected by the fingerprint sensor 814, or the fingerprint sensor 814 identifies the user's identity based on the collected fingerprint. When the user's identity is recognized as a trusted identity, the processor 801 authorizes the user to perform relevant sensitive operations, such as unlocking the screen, viewing encrypted information, downloading software, making payments, and changing settings. The fingerprint sensor 814 can be set on the front, back, or side of the terminal 800. When a physical button or manufacturer logo is provided on the terminal 800, the fingerprint sensor 814 can be integrated with the physical button or manufacturer logo.
[0156] The optical sensor 815 is used to detect ambient light intensity. In one embodiment, the processor 801 can control the display brightness of the display screen 805 based on the ambient light intensity detected by the optical sensor 815. Specifically, when the ambient light intensity is high, the display brightness of the display screen 805 is increased; when the ambient light intensity is low, the display brightness of the display screen 805 is decreased. In another embodiment, the processor 801 can also dynamically adjust the shooting parameters of the camera assembly 806 based on the ambient light intensity detected by the optical sensor 815.
[0157] Proximity sensor 816, also known as a distance sensor, is typically located on the front panel of terminal 800. Proximity sensor 816 is used to detect the distance between the user and the front of terminal 800. In one embodiment, when proximity sensor 816 detects that the distance between the user and the front of terminal 800 is gradually decreasing, processor 801 controls display screen 805 to switch from the screen-on state to the screen-off state. When proximity sensor 816 detects that the distance between the user and the front of terminal 800 is gradually increasing, processor 801 controls display screen 805 to switch from the screen-off state to the screen-on state.
[0158] Those skilled in the art will understand that Figure 8 The structure shown in the figure does not constitute a limitation on the terminal 800, and the terminal 800 may include more or fewer components than shown in the figure, or combine certain components, or adopt a different component arrangement.
[0159] Figure 9 9 is a block diagram of a server provided by an embodiment of the present disclosure. The server 900 may vary significantly due to different configurations or performances, and may include one or more processors (Central Processing Units, CPU) 901 and one or more memories 902, wherein the memories 902 are used to store executable program code, and the processors 901 are configured to execute the above executable program code to implement the blockchain node access methods provided by the above-mentioned various method embodiments. Of course, the server may also have components such as a wired or wireless network interface, a keyboard, and an input / output interface for input and output. The server may also include other components for implementing device functions, which will not be described in detail here.
[0160] In an exemplary embodiment, a storage medium including program code is further provided, such as a memory 902 including program code. The program code can be executed by a processor 901 of a server 900 to complete the above-described blockchain node access method. Alternatively, the storage medium can be a non-transitory computer-readable storage medium, such as a ROM (Read-Only Memory), a RAM (Random Access Memory), a CD-ROM (Compact Disc Read-Only Memory), a magnetic tape, a floppy disk, an optical data storage device, and the like.
[0161] An embodiment of the present application also provides a computer-readable storage medium, in which at least one program code is stored. The at least one program code is loaded and executed by a processor to implement the blockchain node access method of any of the above implementation methods.
[0162] An embodiment of the present application also provides a computer program product, including a computer program, which, when executed by a processor, implements the blockchain node access method of any of the above-mentioned implementation methods.
[0163] In some embodiments, the computer program product involved in the embodiments of the present application can be deployed and executed on a computer device, or on multiple computer devices located at one location, or on multiple computer devices distributed at multiple locations and interconnected through a communication network. Multiple computer devices distributed at multiple locations and interconnected through a communication network can constitute a blockchain system.
[0164] The above are only optional embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application.
Claims
1. A method for accessing a blockchain node, characterized in that: The method comprises: In response to the access request from the access node, obtain data of the target blockchain from a node of the target blockchain, the data consisting of blocks on the target blockchain; Dividing the blocks on the target blockchain into a plurality of block groups, each block group including a preset number of adjacent blocks; Create an index key value and index identifier for each block group; Generate a first index based on the index key values and index identifiers of the plurality of block groups, where the first index represents a mapping relationship between the index key values of the block groups and the index identifiers of the block groups; Obtain the storage location of each block group on the node; generating a second index based on the index identifiers and storage locations of the plurality of block groups, wherein the second index represents a mapping relationship between the index identifiers of the block groups and the storage locations of the block groups; Connecting the access node to the target blockchain; The data index is migrated to a target server so that the access node queries the data from the node based on the data index in the target server, where the data index includes the first index and the second index.
2. The method according to claim 1, characterized in that The step of obtaining data of the target blockchain from a node of the target blockchain includes: In response to the access request of the access node, determining, from the target blockchain, a target node marked with a target identifier, wherein the target identifier indicates that the marked node stores data generated by the target blockchain from the creation time to the current time; Acquire backup data of the data stored in the target node to obtain the data.
3. The method according to claim 1, characterized in that The method further comprises: querying multiple servers that are allowed to access the access node, determining access paths between the multiple servers and the access node, and using the server with the shortest access path as the target server; or, The server whose access path distance is within a preset distance is used as the target server.
4. The method according to claim 1, wherein Connecting the access node to the target blockchain includes: Obtaining node information of the access node and configuration information of the target blockchain; When it is determined based on the node information and the configuration information that the access node has passed verification, the access node is connected to the target blockchain.
5. The method according to claim 4, characterized in that The node information includes the node name of the access node, the organization to which the access node belongs, the blockchain certificate of the access node, the network information of the access node, the channel to which the access node joins, and the chain code installed by the access node. The network information is used by the access node to access other nodes, and the channel is used by the access node to communicate with other nodes. The configuration information includes the nodes allowed to access the target blockchain and the target network information, target channel, and target chain code that match the target blockchain. The method further comprises: If, based on the node name, the organization, and the blockchain certificate, it is determined that the access node is a node allowed to access the target blockchain, and the network information, the channel, and the chain code match the target network information, the target channel, and the target chain code, respectively, then it is determined that the access node verification has passed.
6. A blockchain node access device, characterized in that: The device comprises: an acquisition module, configured to acquire data of a target blockchain from a node of the target blockchain in response to an access request from the access node, the data being composed of blocks on the target blockchain; A generation module is configured to divide the blocks on the target blockchain to obtain a plurality of block groups, each block group including a preset number of adjacent blocks; establish an index key value and an index identifier for each block group; generate a first index based on the index key values and index identifiers of each of the plurality of block groups, the first index representing a mapping relationship between the index key value of the block group and the index identifier of the block group; obtain a storage location of each block group on the node; and generate a second index based on the index identifiers and storage locations of each of the plurality of block groups, the second index representing a mapping relationship between the index identifier of the block group and the storage location of the block group; An access module, configured to connect the access node to the target blockchain; A migration module is used to migrate the data index to the target server so that the access node queries the data from the node based on the data index in the target server, where the data index includes the first index and the second index.
7. A computer device, characterized in that: The computer device includes one or more processors and one or more memories, and at least one program code is stored in the one or more memories. The at least one program code is loaded and executed by the one or more processors to implement the blockchain node access method according to any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that The storage medium stores at least one program code, and the at least one program code is loaded and executed by the processor to implement the blockchain node access method according to any one of claims 1 to 5.
9. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the method for accessing a blockchain node according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Data storage method and data query method and device
CN109669943A
Data processing method and device, equipment and storage medium
CN114020829A