Method, apparatus, and electronic device for processing subscription data
By recording part of the subscription information in the subscription block and cached it to the key-value pair database, the problems of high storage pressure and long response time caused by storing full subscription information in a single block is solved, and efficient and secure subscription information management is achieved.
Patent Information
- Application Number
- CN202411706833.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-26
- Publication Date
- 2025-07-04
- Estimated Expiration
- 2044-11-26
AI Technical Summary
In the prior art, storing full subscription information through a single block leads to high storage pressure and long response time, which becomes a problem of system bottleneck.
Record some subscription information in the subscription block and cache it in the target database stored in the form of key-value pairs, avoiding the pressure of full storage, and achieving efficient management by extracting the subscriber's certificate hash value and subscription status judgment permissions.
It reduces the storage space occupancy rate of a single block, improves the storage and access efficiency of subscription information, and ensures the legality and data security of subscription requests.
Smart Images

Figure CN119622032B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain, and in particular, to a method, device, and electronic device for processing subscribed data. Background Art
[0002] Currently, subscription management is usually based on a full list of subscribed data, and most of it is an off-chain behavior, lacking credibility.
[0003] In related technologies, to implement subscription management on the blockchain, a subscription block type definition is provided to record the full list of subscribed data. However, when the number of subscriber data entries reaches tens of thousands or even millions, the subscribed list data will be extremely large, and the size of the subscription block is usually limited. Although it can be avoided by compressing the data, since the compressed full subscribed information is stored on the subscription block, once the subscribed information needs to be extracted, the subscription block needs to be decompressed, which consumes both the CPU (Central Processing Unit) and memory, and the time and space costs are relatively high. Compression processing is also required during storage, which will also consume a large amount of CPU and time. When the subscribed data records increase, the response time will also become longer, and it is particularly likely to become a system bottleneck.
[0004] In response to the above problems, no effective solution has been proposed yet. Summary of the Invention
[0005] Embodiments of the present invention provide a method, device, and electronic device for processing subscribed data, so as to at least solve the technical problem that the effect of storing full subscribed information in a single block in related technologies is not good.
[0006] According to one aspect of the embodiments of the present invention, a method for processing subscribed data is provided, including: obtaining a subscription block storing subscribed information, where the subscription block includes: a block for recording partial subscribed information in the full subscribed information, and the subscribed information includes: a subscription rule for a first subscriber to subscribe to specified information; extracting the subscribed information from the subscription block to obtain an extraction result; and caching the extraction result in a target database, where the target database includes: a database storing data in the form of key-value pairs.
[0007] Further, extracting the subscription information from the subscription block to obtain an extraction result includes: extracting target information in the subscription information from the subscription block to obtain the extraction result, where the target information includes at least one of the following: the certificate of the first subscriber, the ledger identifier associated with the subscription block, the identifier of the subscription topic, the subscription status, the transaction identifier, and the block height of the subscription block, and the subscription status is used to indicate whether the first subscriber has the subscription permission to subscribe to the specified information.
[0008] Further, caching the extraction result in a target database includes: extracting the identifier of the first subscriber from the certificate of the first subscriber to obtain a first subscription identifier; calculating the hash value of the certificate of the first subscriber to obtain a first hash value; and caching the first subscription identifier, the first hash value, and the extraction result in the target database based on the subscription status.
[0009] Further, caching the first subscription identifier, the first hash value, and the extraction result in the target database based on the subscription status includes: when the subscription status indicates that the first subscriber has the subscription permission for the specified information, converting the first subscription identifier, the first hash value, and the extraction result into a key-value pair form to obtain a target key-value pair, and caching the target key-value pair in the target database, where the first hash value is recorded in the key of the target key-value pair and the first subscription identifier is recorded in the value of the target key-value pair; when the subscription status indicates that the first subscriber does not have the subscription permission for the specified information, prohibiting caching the first subscription identifier, the first hash value, and the extraction result in the target database.
[0010] Further, before obtaining the subscription block storing the subscription information, it includes: obtaining the subscription information and packaging the subscription information into a transaction in the blockchain to obtain a target transaction; sending the target transaction to an endorsing node for signing to obtain a signed target transaction; and sending the signed target transaction to a consensus node to generate the subscription block, where the consensus node is used to package the signed target transaction into a block.
[0011] Further, after sending the signed target transaction to the consensus node to generate the subscription block, it further includes: performing consensus on the subscription block by using the consensus node to obtain a consensus result; when the consensus result indicates that the consensus on the subscription block is successful, storing the subscription block in the disk of the consensus node and broadcasting the subscription block to the accounting nodes so that the accounting nodes store the subscription block in the disks of the accounting nodes.
[0012] Further, after caching the extraction result in the target database, the method further includes: receiving a subscription request, and extracting the certificate of the subscriber in the subscription request to obtain the certificate of the second subscriber; extracting the identifier of the second subscriber from the certificate of the second subscriber to obtain the second subscription identifier; calculating the hash value of the certificate of the second subscriber to obtain the second hash value; based on the second subscription identifier and the second hash value, using the target database to determine whether the second subscriber has the subscription right to the specified information to obtain a judgment result; based on the judgment result, determining whether to allow the second subscriber to subscribe to the specified information.
[0013] Further, after caching the extraction result in the target database, the method further includes: loading the key-value pairs to be verified in the target database, where the key-value pairs to be verified include: the key-value pairs associated with the subscription information waiting for validity verification; based on the subscription information in the target block, performing validity verification on the key-value pairs to be verified to obtain a verification result, where the target block includes: the block for recording the subscription information associated with the key-value pairs to be verified.
[0014] According to another aspect of the embodiments of the present invention, there is also provided a processing device for subscription data, including: an acquisition unit, configured to acquire a subscription block storing subscription information, where the subscription block includes: a block for recording partial subscription information in all subscription information, and the subscription information includes: the subscription rule for the first subscriber to subscribe to specified information; an extraction unit, configured to extract the subscription information from the subscription block to obtain an extraction result; a caching unit, configured to cache the extraction result in a target database, where the target database includes: a database storing data in the form of key-value pairs.
[0015] Further, the extraction unit includes: a first extraction subunit, configured to extract target information in the subscription information from the subscription block to obtain the extraction result, where the target information includes at least one of the following: the certificate of the first subscriber, the ledger identifier associated with the subscription block, the identifier of the subscription theme, the subscription status, the transaction identifier, the block height of the subscription block, and the subscription status is used to indicate whether the first subscriber has the subscription right to the specified information.
[0016] Further, the caching unit includes: an extraction subunit, configured to extract the identifier of the first subscriber from the certificate of the first subscriber to obtain a first subscription identifier; a calculation subunit, configured to calculate the hash value of the certificate of the first subscriber to obtain a first hash value; a caching subunit, configured to cache the first subscription identifier, the first hash value, and the extraction result in the target database based on the subscription status.
[0017] Further, the cache subunit includes: a conversion module, configured to convert the first subscription identifier, the first hash value, and the extraction result into a key-value pair form to obtain a target key-value pair when the subscription status indicates that the first subscriber has the subscription right to the specified information, and cache the target key-value pair into the target database, where the first hash value is recorded in the key of the target key-value pair and the first subscription identifier is recorded in the value of the target key-value pair; a processing module, configured to prohibit caching the first subscription identifier, the first hash value, and the extraction result into the target database when the subscription status indicates that the first subscriber does not have the subscription right to the specified information.
[0018] Further, the processing device for subscription data further includes: a first processing unit, configured to obtain the subscription information and package the subscription information into a transaction in the blockchain to obtain a target transaction before obtaining a subscription block storing the subscription information; a signature unit, configured to send the target transaction to an endorsement node for signature to obtain a signed target transaction; a sending unit, configured to send the signed target transaction to a consensus node to generate the subscription block, where the consensus node is configured to package the signed target transaction into a block.
[0019] Further, the processing device for subscription data further includes: a consensus unit, configured to perform consensus on the subscription block by using the consensus node to obtain a consensus result after sending the signed target transaction to the consensus node to generate the subscription block; a second processing unit, configured to store the subscription block in the disk of the consensus node and broadcast the subscription block to the accounting nodes when the consensus result indicates that the consensus on the subscription block is successful, so that the accounting nodes store the subscription block in the disks of the accounting nodes.
[0020] Further, the processing device for subscription data further includes: a receiving unit, configured to receive a subscription request and extract a certificate of a subscriber in the subscription request to obtain a certificate of a second subscriber after caching the extraction result into the target database; a third processing unit, configured to extract an identifier of the second subscriber from the certificate of the second subscriber to obtain a second subscription identifier; a calculation unit, configured to calculate a hash value of the certificate of the second subscriber to obtain a second hash value; a judgment unit, configured to judge whether the second subscriber has the subscription right to the specified information by using the target database based on the second subscription identifier and the second hash value to obtain a judgment result; a determination unit, configured to determine whether to allow the second subscriber to subscribe to the specified information based on the judgment result.
[0021] Further, the processing device for subscription data further includes: a loading unit, configured to load the key-value pairs to be verified in the target database after caching the extraction result in the target database, where the key-value pairs to be verified include: the key-value pairs associated with the subscription information waiting for validity verification; a verification unit, configured to perform validity verification on the key-value pairs to be verified based on the subscription information in the target block, and obtain a verification result, where the target block includes: a block for recording the subscription information associated with the key-value pairs to be verified.
[0022] According to another aspect of the embodiments of the present invention, there is also provided an electronic device, including: a processor; and a memory for storing executable instructions of the processor; wherein, the processor is configured to execute the processing method for subscription data of any one of the above via executing the executable instructions.
[0023] According to another aspect of the embodiments of the present invention, there is also provided a computer-readable storage medium storing a computer program, wherein when the computer program runs, it controls the device where the computer-readable storage medium is located to execute the processing method for subscription data of any one of the above.
[0024] In the present invention, a subscription block storing subscription information is obtained, where the subscription block includes: a block for recording partial subscription information in the full amount of subscription information, and the subscription information includes: a subscription rule for a first subscriber to subscribe to specified information; extracting subscription information in the subscription block to obtain an extraction result; caching the extraction result in a target database, where the target database includes: a database storing data in the form of key-value pairs. Furthermore, it solves the technical problem in the related art that storing the full amount of subscription information in a single block has a poor effect. In the present invention, partial subscription information in the full amount of subscription information is recorded in each subscription block, and the subscription information in the subscription block is cached in the target database, avoiding the situation in the related art that storing the full amount of subscription information in a single block results in a large storage pressure on the single block, thereby achieving the technical effect of reducing the storage space occupancy rate of a single block. Description of the Drawings
[0025] The drawings described herein are used to provide a further understanding of the present invention, and constitute a part of this application. The schematic embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation to the present invention. In the drawings:
[0026] Figure 1 is a flowchart of an optional processing method for subscription data according to an embodiment of the present invention;
[0027] Figure 2 is a flowchart of another optional processing method for subscription data according to an embodiment of the present invention;
[0028] Figure 3 It is a schematic diagram of an optional processing device for subscription data according to an embodiment of the present invention;
[0029] Figure 4 It is a schematic diagram of an electronic device according to an embodiment of the present invention. Detailed implementation manners
[0030] In order to enable those skilled in the art to better understand the solution of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
[0031] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily need to describe a specific order or sequence. It should be understood that such data used in appropriate cases can be interchanged so that the embodiments of the present invention described here can be implemented in an order other than those illustrated or described here. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device comprising a series of steps or units does not necessarily have to be limited to those clearly listed steps or units, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0032] It should be noted that the user information involved in the present application (including but not limited to user device information, user personal information, etc.), the collected information and data (including but not limited to the data for analysis, the stored data, the displayed data, etc.) are all information and data authorized by the user or fully authorized by all parties. And the processing of the relevant data such as collection, storage, use, processing, transmission, provision, disclosure and application all comply with the relevant laws, regulations and standards in the relevant regions, take necessary confidentiality measures, do not violate public order and good customs, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0033] For the convenience of description, some terms or nouns involved in the embodiments of the present invention are explained below.
[0034] Subscription block: A block used to record subscription records (or called subscription information), and this type of block can record one or several pieces of subscription information.
[0035] Subscription chaincode: The system chaincode responsible for processing subscription blocks. It is responsible for verifying the validity of subscription blocks, extracting the subscription information therein, and saving the subscription information in the form of key:value (key-value pairs) to the namespace of the world state database.
[0036] Namespace: An independent storage area in the world state database, whose parent path is named by the combined expression of the ledger name and the smart contract name.
[0037] Subscription management: The module responsible for processing subscription requests. It can extract ledger and certificate information from the subscription request and query its subscription records from the world state database. If the record exists, the subscription is permitted; otherwise, the subscription is rejected.
[0038] World state database: A key-value pair database used for quickly saving or accessing data.
[0039] Embodiment 1
[0040] According to an embodiment of the present invention, a method embodiment for processing subscription data is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. And although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.
[0041] Figure 1 is a flowchart of an optional method for processing subscription data according to an embodiment of the present invention, as Figure 1 shown, the method includes the following steps:
[0042] Step S101, obtain a subscription block storing subscription information, where the subscription block includes: a block for recording part of the subscription information in the full amount of subscription information, and the subscription information includes: the subscription rule for a first subscriber to subscribe to specified information.
[0043] The above-mentioned subscription block can be used to record one or several pieces of subscription information. The above-mentioned subscription information can include; the subscription rule for a subscriber to subscribe to specified information (for example, subscription permission), and the above-mentioned specified information can include ledger data in the blockchain. The above-mentioned first subscriber can be a node in the blockchain.
[0044] In this embodiment, after generating a subscription record (corresponding to the subscription information), a new subscription block can be created, and the subscription record is saved on the subscription block. One or several subscription records can be saved each time, and the subscription block can be saved to the hard disk of the subscription block after blockchain consensus.
[0045] In this embodiment, the subscription block records the subscription information for one or several days. There is no need to record all the subscription information (or subscription records) in the blockchain, nor to gather all the subscription information on a single block, which avoids the full - volume redundant storage when the subscription information changes and reduces the storage volume of the subscription block. There is also no need to perform decompression or compression operations on the subscription information, resulting in lower time complexity and space complexity.
[0046] Step S102: Extract the subscription information from the subscription block to obtain an extraction result.
[0047] The above - mentioned extraction result may include: the subscription information extracted from the subscription block. In this embodiment, the key information in the subscription information can be extracted from the subscription block through the subscription chain code to obtain the extraction result.
[0048] Step S103: Cache the extraction result in the target database, where the target database includes: a database that stores data in the form of key - value pairs.
[0049] The above - mentioned target database may include: a database that stores data in the form of key - value pairs, and the type of the target database can be the world state database. In this embodiment, caching the extraction result in the target database can avoid the situation in the related art where all the subscription information is stored in the block with high storage cost, or the situation where the full - volume subscription information is compressed and stored in the block with high time cost for storage and access of the subscription information.
[0050] In this embodiment, through the above steps, part of the full - volume subscription information is recorded in each subscription block, and the subscription information in the subscription block is cached in the target database, avoiding the situation in the related art where all the subscription information is stored in a single block with high storage pressure on a single block, thereby achieving the technical effect of reducing the storage space occupancy rate of a single block. Furthermore, it solves the technical problem in the related art that the effect of storing all the subscription information in a single block is not good.
[0051] Optionally, extracting the subscription information from the subscription block to obtain an extraction result includes: extracting the target information in the subscription information from the subscription block to obtain the extraction result, where the target information includes at least one of the following: the certificate of the first subscriber, the ledger identifier associated with the subscription block, the identifier of the subscription topic, the subscription status, the transaction identifier, the block height of the subscription block, and the subscription status is used to indicate whether the first subscriber has the subscription permission to subscribe to the specified information.
[0052] In this embodiment, all subscription settings (corresponding to subscription information) can be extracted from the subscription block by subscribing to the chaincode. The subscription settings are traversed, and information such as cert (certificate of the subscriber), channel (ledger name of the subscription block (corresponding to the ledger identifier)), subject (name of the subscription topic (corresponding to the identifier of the subscription topic)), subscribe (subscription status), txid (transaction identifier), and height (block height) is extracted.
[0053] When a new subscription block is created and goes through the consensus process, the subscription chaincode can be invoked. Its task is to parse this subscription block on the blockchain and extract the key information. These key information include:
[0054] Certificate (cert) of the first subscriber: The certificate is proof of the subscriber's identity and usually can contain the subscriber's public key and other identity-related information. Extracting the certificate is to verify the legality of the subscriber's identity and ensure that only authenticated subscribers can access specific data;
[0055] Ledger identifier (channel) associated with the subscription block: The ledger identifier is the unique identifier of a specific blockchain ledger, used to distinguish different ledgers, which helps to accurately locate and process subscription information in a multi-ledger environment;
[0056] Identifier (subject) of the subscription topic: Each subscriber may be interested in different topics or types of data in the ledger. The identifier of the subscription topic is used to clarify the data range that the subscriber is interested in, facilitating subsequent subscription control and information push; subscription status (subscribe), where the subscription status marks whether the subscriber has the subscription permission for specific information, whether it is true or false. This is the key information to determine whether the subscription request is accepted;
[0057] Transaction identifier (txid): The transaction identifier is the unique identifier of a blockchain transaction and can be used to trace and verify the integrity of the transaction. When processing subscription information, the transaction identifier can ensure the accuracy and immutability of the subscription configuration;
[0058] Block height (height) of the subscription block: The block height is the position identifier of the block in the blockchain, reflecting the order and time of the block. When verifying the validity of subscription information, the block height is a very important parameter because it can help determine whether the information is the latest and whether the blockchain state on which the information depends is correct.
[0059] By extracting key information (corresponding to the target information) from the subscription information of the subscription block, it is convenient to store the subscription information in the world state database, avoiding the situation where all subscription information is stored in the database, resulting in high storage space occupancy.
[0060] Optionally, cache the extraction result in the target database, including: extracting the identifier of the first subscriber from the certificate of the first subscriber to obtain the first subscription identifier; calculating the hash value of the certificate of the first subscriber to obtain the first hash value; based on the subscription status, caching the first subscription identifier, the first hash value, and the extraction result in the target database.
[0061] In this embodiment, the first subscription identifier can be extracted from the certificate of the first subscriber. For example, in the certificate of the first subscriber, the certificate data can be parsed to extract the identifier information of the subscriber. Usually, this identifier information is the cn (common name, the user name, that is, the identifier of the subscriber) in the certificate. However, in complex scenarios, it may include other identifier information, such as email, organization unit name, etc. After the cn or composite identifier information is extracted, it becomes the first subscription identifier. Assigning a unique identifier to each subscriber can facilitate the quick location and management of subscriber information in subscription processing and permission verification.
[0062] In an alternative approach, in the presence of multiple identifiers, a composite key generation strategy can also be designed. For example, combine the cn with other identification attributes to form a more complex unique key to meet a wider range of identification requirements. To enhance the flexibility of the system, an identification resolution rule library can be set up to dynamically resolve and generate the first subscription identifier according to different certificate structures and requirements.
[0063] In this embodiment, the hash value of the certificate of the first subscriber can also be calculated. For example, a secure hash algorithm (such as SHA-256) can be used to calculate the hash value of the certificate of the first subscriber. The generated first hash value is irreversible and unique, ensuring that even if the original certificate data changes, the hash value will also change accordingly, thus guaranteeing the integrity and security of the data. Through the hash operation, the certificate is converted into a short fixed-length hash value, which is used as an auxiliary key for storing and retrieving subscriber information in the database, reducing the time and space complexity of database operations.
[0064] In an alternative approach, the hash value can also be recalculated regularly and compared with the hash value stored in the target database to detect whether the information in the database has been tampered with or accidentally modified. The hash chain technology can also be considered to link the hash values of multiple certificates to enhance the security and traceability of the data.
[0065] In this embodiment, the first subscription identifier, the first hash value, and the extraction result can also be cached in the target database based on the subscription status. For example, according to the extracted first subscription identifier and the calculated first hash value, combined with the subscription status and other extraction results (such as ledger identifier, subscription topic identifier, transaction identifier, block height), key-value pair data can be formed.
[0066] Use a specific key structure, for example, / channel / <channel> / subcc / subject / <subject> / <cert-hash>, cache the data into the target database (i.e., the world state database). If the subscription status is true, create or update the record; if the subscription status is false, delete the corresponding record (wherein, if the record does not originally exist in the target database, it can be treated as an invalid deletion): Store the key subscription information in the world state database for quick retrieval and verification of the subscriber's permission status, improving the efficiency of subscription processing.
[0067] In an optional example, when caching information, version control information such as timestamps or version numbers can be appended for historical query and rollback in future data changes. Considering database performance, database sharding or distributed database strategies can also be adopted to distribute and store data according to ledger identifiers or topic identifiers, reducing the storage pressure on a single node and improving the overall read and write speed. When storing sensitive information (such as the details of certificates), the data can be encrypted so that even if the database is illegally accessed, the data content will not be directly leaked, enhancing data security.
[0068] By caching the key information in the subscription information into the target database, subscription information can be efficiently managed at a low time and space cost, realizing subscription configuration management in a large-scale subscriber environment while ensuring data security and integrity.
[0069] Optionally, based on the subscription status, cache the first subscription identifier, the first hash value, and the extraction result into the target database, including: when the subscription status indicates that the first subscriber has the subscription permission for the specified information, convert the first subscription identifier, the first hash value, and the extraction result into the form of key-value pairs to obtain the target key-value pair, and cache the target key-value pair into the target database, wherein the first hash value is recorded in the key of the target key-value pair, and the first subscription identifier is recorded in the value of the target key-value pair; when the subscription status indicates that the first subscriber does not have the subscription permission for the specified information, prohibit caching the first subscription identifier, the first hash value, and the extraction result into the target database.
[0070] For example, if subscribe is true (i.e., when the subscription status indicates that the first subscriber has the subscription permission for the specified information), the subscription information can be recorded into the target database (e.g., the world state database). The key is / channel / <channel> / subcc / subject / <subject> / <cert-hash>, the value content format is {"cn": <cn>,txid: <txid>,height: <height>}}。
[0071] If subscribe is false (that is, when the subscription status indicates that the first subscriber does not have the subscription permission for the specified information), the corresponding key of the subscription information can be deleted from the target database, and the key is / channel / <channel> / subcc / subject / <subject> / <cert-hash>, where if the target database does not originally store this record, it can be treated as an invalid deletion.
[0072] By caching the key information in the subscription information in the form of key-value pairs in the target database, the subscription information can be efficiently managed at a relatively low time and space cost.
[0073] Optionally, before obtaining the subscription block storing the subscription information, it includes: obtaining the subscription information, packaging the subscription information into a transaction in the blockchain to obtain a target transaction; sending the target transaction to an endorsement node for signing to obtain a signed target transaction; sending the signed target transaction to a consensus node to generate a subscription block, where the consensus node is used to package the signed target transaction into a block.
[0074] For example, obtain the subscription information: The subscription information usually includes the subscriber certificate, ledger identifier, subscription topic identifier, subscription status, and other possible metadata. This information can be sourced from requests directly submitted by the subscriber or the system's configuration management. Once the subscription information is obtained, it can be converted into the format of a blockchain transaction. The target transaction can also contain information about the transaction type to indicate that this is a subscription type transaction, so that subsequent endorsement and consensus processing can correctly identify and process it.
[0075] In this embodiment, the target transaction can be sent to an endorsement node for signing: After the target transaction is sent to the endorsement node, the endorsement node can perform a preliminary verification of the transaction's validity and also sign the transaction using the private key of the endorsement node. The signing process provides a trust basis for subsequent consensus and ensures the credibility of the transaction's source and content. Signature algorithm selection: The signature algorithm of the endorsement node can choose an algorithm with high security and wide acceptance. In addition, for the convenience of verification, the type of the signature algorithm can be recorded.
[0076] After signing is completed, the signed target transaction can be sent to a consensus node to be packaged into a subscription block. For example, the signed target transaction can be sent to a consensus node, and the consensus node will perform further verification on it, including the transaction format, signature validity, and ensuring that the transaction does not conflict with the current state of the ledger. If the transaction passes the verification of the consensus node, the signed target transaction can be added to a block and become part of the subscription block. In an optional example, the consensus node can generate a block according to the consensus algorithm of the blockchain. For subscription transactions, the consensus node can generate a subscription block. The generated subscription block will be broadcast to other nodes in the network, and these nodes can also verify the validity of the block, including verifying the signature of the transaction in the block, the correctness of the transaction content, and the block format, etc. It can be determined that the subscription block is considered legal and permanently stored in the blockchain ledger only after all nodes have verified and passed.
[0077] In this embodiment, by creating a subscription block, efficient and reliable support can be provided for subscription configuration management.
[0078] Optionally, after sending the signed target transaction to the consensus node to generate a subscription block, it further includes: using the consensus node to perform consensus on the subscription block to obtain a consensus result; in the case where the consensus result indicates successful consensus on the subscription block, storing the subscription block in the disk of the consensus node and broadcasting the subscription block to the accounting nodes, so that the accounting nodes store the subscription block in the disk of the accounting nodes.
[0079] The consensus of the consensus node can be a key mechanism in the blockchain to ensure that all nodes reach an agreement on the state of the ledger. When the consensus node receives the signed target transactions sent by the admin of Organization A (administrator, such as a user with high privileges) and packs these transactions into a subscription block, the consensus node can initiate the consensus process. During the consensus process, the consensus node can interact with other nodes in the blockchain to verify the validity of the transactions and ensure that the new block does not conflict with the existing ledger state.
[0080] Once the consensus node completes the consensus and confirms the validity of the subscription block, the consensus result will be fed back to the system next. If the consensus result indicates successful consensus on the subscription block, the consensus node will store the subscription block in its local disk to persistently save the new block. At the same time, the consensus node can also broadcast this new block to all accounting nodes in the network to ensure that all nodes can synchronize the new block, thus maintaining the consistency of the ledger.
[0081] In an alternative example, after the consensus node broadcasts the subscription block to the accounting nodes, these accounting nodes can also perform verification after receiving the new block to ensure the integrity and correctness of the block. If the verification passes, the accounting nodes will store the subscription block in their local disks and update their ledger states, improving the reliability of the subscription information storage.
[0082] Optionally, after caching the extraction result in the target database, it further includes: receiving a subscription request and extracting the certificate of the subscriber in the subscription request to obtain the certificate of the second subscriber; extracting the identifier of the second subscriber from the certificate of the second subscriber to obtain the second subscription identifier; calculating the hash value of the certificate of the second subscriber to obtain the second hash value; based on the second subscription identifier and the second hash value, using the target database to determine whether the second subscriber has the subscription right to the specified information to obtain a judgment result; based on the judgment result, determining whether to allow the second subscriber to subscribe to the specified information.
[0083] For example, a block subscription request can be initiated by an accounting node or a consensus node. After a certain node in the blockchain receives the subscription request, it can extract the channel subject cert information in the request information, extract the user name cn (corresponding to the second subscription identifier) in the cert (the certificate of the corresponding second subscriber). In this embodiment, the hash256 value cert-hash (corresponding to the second hash value) of the cert can be calculated, and it can be through the key: / channel / <channel> / subcc / subject / <subject> / <cert-hash>Query the key in the world state database. If the key does not exist (i.e., the second subscriber does not have the subscription permission for the specified information), the subscription can be rejected. If the key exists (i.e., there is a subscription permission), the public key can be retrieved from the cert to verify the signature. If the signature is valid, the subscription is permitted; otherwise, the subscription is rejected.
[0084] For example, when the system (e.g., a certain node in the blockchain) receives a subscription request, this request may come from any entity that wishes to subscribe to specific data in the blockchain ledger, such as Organization B. The request usually contains some key information, such as the proof of the subscriber's identity (certificate), the ledger identifier (channel) of the subscribed block, and the subscription topic identifier (subject). The system can first extract the certificate information of the second subscriber from the subscription request. This certificate is the proof of the subscriber's identity and contains the public key and other data used to verify the subscriber's identity. Certificate extraction is the basis for the system to judge the subscriber's permissions, ensuring the accuracy and security of subsequent processing. From the certificate of the second subscriber, the system will parse out its unique identifier (such as the username cn), which can be used for subsequent database queries to determine whether the subscriber has the right to subscribe to specific information.
[0085] To further improve the processing efficiency and security, the system can calculate the hash value of the second subscriber's certificate. Using a secure hash algorithm such as SHA-256, a fixed-length hash value can be generated. The system can query in the target database through the second subscription identifier and the second hash value to determine whether the second subscriber has obtained the subscription permission for the specified information (e.g., ledger data), where the key value for the query can be / channel / <channel> / subcc / subject / <subject> / <cert-hash>, where, <cert-hash>Corresponding to the second hash value.
[0086] If the query result exists, it can be determined that the subscription information of the second subscriber has been recorded in the target database, and the subscription status can be checked to see if it is true. If so, it means that the second subscriber has the right to subscribe; if not, it means that the permission has been revoked. If the query result does not exist: it can be determined that the subscription information of the second subscriber is not recorded in the target database, and the subscription request can be rejected.
[0087] Based on the target database, the legitimacy of the subscription request can be judged efficiently and accurately, ensuring that only subscribers with legitimate permissions can access specific information, protecting the integrity and security of the blockchain ledger data.
[0088] Optionally, after caching the extraction result in the target database, it further includes: loading the key-value pairs to be verified in the target database, where the key-value pairs to be verified include: the key-value pairs associated with the subscription information waiting for validity verification; based on the subscription information in the target block, performing validity verification on the key-value pairs to be verified to obtain a verification result, where the target block includes: the block used to record the subscription information associated with the key-value pairs to be verified.
[0089] In this embodiment, the validity of the subscription information can also be verified, including the following steps:
[0090] Step 1, one piece of subscription information in the target database can be loaded, in which the key is / channel / <channel> / subcc / subject / <subject> / <cert-hash>, value is {"cn": <cn>,txid: <txid>,height: <height>}(corresponding to the key-value pair to be verified).
[0091] Step 2: Extract the block (target block) through height and verify the block validity.
[0092] Step 3: Extract the subscription information in the block according to the txid from the target block, extract the subject and cert information, and calculate the cert-hash.
[0093] Step 4: Compare whether the cert-hash and the subject value in Step 1 and Step 3 are equal. If they are equal, it is valid; otherwise, it is invalid.
[0094] Through this embodiment, subscription information can be quickly recorded into the subscription block, and the subscription information can be cached in the world state database. For a subscription request, its subscription information settings can be quickly located, and the validity of the configuration can be verified. It is not necessary to gather all subscription information on one block, avoiding full-scale redundant storage when recording changes, and reducing the storage volume of the subscription block. Nor is it necessary to perform decompression or compression operations on the subscription, with lower time complexity and space complexity, ensuring that subscription information can still be quickly edited and efficiently managed even when there are many subscription entries. In the world state database, only the hash value of the certificate is stored, saving storage space. The linkage mechanism between the subscription block and the world state database ensures that the blockchain engine can quickly determine whether the subscription request of the subscriber is legal, improving the judgment efficiency.
[0095] Embodiment 2
[0096] Figure 2 is a flowchart of another optional processing method for subscription data according to an embodiment of the present invention. As Figure 2 shown, in this embodiment, based on a fine-grained "subscription block (abbreviated as subscription block)", a subscriber record list is established by linking the "world state database" through the `subscription chain code` for quick saving and extraction of subscription information, realizing efficient subscription control. Its processing process includes subscription record setting, subscription control, and valid verification of subscription records (i.e., subscription information), as follows:
[0097] Subscription record setting: A new subscription block can be opened, and the subscription records are saved on the block. One or several subscription records can be saved each time, and the block is saved to the hard disk after blockchain consensus. This logic is applicable to subscription record creation and subscription record editing.
[0098] Generation of subscription world state database: When the subscription block is saved, the subscription chain code can extract the subscription records in the subscription block and cache the key information (corresponding to the target information in Embodiment 1) in the world state database. This logic is applicable to subscription record creation and subscription record editing.
[0099] Subscription control: When a subscriber subscribes, the subscription control module checks from the world state database whether the subscriber has the subscription permission for the relevant data. If so, the subscription is permitted; otherwise, the subscription is rejected.
[0100] Validity verification of subscription records: For the subscription records in the world state data, the subscription records can be retrieved from the block by extracting the block height and transaction ID corresponding to the subscription records for verification.
[0101] Assume that the current production side is Organization A and the consumption side is Organization B. The processing process of subscription information can include the following steps:
[0102] 1.1. Ledger subscription record setting:
[0103] (1) The admin of Organization A packs a set of subscription settings (corresponding to the subscription information) into a transaction.
[0104] (2) The admin of Organization A sends the transaction to the endorsement nodes, and the endorsement nodes perform endorsement to obtain the signed transaction (corresponding to the signed target transaction in Embodiment 1).
[0105] (3) Organization A receives the signed transaction and sends the signed transaction to the consensus nodes.
[0106] (4) The consensus nodes receive the signed transaction, generate a separate block for the subscription information to obtain the subscription block, and perform consensus.
[0107] (5) After successful consensus, the consensus nodes save the subscription block to the disk of the consensus nodes and broadcast the subscription block to the accounting nodes.
[0108] (6) The accounting nodes receive the subscription block and record the subscription block to the disk of the accounting nodes.
[0109] Step 1.2 Generation of subscription world state database:
[0110] (1) The consensus nodes or accounting nodes receive the subscription block and save it to the disk.
[0111] (2) The consensus nodes or accounting nodes identify that the block type is a subscription block and call the subscription chain code.
[0112] (3) The subscription chain code extracts all subscription settings from the subscription block.
[0113] (4) The accounting nodes traverse the subscription setting records and extract the cert, channel, subject, subscribe, txid, and height information.
[0114] Extract the user name cn in cert, and calculate the hash256 value of the subscriber's certificate, cert-hash.
[0115] If subscribe (subscription status) is true, record the subscription record in the world state database. The key is / channel / <channel> / subcc / subject / <subject> / <cert-hash>, the value content format is {"cn": <cn>,txid: <txid>,height: <height>}}。
[0116] (7) If subscribe is false, delete the corresponding key of the subscription record from the world state database. The key is / channel / <channel> / subcc / subject / <subject> / <cert-hash>。
[0117] 1.3 Subscription Management:
[0118] (1) Organization B initiates a block subscription request through the accounting node.
[0119] (2) The node receives the subscription request and extracts the channel subject cert information in the request message.
[0120] (3) Extract the user name cn in the cert and calculate the hash256 value cert-hash of the cert.
[0121] (4) Through the key: / channel / <channel> / subcc / subject / <subject> / <cert-hash>Query the key in the world state database.
[0122] (5)Reject the subscription if the key does not exist.
[0123] (6)If the key exists, the public key can be retrieved from the cert to verify the signature. If the signature is valid, the subscription is permitted; otherwise, the subscription is rejected.
[0124] 1.4 Validation of subscription records:
[0125] (1)Load a subscription record in the world state database with the key / channel / <channel> / subcc / subject / <subject> / <cert-hash>, value is {"cn": <cn>,txid: <txid>,height: <height>}}。
[0126] (2)Extract blocks through height and verify the validity of the blocks.
[0127] (3)Extract the subscription information in the block according to the txid from the block, extract the subject and cert information, and calculate the cert-hash.
[0128] (4)Compare whether the cert-hash and the subject value in step (1) and step (3) are equal. If they are equal, it is valid; otherwise, it is invalid.
[0129] Through this embodiment, the subscription information can be quickly recorded into the subscription block, and the subscription information can be cached in the world state database. For a subscription request, its subscription information settings can be quickly located, and the validity of the configuration can be verified. It is not necessary to gather all subscription information on one block, avoiding the full-scale redundant storage when recording changes, and reducing the storage volume of the subscription block. Nor is it necessary to perform decompression or compression operations on the subscription, with lower time complexity and space complexity, ensuring that the subscription information can still be quickly edited and efficiently managed even when there are many subscription entries. In the world state database, only the hash value of the certificate is stored, saving storage space. The linkage mechanism between the subscription block and the world state database ensures that the blockchain engine can quickly determine whether the subscription request of the subscriber is legal, improving the judgment efficiency. Embodiment
[0130] Embodiment III of the present invention provides an optional processing device for subscription data. Each implementation unit in the processing device corresponds to each implementation step in Embodiment I.
[0131] Figure 3 is a schematic diagram of an optional processing device for subscription data according to an embodiment of the present invention, as Figure 3 shown, including: an acquisition unit 31, an extraction unit 32, and a caching unit 33.
[0132] Among them, the acquisition unit 31 is used to acquire the subscription block storing the subscription information, where the subscription block includes: a block for recording part of the subscription information in the full-scale subscription information, and the subscription information includes: the subscription rule for the first subscriber to subscribe to the specified information;
[0133] The extraction unit 32 is used to extract the subscription information in the subscription block to obtain an extraction result;
[0134] The caching unit 33 is used to cache the extraction result into the target database, where the target database includes: a database storing data in the form of key-value pairs.
[0135] In the subscription data processing device provided in the third embodiment of the present invention, a subscription block storing subscription information can be obtained through an acquisition unit 31. The subscription block includes: a block for recording partial subscription information in the full amount of subscription information, and the subscription information includes: a subscription rule for a first subscriber to subscribe to specified information. The subscription information is extracted from the subscription block through an extraction unit 32 to obtain an extraction result, and the extraction result is cached to a target database through a caching unit 33. The target database includes: a database storing data in the form of key-value pairs. Furthermore, the technical problem in the related art that the full amount of subscription information is stored in a single block and the effect of storing the full amount of subscription information in a single block is not good is solved. In this embodiment, partial subscription information in the full amount of subscription information is recorded in each subscription block, and the subscription information in the subscription block is cached to the target database, avoiding the situation in the related art that the full amount of subscription information is stored in a single block and the storage pressure of the single block is large, thereby achieving the technical effect of reducing the storage space occupancy rate of a single block.
[0136] Optionally, in the subscription data processing device provided in the third embodiment of the present invention, the extraction unit includes: a first extraction subunit, configured to extract target information in the subscription information from the subscription block to obtain an extraction result, where the target information includes at least one of the following: a certificate of the first subscriber, a ledger identifier associated with the subscription block, an identifier of a subscription topic, a subscription status, a transaction identifier, a block height of the subscription block, and the subscription status is used to indicate whether the first subscriber has the subscription permission to subscribe to the specified information.
[0137] Optionally, in the subscription data processing device provided in the third embodiment of the present invention, the caching unit includes: an extraction subunit, configured to extract an identifier of the first subscriber from the certificate of the first subscriber to obtain a first subscription identifier; a calculation subunit, configured to calculate a hash value of the certificate of the first subscriber to obtain a first hash value; and a caching subunit, configured to cache the first subscription identifier, the first hash value, and the extraction result to the target database based on the subscription status.
[0138] Optionally, in the subscription data processing device provided in the third embodiment of the present invention, the caching subunit includes: a conversion module, configured to convert the first subscription identifier, the first hash value, and the extraction result into the form of a key-value pair to obtain a target key-value pair and cache the target key-value pair to the target database when the subscription status indicates that the first subscriber has the subscription permission for the specified information, where the first hash value is recorded in the key of the target key-value pair and the first subscription identifier is recorded in the value of the target key-value pair; and a processing module, configured to prohibit caching the first subscription identifier, the first hash value, and the extraction result to the target database when the subscription status indicates that the first subscriber does not have the subscription permission for the specified information.
[0139] Optionally, in the subscription data processing device provided in Embodiment 3 of the present invention, the subscription data processing device further includes: a first processing unit, configured to obtain subscription information before obtaining a subscription block storing the subscription information, and pack the subscription information into a transaction in the blockchain to obtain a target transaction; a signature unit, configured to send the target transaction to an endorsement node for signature to obtain a signed target transaction; a sending unit, configured to send the signed target transaction to a consensus node to generate a subscription block, where the consensus node is configured to pack the signed target transaction into a block.
[0140] Optionally, in the subscription data processing device provided in Embodiment 3 of the present invention, the subscription data processing device further includes: a consensus unit, configured to, after sending the signed target transaction to a consensus node to generate a subscription block, perform consensus on the subscription block by using the consensus node to obtain a consensus result; a second processing unit, configured to, when the consensus result indicates successful consensus on the subscription block, store the subscription block in the disk of the consensus node and broadcast the subscription block to a bookkeeping node, so that the bookkeeping node stores the subscription block in the disk of the bookkeeping node.
[0141] Optionally, in the subscription data processing device provided in Embodiment 3 of the present invention, the subscription data processing device further includes: a receiving unit, configured to, after caching the extraction result in a target database, receive a subscription request and extract a certificate of a subscriber in the subscription request to obtain a certificate of a second subscriber; a third processing unit, configured to extract an identifier of the second subscriber from the certificate of the second subscriber to obtain a second subscription identifier; a calculation unit, configured to calculate a hash value of the certificate of the second subscriber to obtain a second hash value; a judgment unit, configured to, based on the second subscription identifier and the second hash value, use the target database to judge whether the second subscriber has the subscription right to specified information to obtain a judgment result; a determination unit, configured to determine whether to allow the second subscriber to subscribe to the specified information based on the judgment result.
[0142] Optionally, in the subscription data processing device provided in Embodiment 3 of the present invention, the subscription data processing device further includes: a loading unit, configured to, after caching the extraction result in a target database, load key-value pairs to be verified in the target database, where the key-value pairs to be verified include: key-value pairs associated with subscription information waiting for validity verification; a verification unit, configured to perform validity verification on the key-value pairs to be verified based on the subscription information in a target block to obtain a verification result, where the target block includes: a block for recording subscription information associated with the key-value pairs to be verified.
[0143] The above-mentioned processing device for subscription data may further include a processor and a memory. The above-mentioned acquisition unit 31, extraction unit 32, cache unit 33, etc. are all stored in the memory as program units, and the processor executes the above program units stored in the memory to implement corresponding functions.
[0144] The above-mentioned processor includes a kernel, and the kernel retrieves the corresponding program units from the memory. One or more kernels can be set. By adjusting the kernel parameters, partial subscription information in the full-scale subscription information is recorded in each subscription block, and the subscription information in the subscription block is cached to the target database, avoiding the situation in the related art where the full-scale subscription information is stored in a single block and the storage pressure of a single block is large, thereby achieving the technical effect of reducing the storage space occupancy rate of a single block.
[0145] The above-mentioned memory may include non-permanent memory in a computer-readable medium, in the form of random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash memory (flash RAM), and the memory includes at least one storage chip.
[0146] According to another aspect of the embodiments of the present invention, an electronic device is further provided, including: a processor; and a memory for storing executable instructions of the processor; wherein, the processor is configured to execute the processing method of subscription data in any one of the above through executing the executable instructions.
[0147] According to another aspect of the embodiments of the present invention, a computer-readable storage medium is further provided. The computer-readable storage medium stores a computer program, wherein when the computer program runs, it controls the device where the computer-readable storage medium is located to execute the processing method of subscription data in any one of the above.
[0148] Figure 4 is a schematic diagram of an electronic device according to an embodiment of the present invention, as Figure 4 shown, an embodiment of the present invention provides an electronic device 40. The electronic device includes a processor, a memory, and a program stored on the memory and executable on the processor. When the processor executes the program, it implements the processing method of subscription data in any one of the above.
[0149] The above serial numbers of the embodiments of the present invention are only for description and do not represent the advantages and disadvantages of the embodiments.
[0150] In the above embodiments of the present invention, the descriptions of each embodiment have their own emphases. For the parts not detailed in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0151] In several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are merely illustrative. For example, the division of the units can be a logical function division. In actual implementation, there can be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the couplings or direct couplings or communication connections shown or discussed with each other can be through some interfaces. The indirect couplings or communication connections of units or modules can be in electrical or other forms.
[0152] The units described as separate components may or may not be physically separated. The components shown as units may or may not be physical units, that is, they can be located in one place or distributed to multiple units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0153] In addition, in each embodiment of the present invention, the functional units can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.
[0154] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server or a network device, etc.) to execute all or part of the steps of the methods described in each embodiment of the present invention. The foregoing storage medium includes: USB flash drives, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), mobile hard disks, magnetic disks or optical discs and other media that can store program codes.
[0155] The above is only the preferred embodiment of the present invention. It should be pointed out that for those of ordinary skill in the art, without departing from the principle of the present invention, several improvements and refinements can still be made, and these improvements and refinements should also be regarded as the protection scope of the present invention.< / height> < / txid> < / cn> < / subject> < / channel> < / subject> < / channel> < / subject> < / channel> < / height> < / txid> < / cn> < / subject> < / channel> < / height> < / txid> < / cn> < / subject> < / channel> < / subject> < / channel> < / subject> < / channel> < / subject> < / channel> < / height> < / txid> < / cn> < / subject> < / channel> < / subject> < / channel>
Claims
1. A method for processing subscribed data, characterized in that Including: Obtain a subscription block storing subscription information, where the subscription block includes: a block for recording partial subscription information in the full amount of subscription information, and the subscription information includes: a subscription rule for a first subscriber to subscribe to specified information; Extract the subscription information from the subscription block to obtain an extraction result; Cache the extraction result in a target database, where the target database includes: a database storing data in the form of key-value pairs; Extracting the subscription information from the subscription block to obtain an extraction result includes: extracting target information in the subscription information from the subscription block to obtain the extraction result, where the target information includes at least one of the following: a certificate of the first subscriber, a ledger identifier associated with the subscription block, an identifier of a subscription topic, a subscription status, a transaction identifier, a block height of the subscription block, and the subscription status is used to indicate whether the first subscriber has the subscription permission to subscribe to the specified information; Caching the extraction result in the target database includes: extracting an identifier of the first subscriber from the certificate of the first subscriber to obtain a first subscription identifier; calculating a hash value of the certificate of the first subscriber to obtain a first hash value; based on the subscription status, caching the first subscription identifier, the first hash value, and the extraction result in the target database; The method further includes: periodically recalculating the first hash value and comparing it with the hash value stored in the target database to detect whether the information in the target database has been tampered with.
2. The processing method according to claim 1, wherein Caching the first subscription identifier, the first hash value, and the extraction result in the target database based on the subscription status includes: In the case where the subscription status indicates that the first subscriber has the subscription permission for the specified information, converting the first subscription identifier, the first hash value, and the extraction result into the form of a key-value pair to obtain a target key-value pair, and caching the target key-value pair in the target database, where the first hash value is recorded in the key of the target key-value pair, and the first subscription identifier is recorded in the value of the target key-value pair; In the case where the subscription status indicates that the first subscriber does not have the subscription permission for the specified information, it is prohibited to cache the first subscription identifier, the first hash value, and the extraction result in the target database.
3. The processing method according to claim 1, characterized in that, Before obtaining the subscription block storing the subscription information, it includes: Obtain the subscription information and package the subscription information into a transaction in the blockchain to obtain a target transaction; Send the target transaction to an endorsing node for signature to obtain a signed target transaction; Send the signed target transaction to a consensus node to generate the subscription block, where the consensus node is used to package the signed target transaction into a block.
4. The processing method according to claim 3, characterized in that After sending the signed target transaction to the consensus node to generate the subscription block, it further includes: Performing consensus on the subscription block by using the consensus node to obtain a consensus result; When the consensus result indicates successful consensus on the subscribed block, store the subscribed block in the disk of the consensus node, and broadcast the subscribed block to the accounting nodes so that the accounting nodes store the subscribed block in their disks.
5. The processing method according to claim 1, wherein After caching the extraction result in the target database, it further includes: Receive a subscription request and extract the certificate of the subscriber in the subscription request to obtain the certificate of the second subscriber. Extract the identifier of the second subscriber from the certificate of the second subscriber to obtain the second subscription identifier. Calculate the hash value of the certificate of the second subscriber to obtain the second hash value. Based on the second subscription identifier and the second hash value, use the target database to determine whether the second subscriber has the subscription permission for the specified information to obtain a judgment result. Based on the judgment result, determine whether to allow the second subscriber to subscribe to the specified information.
6. The processing method according to claim 1, wherein After caching the extraction result in the target database, it further includes: Load the key-value pairs to be verified in the target database, where the key-value pairs to be verified include: the key-value pairs associated with the subscription information waiting for validity verification. Based on the subscription information in the target block, perform validity verification on the key-value pairs to be verified to obtain a verification result, where the target block includes: a block for recording the subscription information associated with the key-value pairs to be verified.
7. A processing device for subscription data, characterized in that It includes: An acquisition unit for acquiring a subscribed block storing subscription information, where the subscribed block includes: a block for recording part of the subscription information in the full amount of subscription information, and the subscription information includes: the subscription rules for the first subscriber to subscribe to specified information. An extraction unit for extracting the subscription information from the subscribed block to obtain an extraction result. A caching unit for caching the extraction result in the target database, where the target database includes: a database storing data in the form of key-value pairs. The extraction unit includes: a first extraction subunit for extracting the target information in the subscription information from the subscribed block to obtain the extraction result, where the target information includes at least one of the following: the certificate of the first subscriber, the ledger identifier associated with the subscribed block, the identifier of the subscription topic, the subscription status, the transaction identifier, the block height of the subscribed block, and the subscription status is used to indicate whether the first subscriber has the subscription permission to subscribe to the specified information. The caching unit includes: an extraction subunit for extracting the identifier of the first subscriber from the certificate of the first subscriber to obtain the first subscription identifier; a calculation subunit for calculating the hash value of the certificate of the first subscriber to obtain the first hash value; and a caching subunit for caching the first subscription identifier, the first hash value, and the extraction result in the target database based on the subscription status. The device further includes: regularly recalculate the first hash value and compare it with the hash value stored in the target database to detect whether the information in the target database has been tampered with.
8. An electronic device, characterized in that, Comprising one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors are caused to implement the method for processing subscription data according to any one of claims 1 to 6.
Citation Information
Patent Citations
Information subscription method and device of block chain, server and storage medium
CN112671878A
Communication method and device of block chain system, equipment and storage medium
CN114257593A