WO2024037629A1 - 区块链的数据整合方法、装置、计算机设备及存储介质 - Google Patents

区块链的数据整合方法、装置、计算机设备及存储介质 Download PDF

Info

Publication number
WO2024037629A1
WO2024037629A1 PCT/CN2023/113768 CN2023113768W WO2024037629A1 WO 2024037629 A1 WO2024037629 A1 WO 2024037629A1 CN 2023113768 W CN2023113768 W CN 2023113768W WO 2024037629 A1 WO2024037629 A1 WO 2024037629A1
Authority
WO
WIPO (PCT)
Prior art keywords
message
blockchain
data
partition
messages
Prior art date
Application number
PCT/CN2023/113768
Other languages
English (en)
French (fr)
Inventor
王红伟
唐俊峰
方银城
张强
陈新江
吕寒冰
任亚坤
陈晓文
Original Assignee
顺丰科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 顺丰科技有限公司 filed Critical 顺丰科技有限公司
Publication of WO2024037629A1 publication Critical patent/WO2024037629A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • This application relates to the field of data processing, specifically to a blockchain data integration method, device, computer equipment and storage medium.
  • Embodiments of the present application provide a data integration method, device, computer equipment and storage medium for a blockchain, which can integrate on-chain information of different business nodes to solve the technical problem of data incompatibility in multiple blockchains. .
  • this application provides a blockchain data integration method, applied to a blockchain system.
  • the blockchain system includes a message middleware for transmitting messages.
  • the message middleware includes a message middleware for storing messages.
  • Distributed message queue, the blockchain data integration method includes:
  • the messages in the distributed message queue are analyzed to obtain a locally ordered message queue set of the uplink information.
  • the locally ordered message queue set includes a plurality of locally ordered message queues, and each of the locally ordered message queues has The sequential message queue stores a partition message, and each partition message corresponds to a message topic;
  • the locally ordered message queue set is consumed in an orderly manner to obtain a globally ordered message queue set.
  • the global ordered message queue set includes a plurality of globally ordered message queues marked with order, and each of the globally ordered message queue sets is Message queue stores partitioned messages with the same message topic;
  • the partition messages with the same message topic in the global ordered message queue are used as on-chain data and are uploaded on the blockchain system.
  • the ordered consumption of the locally ordered message queue set is performed to obtain a global ordered message queue set, including:
  • a preconfigured sub-thread is started to consume the memory queue message, and the global ordered message queue is generated.
  • the distributed message queue is kafka
  • the subscription to the messages of the locally ordered message queue obtains multiple message topic identifiers and partition messages corresponding to each of the message topic identifiers, including:
  • the on-chain information includes the chain channel identifier and the smart contract version identifier of the blockchain to be on-chain, where,
  • the step of using the partition messages with the same message topic in the global ordered message queue as on-chain data and uploading them on the blockchain system includes:
  • the uploaded data is uploaded to the target blockchain.
  • determining the target blockchain of the on-chain data based on the chain channel identifier and the smart contract version identifier includes:
  • target blockchain type identifier and the target smart contract search for the target blockchain in the preconfigured mapping table of the blockchain type identifier, target smart contract, and blockchain.
  • uploading the uploaded data in the target blockchain includes:
  • the blockchain Data integration methods after the partition messages with the same message topic in the global ordered message queue are used as on-chain data, after the blockchain system is on-chain, the blockchain Data integration methods also include:
  • the blockchain Data integration methods after the partition messages with the same message topic in the global ordered message queue are used as on-chain data, after the blockchain system is on-chain, the blockchain Data integration methods also include:
  • the uplinking result table includes data on successful uplinking
  • the uplink failure data is uploaded a second time.
  • this application provides a data integration device for blockchain, which is applied to a blockchain system.
  • the blockchain system includes a message middleware for transmitting messages.
  • the message middleware includes a message middleware for storing messages.
  • Distributed message queue, the blockchain data integration device includes:
  • the acquisition module is used to obtain the on-chain information of multiple business nodes in the blockchain system
  • a sending module configured to send the uplink information to the distributed message queue of the message middleware
  • An analysis module used to analyze the messages in the distributed message queue to obtain a locally ordered message queue set of the uplink information.
  • the partially ordered message queue set includes a plurality of partially ordered message queues, each of which is Each of the locally ordered message queues stores a partition message, and each partition message corresponds to a message topic;
  • An integration module configured to consume the local ordered message queue set in an orderly manner to obtain a global ordered message queue set.
  • the global ordered message queue set includes a plurality of globally ordered message queues marked with order, each of which The global ordered message queue stores partitioned messages with the same message topic;
  • the uplink module is configured to use the partition messages with the same message topic in the global ordered message queue as uplink data and upload them to the blockchain system.
  • the integration module is specifically used for:
  • a preconfigured sub-thread is started to consume the memory queue message, and the global ordered message queue is generated.
  • the distributed message queue is kafka
  • the integration module is specifically used to:
  • the uplinking information includes the chain channel identifier and the smart contract version identifier of the blockchain to be uplinked, wherein the uplinking module is specifically used to:
  • the uploaded data is uploaded to the target blockchain.
  • the winding module is specifically used for:
  • target blockchain type identifier and the target smart contract search for the target blockchain in the preconfigured mapping table of the blockchain type identifier, target smart contract, and blockchain.
  • the winding module is specifically used for:
  • the blockchain data integration device also includes:
  • the analysis module is used to analyze the on-chain data after being uploaded through the blockchain network to obtain analytical business data;
  • a filling module used to fill in the parsed business data to obtain standardized business data
  • a writing module is used to write the standardized business data into a preset database.
  • the blockchain data integration device also includes:
  • the first acquisition module is used to obtain a pre-stored uplink result table, where the uplink result table includes data on successful uplink;
  • a comparison module used to compare and verify the uplink data with the successfully uplinked data in the uplink result table, obtain a comparison verification result, and determine whether there is uplink failure data based on the comparison verification result;
  • the secondary uplinking module is used to perform secondary uplinking on the uplinking failed data if the uplinking failed data exists.
  • this application also provides a computer device, which includes:
  • a memory wherein one or more application programs are stored in the memory, and the one or more application programs are configured to be executed by the processor to implement the blockchain according to any one of the first aspects.
  • Data integration methods are configured to be executed by the processor to implement the blockchain according to any one of the first aspects.
  • this application also provides a computer-readable storage medium on which a computer program is stored, and the computer program is loaded by a processor to perform the data integration of the blockchain described in any one of the first aspects. steps in the method.
  • This application obtains the uplink information of multiple business nodes in the blockchain system, sends the uplink information to the distributed message queue of the message middleware, analyzes the messages in the distributed message queue, and obtains A locally ordered message queue set, performs orderly consumption on the locally ordered message queue set, and obtains a global ordered message queue set, and uses the partition messages with the same message topic in the global ordered message queue as the above
  • On-chain data is uploaded to the blockchain system, which realizes the integration of on-chain information of different business nodes. Since the global ordered message queue is orderly, it ensures the global orderliness of the on-chain data. sex.
  • Figure 1 is a schematic diagram of a scenario of a blockchain data integration device provided by an embodiment of the present application.
  • Figure 2 is a schematic flowchart of a blockchain data integration method provided by an embodiment of the present application.
  • FIG. 3 is a schematic flowchart of step 304 provided by an embodiment of the present application.
  • FIG. 4 is a schematic flowchart of step 401 provided by an embodiment of the present application.
  • Figure 5 is a schematic flowchart of step 305 provided by an embodiment of the present application.
  • FIG. 6 is a schematic flowchart of step 601 provided by an embodiment of the present application.
  • Figure 7 is a schematic flowchart of step 305 or step 602 provided by an embodiment of the present application.
  • Figure 8 is a schematic flowchart of a blockchain data integration method provided by another embodiment of the present application.
  • Figure 9 is a schematic flowchart of a blockchain data integration method provided by another embodiment of the present application.
  • Figure 10 is a schematic structural diagram of a blockchain data integration device provided by an embodiment of the present application.
  • Figure 11 is a schematic structural diagram of a computer device provided by an embodiment of the present application.
  • Embodiments of the present application provide a data integration method, device, computer equipment, and storage medium for blockchain, which will be described in detail below.
  • Figure 1 is a schematic diagram of a scenario of a blockchain data integration device provided by an embodiment of the present application.
  • the blockchain data integration device may include a computer device 100, or the computer device 100 may be integrated with a zone.
  • the data integration device of the blockchain is the computer equipment in Figure 1.
  • Blockchain systems include message middleware for transmitting messages, and message middleware includes distributed message queues for storing messages.
  • the computer device 100 is mainly used to: obtain the uplink information of multiple business nodes in the blockchain system; send the uplink information to the distributed message queue of the message middleware, and the message
  • the middleware is used to transmit messages in the blockchain system; analyze the messages in the distributed message queue to obtain a locally ordered message queue set of the on-chain information, and the partially ordered message queue set is It includes multiple locally ordered message queues.
  • Each of the locally ordered message queues stores a partition message, and each partition message corresponds to a message topic.
  • the locally ordered message queue set is consumed in an orderly manner to obtain a globally ordered message.
  • a message queue set the global ordered message queue set includes a plurality of globally ordered message queues marked with order, each of the global ordered message queues stores partitioned messages with the same message topic; the global ordered message The partition messages with the same message topic in the queue are used as uplink data and are uploaded to the blockchain system.
  • the computer device 100 realizes the integration of the uplink information of different business nodes. Since the global ordered message queue has orderliness, the global orderliness of the uplink data is ensured. sequence.
  • the computer device 100 may be an independent server, or a server network or server cluster composed of servers.
  • the computer device 100 described in the embodiment of the present application includes, but is not limited to, a computer, a network A host, a single network server, a set of multiple network servers, or a cloud server composed of multiple servers.
  • the cloud server consists of a large number of computers or network servers based on cloud computing (Cloud Computing).
  • Computer device 100 may also be referred to as a terminal. It can be understood that the terminal 100 used in the embodiment of the present application may be a device that includes both receiving and transmitting hardware, that is, a device with receiving and transmitting hardware capable of performing two-way communication on a two-way communication link. Such devices may include cellular or other communications devices with a single line display or a multi-line display or a cellular or other communications device without a multi-line display. In some embodiments, the terminal 100 may be a desktop terminal or a mobile terminal. The terminal 100 may also be a mobile phone, a tablet computer, a notebook computer, etc.
  • FIG. 1 is only one application scenario of the solution of the present application and does not constitute a limitation on the application scenarios of the solution of the present application.
  • Other application environments may also include those shown in Figure 1 Show more or less computer equipment, for example, only one computer equipment is shown in Figure 1.
  • the data integration device of the blockchain can also include one or more other services, which are not limited here.
  • the data integration device of the blockchain can also include a memory 200 for storing on-chain information of different business nodes, such as transaction information, such as various transaction information of digital collections. Specifically, such as Attribution information of digital collections, quasi-transfer information of digital collections, etc.
  • inventions of the present application provide a data integration method of a blockchain.
  • the execution subject of the data integration method of the blockchain is a data integration device of the blockchain.
  • the data integration device of the blockchain is applied to computer equipment.
  • the data integration method of the blockchain includes: obtaining the uplink information of multiple business nodes in the blockchain system; sending the uplink information to the distributed message queue of the message middleware; The messages in the message queue are analyzed to obtain a partially ordered message queue set of the uplink information.
  • the partially ordered message queue set includes multiple partially ordered message queues, and each of the partially ordered message queues stores a Partition messages, each partition message corresponds to a message topic; the local ordered message queue set is consumed in an orderly manner to obtain a global ordered message queue set, and the global ordered message queue set is
  • the collection includes a plurality of globally ordered message queues marked with order, each of the global ordered message queues stores partition messages with the same message topic; the partitions with the same message topic in the global ordered message queue are Messages are used as on-chain data and are uploaded on the blockchain system.
  • FIG. 2 shows a schematic flowchart of a blockchain data integration method provided by an embodiment of the present application.
  • the blockchain data integration method may include the following steps 301 to 305.
  • a blockchain system refers to a system composed of blockchains with multiple different data structures. At least two blockchains with different data structures constitute a heterogeneous blockchain.
  • the data structure of blockchain A is ⁇ did, blockhash, funcParam(Json) ⁇ , where did, blockhash, and funcParam(Json) are respectively represented as distributed digital identity, block hash, and Json. Format parameter transfer;
  • the structure of the data structure of blockchain B is ⁇ txhash, blockheight ⁇ , where txhash and blockheight represent the current hash and block height respectively.
  • the data structures of Blockchain A and Blockchain B are different, that is, the data structures of Blockchain A and Blockchain B are different, that is, Blockchain A and Blockchain B are combined into a heterogeneous blockchain. .
  • a blockchain has a data structure, where the data structure includes information such as data parameter type, data construction method, parameter attributes, etc.
  • the data of different data structures in heterogeneous blockchains are called heterogeneous data, also known as heterogeneous data. That is, there is a lot of heterogeneous data in the heterogeneous blockchain, and heterogeneous data needs to be converted during the data sharing/storage process. When there is a lot of heterogeneous data, the efficiency of the chain will be reduced.
  • On-chain information refers to the information related to data uploading in a business node, including the data to be uploaded by multiple business nodes, the user ID and private key of the business node on the blockchain system.
  • the user ID and private key are used for identity verification when uploading to the blockchain.
  • the data to be uploaded refers to the data that needs to be uploaded to the blockchain. Since the data to be uploaded on different business nodes are aimed at different businesses, the respective data to be uploaded are heterogeneous data, that is, the data structures and types must be different.
  • the business node refers to the node of the application corresponding to the application chain in the blockchain technology architecture.
  • the blockchain technology architecture there are multiple application chains, and each application chain corresponds to the blockchain type, smart contract type and data
  • the structures are different.
  • blockchain types can be divided into evm, fisco bcos or hyperledger fabric according to technical implementation.
  • the business layer, scenario layer and access layer can be pre-configured on the business nodes in the blockchain system.
  • the business layer is the service that needs to be called by the outside world.
  • the scenario layer is used to provide different services for different needs.
  • the access layer is used to provide SDK, restful interface methods, synchronous on-chain services, and asynchronous on-chain services to the scene layer and externally.
  • the business layer generates an uploading requirement, the data to be uploaded is provided to the scene layer.
  • the scene layer obtains the user ID and private key, and packages the user ID, private key and data to be uploaded into the chain information, and submits it to the access layer, and the data to be uploaded in the upload information submitted by different scene layers is called Parameter encapsulation of different smart contracts, where the parameters include the type of blockchain and the smart contract version on the corresponding type of blockchain.
  • message middleware is the basic component that completes the sending and receiving of messages in a distributed system. It transmits messages through an efficient and reliable messaging mechanism.
  • the message middleware includes but is not limited to ActiveMQ, RabbitMQ, ZeroMQ, and Kafka. MetaMQ or RocketMQ etc.
  • Distributed message queue is a container used to save messages in message middleware.
  • the uplink information is stored in the distributed message queue, enabling rapid screening and analysis of massive data messages, improving message transmission efficiency, throughput and processing performance, and also It is helpful to improve the efficiency of subsequent data uploading to the chain.
  • the partially ordered message queue set includes multiple partially ordered message queues, each of which is The locally ordered message queue stores a partition message, and each partition message corresponds to a message topic.
  • the locally ordered message queue refers to a message queue that can ensure the order of messages stored in the same partition (partition), that is, a partition message is stored in a locally ordered message queue, and the messages in the distributed message queue can be Inside
  • the capacity is divided into the required number of partitions, and messages are routed to fixed partitions through partition strategies to achieve ordering of messages in each fixed partition.
  • the partition message refers to the uplink information stored in a partition. It can be understood that from step 301, the uplink information is packaged by the user ID, private key and data to be uploaded. Since the partition message distributes the uplink information Obtained after message processing, therefore, the partition message contains the user ID and private key.
  • the blockchain system analyzes messages stored in distributed message queues.
  • this embodiment uses the distributed publish-subscribe messaging system Kafka to analyze the messages in the distributed message queue.
  • Kafka provides message persistence through a disk data structure. This structure can also store messages on the order of TB for a long time. It has stable performance and can handle all action flow data of different business nodes in each application chain.
  • the action flow data may specifically be various data generated by the service node during the data uplink process. More specifically, each message obtained by the Kafka cluster has a message topic, and this category is called Topic. Messages of different topics are stored in partitions. The storage location of each partition can be customized according to needs and recorded in Offset.
  • each message has an offset to ensure order within the same partition, that is, local order.
  • the offset is the index sequence of the storage location.
  • the offset includes but is not limited to: offset number, message category, distributed server IP address, storage location and message time. And the number of partitions can be set to multiple to improve the overall throughput of the Topic.
  • Kafka adopts a decoupled design idea, it is not a primitive publish and subscribe.
  • the producer pushes the data to each Topic, and the consumer obtains the data from the Topic.
  • the Fetch method provides an API interface for obtaining resource data and a more powerful and flexible function set. Consumers can obtain the interface according to their own capabilities and are not restricted by the producer's server;
  • Kafka can obtain and store all the information to be uploaded in real time and quickly analyze it, and obtain multiple locally ordered message queues of the uploaded information.
  • Each local ordered message queue stores a partition message.
  • a single-threaded consumer is used to improve message processing efficiency through the concurrency of the number of partitions on the premise of achieving partial ordering.
  • the global ordered message queue set includes a plurality of globally ordered message queues marked with order.
  • Each of the global ordered message queue sets An ordered message queue stores partitioned messages with the same message topic.
  • the locally ordered message queue set is consumed in an orderly manner as described in step 304 to obtain a global ordered message queue set.
  • the global ordered message queue set includes multiple Each global ordered message queue is marked with order, and each global ordered message queue stores partitioned messages with the same message topic, which may include the following steps 401 to 404, specifically as follows:
  • the consumer subscribes to the messages in the partially ordered message queue according to its own needs, and then obtains the required topic identifiers and the partition messages corresponding to each of the topic identifiers.
  • subscribing to the messages of the partially ordered message queue in step 401 to obtain multiple message topic identifiers and partition messages corresponding to each of the message topic identifiers may include the following Steps 501 to 503 are as follows:
  • the distributed message queue is kafka.
  • each message obtained by Kafka has a message topic.
  • the distributed messages are stored in partitions, and the messages stored in each partition are analyzed. Based on the analysis results, each message is determined.
  • the message topic identifier of the partition message is published, and the consumer subscribes to the message topic identifier of the partition message on demand to obtain the message topic identifier and the partition message corresponding to the message topic identifier.
  • multiple partitions are divided according to the message topic of the pre-released Kafka message.
  • a hash algorithm is performed on the partition key value in the obtained message to obtain the partition key value.
  • the message topic of the Kafka message released first is partitioned by the Kafka cluster, so that consumers can subscribe on demand according to the received message topic identifier, and obtain the message topic identifier and the partitioned message corresponding to each message topic identifier, to achieve Local ordering of messages.
  • the memory queue is a queue used to store messages and has the characteristics of first in, first out.
  • partition messages with the same key value are routed to a memory queue.
  • the key value in this embodiment is the message topic identifier. Therefore, the partitioned messages of a message topic are placed in a memory queue. Since the message topics of the partitioned messages stored in different locally ordered message queues may be the same, a memory queue Store at least one partition message in it, that is, a memory queue contains at least one partially ordered message queue, so that partition messages are subsequently taken out from each memory queue for consumption.
  • each key-value pair message queue can be expressed as: MAP ⁇ partitionKey, LinkedBlockingQueue>, where partitionKey is the topic identifier of the partition message, and LinkedBlockingQueue is the message queue.
  • the structure of the message queue is transformed through the underlying chain to obtain a key-value message queue that is convenient and fast on the chain. Then each memory queue message is consumed through the sub-thread to obtain a global ordered message queue and achieve a local orderly message queue.
  • the sequential message queue is transformed into a global ordered message queue, making the global chain orderly and ensuring the consistency of transactions.
  • the uplink data can be a structure.
  • the structure of the uplink data can be as follows:
  • txParam “chain”, “scene”, “funcParam”, “user”, “sk”, “certId”, “useCns”, “cnsName”, and “key” are all parameters in the blockchain. They are blockchain function, blockchain type, scenario, parameters, user, private key, certificate ID, smart contract, smart contract name, and smart contract version.
  • the scenario for uploading data to the blockchain in the blockchain system can be certificate storage, traceability, or digital collections.
  • the partition message is used as the uplink data, and based on the user ID and private key contained in each partition message, the uplink
  • the on-chain data is processed on the chain, which realizes the integration of the on-chain information of different business nodes. This can solve the technical problem of data incompatibility in various blockchains, and thus solve the transaction in the blockchain system to a certain extent. , maintenance and migration difficult technical issues.
  • the global orderliness of the on-chain data is guaranteed.
  • the uplink data can also be uploaded in the blockchain through synchronization.
  • the specific process is: send an upload request, determine whether the upload data reaches the upper limit, and if it reaches the upper limit, call the rollback. Functions, such as fallback.
  • the on-chain information includes the chain channel identifier and the smart contract version identifier of the blockchain to be on-chain, wherein, as shown in Figure 5, the global ordered message queue is placed in the global ordered message queue as described in step 305.
  • the chain channel identifier is a symbol used to uniquely identify the blockchain
  • the smart contract version identifier is a symbol used to uniquely identify the version of the smart contract.
  • each blockchain has a unique chain channel identifier.
  • the smart contract layer of the blockchain system there are multiple smart contracts, and each smart contract is based on specific The application needs to be upgraded. Before being uploaded to the chain, the smart contract version needs to be verified to ensure that the corresponding smart contract version meets the requirements.
  • determining the target blockchain of the on-chain data based on the chain channel identifier and the smart contract version identifier in step 601 may include the following steps 701- 703, the details are as follows:
  • target blockchain type identifier and the target smart contract search for the target blockchain in the preconfigured mapping table of the blockchain type identifier, target smart contract, and blockchain.
  • this embodiment uses smart contracts to locate the target blockchain and reduce the number of target blocks. The time overhead of chain positioning is conducive to improving the efficiency of chaining.
  • mapping table is pre-configured and is used to store the blockchain type identifier, the association information between the target smart contract and the blockchain.
  • the target smart contract used for the on-chain data is determined through the smart contract version identifier to ensure that the version of the smart contract used meets the blockchain requirements, and then the chain channel identifier and the smart contract version identifier are compared. Splicing, determine the target blockchain type identifier, and query in the pre-configured mapping table to locate the target blockchain, reducing the time spent on locating the target blockchain.
  • the target blockchain is quickly determined through the combination of the chain channel identifier and the smart contract version identifier, which is beneficial to improving the efficiency of querying and locating the target chain.
  • step 305 the partitioned messages with the same message topic in the global ordered message queue are used as uplink data, and on the blockchain system Chaining, or uploading the chained data in the target blockchain as described in step 602, may include the following steps 603 to 605, specifically as follows:
  • the blockchain network corresponds to the configuration data of the blockchain, including host cluster, certificate, consensus algorithm, type (bcos, fabric), etc.
  • the target blockchain can be determined according to the above method, or determined in the blockchain system through preset or other methods.
  • the target blockchain has a pre-configured blockchain network cache (network cache) through the underlying chain blockchain domain layer, where the underlying chain is a distributed database stored in the blockchain network. . If it exists, obtain the blockchain network corresponding to the target blockchain, and use the preset uploading method configured in the blockchain network to upload the uploading data. If it does not exist, obtain the blockchain network from the block chain. Query the configuration of the target blockchain in the database corresponding to the chain, instantiate the blockchain network (network) corresponding to the target blockchain, store it in the cache, and perform on-chain processing.
  • a pre-configured blockchain network cache network cache
  • the underlying chain is a distributed database stored in the blockchain network.
  • the pre-configured blockchain network cache includes the on-chain method of each blockchain corresponding to the blockchain network.
  • the target blockchain is quickly located through parameters such as the chain channel identifier and the smart contract version identifier included in the uplink information, and then it is checked whether the target blockchain exists in the pre-configured blockchain network. If it exists, Then the on-chain processing is performed through the on-chain method in the blockchain network. If it does not exist, the target blockchain is instantiated and then the on-chain processing is performed.
  • step 305 the partition messages with the same message topic in the global ordered message queue are used as uplink data, and in the blockchain system After being uploaded to the chain, the data integration method of the blockchain may also include the following steps 306 to 308, specifically as follows:
  • the preset configuration rules specifically include but are not limited to: regular expressions, field standardization, data cleaning, etc.
  • the on-chain data is standardized and then stored in a preset database to ensure the convenience of subsequent data query and use.
  • step 305 the partition messages with the same message topic in the global ordered message queue are used as uplink data, and in the blockchain system After being uploaded to the chain, the data integration method of the blockchain may also include the following steps 309 to 311, as follows:
  • the blockchain stores successfully uploaded data into the upload result table
  • the smart contract layer regularly stores the upload result table data into the database.
  • the database can be a redis database, hbase database, or mongodb. Database, clickhouse database or dorisdb database, etc.
  • the mongodb database is conducive to improving the persistent storage of on-chain data.
  • the clickhouse database and dorisdb database are conducive to improving the query and analysis performance of on-chain data, and then subsequent data comparison in the database Verification is helpful to improve the speed of data comparison and verification.
  • the uplink failed data is uplinked a second time. Ensure that all on-chain information is uploaded to the chain and improve the integrity of the on-chain data.
  • the embodiment of the present application also provides a data integration device of the blockchain, which is applied to the block chain.
  • the blockchain system includes a message middleware for transmitting messages, and the message middleware includes a distributed message queue for storing messages.
  • the blockchain data integration device 800 includes:
  • the acquisition module 801 is used to obtain the on-chain information of multiple business nodes in the blockchain system
  • Sending module 802 configured to send the uplink information to the distributed message queue of the message middleware
  • the analysis module 803 is used to analyze the messages in the distributed message queue to obtain a locally ordered message queue set of the uplink information.
  • the partially ordered message queue set includes multiple locally ordered message queues, Each of the locally ordered message queues stores a partition message, and each partition message corresponds to a message topic;
  • the integration module 804 is used to perform orderly consumption of the local ordered message queue set to obtain a global ordered message queue set.
  • the global ordered message queue set includes a plurality of globally ordered message queues marked with order, and each Each of the global ordered message queues stores partitioned messages with the same message topic;
  • the uplink module 805 is used to upload the partition messages with the same message topic in the global ordered message queue as uplink data in the blockchain system.
  • the uplink information is sent to the distributed message queue of the message middleware, and the messages in the distributed message queue are processed. Perform analysis to obtain multiple locally ordered message queue sets, perform orderly consumption on the locally ordered message queue sets, and obtain a global ordered message queue set, and combine the messages with the same message in the global ordered message queue.
  • the topic's partition message is used as on-chain data and is uploaded on the blockchain system, which realizes the integration of on-chain information of different business nodes. Since the global ordered message queue is orderly, it ensures the integrity of the on-chain data. Global orderliness on the chain.
  • the integration module 804 is specifically used to:
  • a preconfigured sub-thread is started to consume the memory queue message, and the global ordered message queue is generated.
  • the distributed message queue is kafka
  • the integration module 804 is specifically used to:
  • the uplinking information includes the chain channel identifier and the smart contract version identifier of the blockchain to be uplinked, wherein the uplinking module 805 is specifically used to:
  • the uploaded data is uploaded to the target blockchain.
  • the uplink module 805 is specifically used to:
  • target blockchain type identifier and the target smart contract search for the target blockchain in the preconfigured mapping table of the blockchain type identifier, target smart contract, and blockchain.
  • the uplink module 805 is specifically used to:
  • the blockchain data integration device further includes:
  • the analysis module is used to analyze the on-chain data after being uploaded through the blockchain network to obtain analytical business data;
  • a filling module used to fill in the parsed business data to obtain standardized business data
  • a writing module is used to write the standardized business data into a preset database.
  • the blockchain data integration device further includes:
  • the first acquisition module is used to obtain a pre-stored uplink result table, where the uplink result table includes data on successful uplink;
  • a comparison module used to compare and verify the uplink data with the successfully uplinked data in the uplink result table, obtain a comparison verification result, and determine whether there is uplink failure data based on the comparison verification result;
  • the secondary uplinking module is used to perform secondary uplinking on the uplinking failed data if the uplinking failed data exists.
  • An embodiment of the present application also provides a computer device that integrates any blockchain data integration device provided by the embodiment of the present application.
  • the computer device includes:
  • processors one or more processors
  • One or more application programs wherein the one or more application programs are stored in the memory and configured to be executed by the processor in any of the above-mentioned blockchain data integration method embodiments.
  • An embodiment of the present application also provides a computer device that integrates any blockchain data integration device provided by the embodiment of the present application. As shown in Figure 11, it shows a schematic structural diagram of the computer equipment involved in the embodiment of the present application. Specifically:
  • the computer device may include components such as a processor 901 of one or more processing cores, a memory 902 of one or more computer-readable storage media, a power supply 903, and an input unit 904.
  • a processor 901 of one or more processing cores a memory 902 of one or more computer-readable storage media
  • a power supply 903 a power supply 903
  • FIG. 11 does not constitute a limitation on the computer equipment, and may include more or fewer components than shown in the figure, or combine certain components, or arrange different components. in:
  • the processor 901 is the control center of the computer equipment, using various interfaces and lines to connect various parts of the entire computer equipment, by running or executing software programs and/or modules stored in the memory 902, and calling software programs stored in the memory 902. Data, perform various functions of the computer equipment and process the data to conduct overall monitoring of the computer equipment.
  • the processor 901 may include one or more processing cores; preferably, the processor 901 may integrate an application processor and a modem processor, where the application processor mainly processes operating systems, user interfaces, application programs, etc. , the modem processor mainly handles wireless communications. It can be understood that the above modem processor may not be integrated into the processor 901.
  • the memory 902 can be used to store software programs and modules.
  • the processor 901 executes various functional applications and data processing by running the software programs and modules stored in the memory 902 .
  • the memory 902 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the storage data area may store data based on Data created by the use of computer equipment, etc.
  • memory 902 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 902 may also include a memory controller to provide the processor 901 with access to the memory 902 .
  • the computer equipment also includes a power supply 903 that supplies power to various components.
  • the power supply 903 can be logically connected to the processor 901 through a power management system, so that functions such as charging, discharging, and power consumption management can be implemented through the power management system.
  • the power supply 903 may also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
  • the computer device may also include an input unit 904 operable to receive input numeric or character information and to generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and functional controls.
  • an input unit 904 operable to receive input numeric or character information and to generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and functional controls.
  • the computer device may also include a display unit and the like, which will not be described again here.
  • the processor 901 in the computer device will load the executable files corresponding to the processes of one or more application programs into the memory 902 according to the following instructions, and the processor 901 will run the executable files stored in The application program in the memory 902 implements various functions, as follows:
  • the messages in the distributed message queue are analyzed to obtain a locally ordered message queue set of the uplink information.
  • the locally ordered message queue set includes a plurality of locally ordered message queues, and each of the locally ordered message queues has The sequential message queue stores a partition message, and each partition message corresponds to a message topic;
  • the locally ordered message queue set is consumed in an orderly manner to obtain a globally ordered message queue set.
  • the global ordered message queue set includes a plurality of globally ordered message queues marked with order, and each of the globally ordered message queue sets is Message queue stores partitioned messages with the same message topic;
  • the partition messages with the same message topic in the global ordered message queue are used as on-chain data and are uploaded on the blockchain system.
  • embodiments of the present application provide a computer-readable storage medium, which may include: read-only memory (ROM, Read Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disk, etc. .
  • a computer program is stored thereon, and the computer program is loaded by the processor to execute the steps in any of the blockchain data integration methods provided by the embodiments of this application. For example, when the computer program is loaded by the processor, the following steps may be performed:
  • the messages in the distributed message queue are analyzed to obtain a locally ordered message queue set of the uplink information.
  • the locally ordered message queue set includes a plurality of locally ordered message queues, and each of the locally ordered message queues has The sequential message queue stores a partition message, and each partition message corresponds to a message topic;
  • the locally ordered message queue set is consumed in an orderly manner to obtain a globally ordered message queue set.
  • the global ordered message queue set includes a plurality of globally ordered message queues marked with order, and each of the globally ordered message queue sets is Message queue stores partitioned messages with the same message topic;
  • the partition messages with the same message topic in the global ordered message queue are used as on-chain data and are uploaded on the blockchain system.
  • each of the above units or structures can be implemented as an independent entity, or can be combined in any way and implemented as the same or several entities.
  • each of the above units or structures please refer to the previous method embodiments. Here No longer.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Computing Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

本申请公开了一种区块链的数据整合方法、装置、计算机设备及存储介质,该方法通过获取区块链***中多个业务节点的上链信息,将上链信息发送给所述区块链***对应的消息中间件的分布式消息队列中,对所述分布式消息队列中的消息进行分析,得到局部有序消息队列集合,对所述局部有序消息队列集合进行有序消费,得到全局有序消息队列集合,将所述全局有序消息队列中的所述具有相同消息主题的分区消息作为上链数据,在所述区块链***上链,实现了对不同业务节点的上链信息的整合,由于全局有序消息队列具备有序性,从而保障了上链数据的上链的全局有序性。

Description

区块链的数据整合方法、装置、计算机设备及存储介质 技术领域
本申请涉及数据处理领域,具体涉及一种区块链的数据整合方法、装置、计算机设备及存储介质。
发明背景
目前,市场上存在多种区块链技术架构,且各种区块链技术架构之下的数据访问API(Application Programming Interface,应用程序编程接口)各不相同,导致区块链的迁移、维护、使用繁琐,具体问题体现在三个方面,分别是:区块链的“孤岛”形式,对于技术同源的底层链,链上数据难以兼容;在跨链交易执行过程中,不同形式的接口、不同底层链之间的交易存在困难;区块链的变动,在某些场景下更换底层链技术路线后,业务层需要对应做大量改动。
综上,为了应对多种不同的区块链以及其所对应的不同数据结构导致的***维护困难、迁移困难,有必要提供一种针对多种区块链的底层统一的方案。
发明内容
本申请实施例提供一种区块链的数据整合方法、装置、计算机设备及存储介质,可以对不同业务节点的上链信息进行整合,以解决多种区块链中的数据不兼容的技术问题。
一方面,本申请提供一种区块链的数据整合方法,应用于区块链***,所述区块链***包括用于传输消息的消息中间件,所述消息中间件包括用于存储消息的分布式消息队列,所述区块链的数据整合方法包括:
获取区块链***中多个业务节点的上链信息;
将所述上链信息发送给所述消息中间件的分布式消息队列中;
对所述分布式消息队列中的消息进行分析,得到所述上链信息的局部有序消息队列集合,所述局部有序消息队列集合包括多个局部有序消息队列,每个所述局部有序消息队列存储一个分区消息,每个分区消息对应一个消息主题;
对所述局部有序消息队列集合进行有序消费,得到全局有序消息队列集合,所述全局有序消息队列集合包括多个标记有顺序的全局有序消息队列,每个所述全局有序消息队列存储具有相同消息主题的分区消息;
将所述全局有序消息队列中的所述具有相同消息主题的分区消息作为上链数据,在所述区块链***上链。
在本申请一些实施方案中,所述对所述局部有序消息队列集合进行有序消费,得到全局有序消息队列集合,包括:
订阅所述局部有序消息队列的消息,得到多个消息主题标识及各个所述消息主题标识对应的分区消息;
将所述消息主题标识作为键、所述消息主题标识对应的分区消息作为值,得到多个键值对消息队列;
获取预先创建的用于消费所述分布式消息队列中消息的多个内存队列,并将所述多个键值对消息队列中,相同键值的分区消息路由至一个所述内存队列,生成多个内存队列消息;
针对每个所述内存队列消息,分别开启预先配置的子线程对所述内存队列消息进行消费,生成所述全局有序消息队列。
在本申请一些实施方案中,所述分布式消息队列为kafka,所述订阅所述局部有序消息队列的消息,得到多个消息主题标识及各个所述消息主题标识对应的分区消息,包括:
获取预先发布的kafka消息的消息主题;
根据所述消息主题,对所述局部有序消息队列中的各个分区消息进行分析,确定各个所述分区消息的消息主题标识;
订阅各个所述分区消息的主题标识,得到所述多个主题标识及各个所述主题标识对应的所述分区消息。
在本申请一些实施方案中,所述上链信息包括待上链的区块链的链通道标识和智能合约版本标识,其中,
所述将所述全局有序消息队列中的所述具有相同消息主题的分区消息作为上链数据,在所述区块链***上链,包括:
根据所述链通道标识和所述智能合约版本标识,确定所述上链数据的目标区块链;
将所述上链数据在所述目标区块链中进行上链。
在本申请一些实施方案中,所述根据所述链通道标识和所述智能合约版本标识,确定所述上链数据的目标区块链,包括:
根据所述智能合约版本标识确定所述上链数据所采用的目标智能合约;
将所述链通道标识与所述智能合约版本标识进行拼接,得到目标区块链类型标识;
根据所述目标区块链类型标识及所述目标智能合约,在预先配置的区块链类型标识、目标智能合约与区块链的映射表中,查找所述目标区块链。
在本申请一些实施方案中,所述将所述上链数据在所述目标区块链中进行上链,包括:
检测所述目标区块链是否存在预先配置的区块链网络;
若存在,则获取所述目标区块链对应的区块链网络,并利用所述区块链网络中配置的预设上链方法对所述上链数据进行上链;
若不存在,则根据所述链通道标识对应的链通道配置实例化区块链网络,并利用实例化的区块链网络中配置的上链方法对所述上链数据进行上链。
在本申请一些实施方案中,在所述将所述全局有序消息队列中的所述具有相同消息主题的分区消息作为上链数据,在所述区块链***上链之后,该区块链的数据整合方法还包括:
通过区块链网络对上链后的上链数据进行解析,得到解析业务数据;
对所述解析业务数据进行填充,得到标准化业务数据;
将所述标准化业务数据写入预设数据库。
在本申请一些实施方案中,在所述将所述全局有序消息队列中的所述具有相同消息主题的分区消息作为上链数据,在所述区块链***上链之后,该区块链的数据整合方法还包括:
获取预先存储的上链结果表,所述上链结果表中包括上链成功的数据;
将所述上链数据与所述上链结果表中上链成功的数据进行对比校验,得到对比校验结果,并根据对比校验结果,确定是否存在上链失败数据;
若存在所述上链失败数据,则对所述上链失败数据进行二次上链。
另一方面,本申请提供一种区块链的数据整合装置,应用于区块链***,所述区块链***包括用于传输消息的消息中间件,所述消息中间件包括用于存储消息的分布式消息队列,所述区块链的数据整合装置包括:
获取模块,用于获取区块链***中多个业务节点的上链信息;
发送模块,用于将所述上链信息发送给所述消息中间件的分布式消息队列中;
分析模块,用于对所述分布式消息队列中的消息进行分析,得到所述上链信息的局部有序消息队列集合,所述局部有序消息队列集合包括多个局部有序消息队列,每个所述局部有序消息队列存储一个分区消息,每个分区消息对应一个消息主题;
整合模块,用于对所述局部有序消息队列集合进行有序消费,得到全局有序消息队列集合,所述全局有序消息队列集合包括多个标记有顺序的全局有序消息队列,每个所述全局有序消息队列存储具有相同消息主题的分区消息;
上链模块,用于将所述全局有序消息队列中的所述具有相同消息主题的分区消息作为上链数据,在所述区块链***上链。
在本申请一些实施方案中,所述整合模块具体用于:
订阅所述局部有序消息队列的消息,得到多个消息主题标识及各个所述消息主题标识对应的分区消息;
将所述消息主题标识作为键、所述消息主题标识对应的分区消息作为值,得到多个键值对消息队列;
获取预先创建的用于消费所述分布式消息队列中消息的多个内存队列,并将所述多个键值对消息队列中,相同键值的分区消息路由至一个所述内存队列,生成多个内存队列消息;
针对每个所述内存队列消息,分别开启预先配置的子线程对所述内存队列消息进行消费,生成所述全局有序消息队列。
在本申请一些实施方案中,所述分布式消息队列为kafka,所述整合模块具体用于:
获取预先发布的kafka消息的消息主题;
根据所述消息主题,对所述局部有序消息队列中的各个分区消息进行分析,确定各个所述分区消息的消息主题标识;
订阅各个所述分区消息的消息主题标识,得到所述多个消息主题标识及各个所述消息主题标识对应的所述分区消息。
在本申请一些实施方案中,所述上链信息包括待上链的区块链的链通道标识和智能合约版本标识,其中,所述上链模块具体用于:
根据所述链通道标识和所述智能合约版本标识,确定所述上链数据的目标区块链;
将所述上链数据在所述目标区块链中进行上链。
在本申请一些实施方案中,所述上链模块具体用于:
根据所述智能合约版本标识确定所述上链数据所采用的目标智能合约;
将所述链通道标识与所述智能合约版本标识进行拼接,得到目标区块链类型标识;
根据所述目标区块链类型标识及所述目标智能合约,在预先配置的区块链类型标识、目标智能合约与区块链的映射表中,查找所述目标区块链。
在本申请一些实施方案中,所述上链模块具体用于:
检测所述目标区块链是否存在预先配置的区块链网络;
若存在,则获取所述目标区块链对应的区块链网络,并利用所述区块链网络中配置的预设上链方法对所述上链数据进行上链;
若不存在,则根据所述链通道标识对应的链通道配置实例化区块链网络,并利用实例化的区块链网络中配置的上链方法对所述上链数据进行上链。
在本申请一些实施方案中,该区块链的数据整合装置还包括:
解析模块,用于通过区块链网络对上链后的上链数据进行解析,得到解析业务数据;
填充模块,用于对所述解析业务数据进行填充,得到标准化业务数据;
写入模块,用于将所述标准化业务数据写入预设数据库。
在本申请一些实施方案中,该区块链的数据整合装置还包括:
第一获取模块,用于获取预先存储的上链结果表,所述上链结果表中包括上链成功的数据;
对比模块,用于将所述上链数据与所述上链结果表中上链成功的数据进行对比校验,得到对比校验结果,并根据对比校验结果,确定是否存在上链失败数据;
二次上链模块,用于若存在所述上链失败数据,则对所述上链失败数据进行二次上链。
另一方面,本申请还提供一种计算机设备,所述计算机设备包括:
一个或多个处理器;以及
存储器,其中,所述存储器中存储有一个或多个应用程序,所述一个或多个应用程序被配置为由所述处理器执行以实现第一方面中任一项所述的区块链的数据整合方法。
第四方面,本申请还提供一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器进行加载,以执行第一方面任一项所述的区块链的数据整合方法中的步骤。
本申请通过获取区块链***中多个业务节点的上链信息,将上链信息发送给所述消息中间件的分布式消息队列中,对所述分布式消息队列中的消息进行分析,得到局部有序消息队列集合,对所述局部有序消息队列集合进行有序消费,得到全局有序消息队列集合,将所述全局有序消息队列中的所述具有相同消息主题的分区消息作为上链数据,在所述区块链***上链,实现了对不同业务节点的上链信息的整合,由于全局有序消息队列具备有序性,从而保障了上链数据的上链的全局有序性。
附图简要说明
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1是本申请一实施例提供的区块链的数据整合装置的场景示意图。
图2是本申请一实施例提供的区块链的数据整合方法的流程示意图。
图3是本申请一实施例提供的步骤304的流程示意图。
图4是本申请一实施例提供的步骤401的流程示意图。
图5是本申请一实施例提供的步骤305的流程示意图。
图6是本申请一实施例提供的步骤601的流程示意图。
图7是本申请一实施例提供的步骤305或步骤602的流程示意图。
图8是本申请另一实施例提供的区块链的数据整合方法的流程示意图。
图9是本申请另一实施例提供的区块链的数据整合方法的流程示意图。
图10是本申请一实施例提供的区块链的数据整合装置的结构示意图。
图11是本申请一实施例提供的计算机设备的结构示意图。
实施本发明的方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
在本申请中,“示例性”一词用来表示“用作例子、例证或说明”。本申请中被描述为“示例性”的任何实施例不一定被解释为比其它实施例更优选或更具优势。为了使本领域任何技术人员能够实现和使用本申请,给出了以下描述。在以下描述中,为了解释的目的而列出了细节。应当明白的是,本领域普通技术人员可以认识到,在不使用这些特定细节的情况下也可以实现本申请。在其它实例中,不会对公知的结构和过程进行详细阐述,以避免不必要的细节使本申请的描述变得晦涩。因此,本申请并非旨在限于所示的实施例,而是与符合本申请所公开的原理和特征的最广范围相一致。
需要说明的是,本申请实施例方法由于是在计算机设备中执行,各计算机设备的处理对象均以数据或信息的形式存在,例如时间,实质为时间信息,可以理解的是,后续实施例中若提及尺寸、数量、位置等,均为对应的数据存在,以便计算机设备进行处理,具体此处不作赘述。
本申请实施例提供一种区块链的数据整合方法、装置、计算机设备及存储介质,以下分别进行详细说明。
请参阅图1,图1为本申请一实施例所提供的区块链的数据整合装置的场景示意图,该区块链的数据整合装置可以包括计算机设备100,或者,计算机设备100中集成有区块链的数据整合装置,如图1中的计算机设备。
区块链的数据整合方法可应用于区块链***,区块链***包括用于传输消息的消息中间件,消息中间件包括用于存储消息的分布式消息队列。
本申请实施例中计算机设备100主要用于:获取区块链***中多个业务节点的上链信息;将所述上链信息发送给所述消息中间件的分布式消息队列中,所述消息中间件用于传输所述区块链***中的消息;对所述分布式消息队列中的消息进行分析,得到所述上链信息的局部有序消息队列集合,所述局部有序消息队列集合包括多个局部有序消息队列,每个所述局部有序消息队列存储一个分区消息,每个分区消息对应一个消息主题;对所述局部有序消息队列集合进行有序消费,得到全局有序消息队列集合,所述全局有序消息队列集合包括多个标记有顺序的全局有序消息队列,每个所述全局有序消息队列存储具有相同消息主题的分区消息;将所述全局有序消息队列中的所述具有相同消息主题的分区消息作为上链数据,在所述区块链***上链。计算机设备100在处理各个业务节点的上链信息时,实现了对不同业务节点的上链信息的整合,由于全局有序消息队列具备有序性,从而保障了上链数据的上链的全局有序性。
本申请实施例中,该计算机设备100可以是独立的服务器,也可以是服务器组成的服务器网络或服务器集群,例如,本申请实施例中所描述的计算机设备100,其包括但不限于计算机、网络主机、单个网络服务器、多个网络服务器集或多个服务器构成的云服务器。其中,云服务器由基于云计算(Cloud Computing)的大量计算机或网络服务器构成。
计算机设备100也可以称为终端。可以理解的是,本申请实施例中所使用的终端100可以是既包括接收和发射硬件的设备,即具有能够在双向通信链路上,执行双向通信的接收和发射硬件的设备。这种设备可以包括:蜂窝或其他通信设备,其具有单线路显示器或多线路显示器或没有多线路显示器的蜂窝或其他通信设备。在一些实施例中,终端100具体可以是台式终端或移动终端,终端100具体还可以是手机、平板电脑、笔记本电脑等中的一种。
本领域技术人员可以理解,图1中示出的应用环境,仅仅是本申请方案的一种应用场景,并不构成对本申请方案应用场景的限定,其他的应用环境还可以包括比图1中所示更多或更少的计算机设备,例如图1中仅示出1个计算机设备,可以理解的,该区块链的数据整合装置还可以包括一个或多个其他服务,具体此处不作限定。
另外,如图1所示,该区块链的数据整合装置还可以包括存储器200,用于存储不同业务节点的上链信息,如交易信息,例如数字藏品的各种交易信息,具体的,如数字藏品的归属信息,数字藏品的准转移信息等。
需要说明的是,图1所示的区块链的数据整合装置的场景示意图仅仅是一个示例,本申请实施例描述的区块链的数据整合装置以及场景是为了更加清楚的说明本申请实施例的技术方案,并不构成对于本申请实施例提供的技术方案的限定,本领域普通技术人员可知,随着区块链的数据整合装置的演变和新业务场景的出现,本申请实施例提供的技术方案对于类似的技术问题,同样适用。
首先,本申请实施例中提供一种区块链的数据整合方法,该区块链的数据整合方法的执行主体为区块链的数据整合装置,该区块链的数据整合装置应用于计算机设备。该区块链的数据整合方法包括:获取区块链***中多个业务节点的上链信息;将所述上链信息发送给所述消息中间件的分布式消息队列中;对所述分布式消息队列中的消息进行分析,得到所述上链信息的局部有序消息队列集合,所述局部有序消息队列集合包括多个局部有序消息队列,每个所述局部有序消息队列存储一个分区消息,每个分区消息对应一个消息主题;对所述局部有序消息队列集合进行有序消费,得到全局有序消息队列集合,所述全局有序消息队列集 合包括多个标记有顺序的全局有序消息队列,每个所述全局有序消息队列存储具有相同消息主题的分区消息;将所述全局有序消息队列中的所述具有相同消息主题的分区消息作为上链数据,在所述区块链***上链。
图2所示为本申请一实施例提供的区块链的数据整合方法的流程示意图,该区块链的数据整合方法可以包括如下步骤301~305。
301、获取区块链***中多个业务节点的上链信息。
区块链***是指包含有多种不同数据结构的区块链组成的***,其中的至少两个具有不同数据结构的区块链构成为异构区块链。示例性地,区块链A的数据结构的结构体为{did,blockhash、funcParam(Json)},其中的did,blockhash、funcParam(Json)分别表示为分布式数字身份标识、块哈希、Json格式的传参;区块链B的数据结构的结构体为{txhash、blockheight},其中的txhash、blockheight分别表示为当前哈希、区块高度。区块链A与区块链B的数据结构的结构体不同,即区块链A与区块链B的数据结构不同,也即区块链A与区块链B组合为异构区块链。
一个区块链具有一种数据结构,其中的数据结构包括数据的参数类型、数据构建方式和参数属性等信息,异构区块链中的不同数据结构的数据,被称为异构数据,也即异构区块链中存在较多的异构数据,而异构数据在进行数据共享/存储过程中,需要进行数据转化,在异构数据较多时,会导致上链效率降低。
上链信息是指一个业务节点中,与进行数据上链相关的信息,包括多个业务节点各自上传的待上链数据、业务节点在区块链***上的用户标识及私钥。该用户标识和私钥用于在上链时进行身份确权验证,待上链数据是指需要在区块链进行上链的数据。不同业务节点上的待上链数据由于针对的是不同的业务,因此,各自的待上链数据为异构数据,即数据结构、类型必然不同。
其中,业务节点是指区块链技术架构中应用链对应的应用的节点,在区块链技术架构中,存在多种应用链,每种应用链对应的区块链类型、智能合约类型及数据结构不尽相同,示例性地,区块链类型根据技术实现可以分为evm、fisco bcos或hyperledger fabric等。
在一个具体实施方式中,可以在区块链***中的业务节点上预先配置业务层、场景层和接入层,业务层为外部需要调用区块链服务的服务,场景层用于提供针对不同区块链智能合约类型的对应场景服务,接入层用于对场景层以及对外提供sdk、restful接口方式及同步上链服务、异步上链服务。在业务层生成上链需求时,将待上链数据提供给场景层。场景层获取用户标识和私钥,并将用户标识、私钥和待上链数据打包为上链信息,提交到接入层,且不同场景层提交的上链信息中的待上链数据,调用不同智能合约的参数封装,其中的参数包括区块链的类型和相应类型的区块链上的智能合约版本。
302、将所述上链信息发送给所述消息中间件的分布式消息队列中。
其中,消息中间件是在分布式***中完成消息的发送和接收的基础组件,通过高效可靠的消息传递机制进行消息的传输,该消息中间件包括但不限于是ActiveMQ,RabbitMQ,ZeroMQ,Kafka,MetaMQ或RocketMQ等。分布式消息队列是消息中间件中用于保存消息的容器。
在本申请实施例中,通过消息中间件传输上链信息后,上链信息存储在分布式消息队列中,实现对海量数据消息进行快速筛选分析,提高消息传输效率、吞吐量和处理性能,还有利于提高后续数据上链的效率。
303、对所述分布式消息队列中的消息进行分析,得到所述上链信息的局部有序消息队列集合,所述局部有序消息队列集合包括多个局部有序消息队列,每个所述局部有序消息队列存储一个分区消息,每个分区消息对应一个消息主题。
其中,局部有序消息队列是指能够保证存储在同一分区(partition)内的消息有序的消息队列,即一个分区消息存放于一个局部有序消息队列,可以将分布式消息队列中的消息的内 容划分成需要的分区数,把消息通过分区策略路由至固定的分区中,实现各个固定分区中的消息有序。
分区消息是指存储在一个分区中的上链信息,可以理解地,由步骤301可知,上链信息由用户标识、私钥和待上链数据打包得到,由于分区消息是对上链信息进行分布式消息处理后得到的,因此,分区消息中包含有用户标识和私钥。
具体地,区块链***对存储于分布式消息队列中的消息进行分析。优选地,本实施例采用分布式发布订阅消息***Kafka对分布式消息队列中的消息进行分析,Kafka通过磁盘数据结构提供消息的持久化,这种结构对于TB数量级的消息存储也能够保持长时间的稳定性能,能够处理各个应用链中不同业务节点的所有动作流数据。本实施例中,动作流数据具体可以是业务节点在进行数据上链过程中产生的各种数据。更具体地,Kafka集群获取到的每条消息都有一个消息主题,这个类别被称为Topic。不同Topic的消息分区存储,每个分区的存储位置可以根据需求进行自定义并记录在Offset中,消费者只需指定消息的Topic即可获取数据而不必关心数据具体存储在哪个地方。因此,为了实现局部有序,在kafka集群中的生产者发送消息时,指定分区键值(partition key),则根据分区键值的哈希(hash)值与分区数,进行运算后确定发送到哪个分区(partition),如此,分区键值相同的消息会放在同一个分区。每个分区内,每条消息都有Offset,保证同一分区内有序,也即局部有序,其中的Offset为存储位置的索引序列,Offset包括但不限于:Offset编号、消息类别、分布式服务器IP地址、存储位置和消息时间。且分区数量可以设置多个,以提升Topic的整体吞吐量。
需要说明的是,由于Kafka采用解耦的设计思想,并非原始的发布订阅,生产者把数据推送给每个Topic,消费者从Topic中获取数据,这种方式具有如下优势:
a)生产者的负载与消费者的负载解耦;
b)消费者按照自己的需要获取数据,避免了消费者集群中产生大量没必要的垃圾数据。其中,获取数据使用Fetch方法,Fetch方法提供了获取资源数据的API接口和更强大更灵活的功能集,消费者可以根据自己的能力来获取接口,不受生产者的服务器限制;
c)消费者可以自定义消费的数量。
可以理解地,由于这些优势,使得Kafka能够实时获取并存储对所有待上链信息进行快速分析,得到多个上链信息的局部有序消息队列,每个局部有序消息队列存储一个分区消息。
值得说明的是,针对每个分区,通过一个单线程处理的消费者,在实现部分有序的前提条件下,通过分区数量的并发来提高消息处理效率。
304、对所述局部有序消息队列集合进行有序消费,得到全局有序消息队列集合,所述全局有序消息队列集合包括多个标记有顺序的全局有序消息队列,每个所述全局有序消息队列存储具有相同消息主题的分区消息。
在一具体实施方式中,如图3所示,步骤304中所述对所述局部有序消息队列集合进行有序消费,得到全局有序消息队列集合,所述全局有序消息队列集合包括多个标记有顺序的全局有序消息队列,每个所述全局有序消息队列存储具有相同消息主题的分区消息,可以包括如下步骤401~404,具体如下:
401、订阅所述局部有序消息队列的消息,得到多个消息主题标识及各个所述消息主题标识对应的分区消息。
具体地,在得到局部有序消息队列后,消费者根据自身所需,订阅局部有序消息队列的消息,进而获取所需的各个主题标识及各个所述主题标识对应的分区消息。
在一具体实施方式中,如图4所示,步骤401中所述订阅所述局部有序消息队列的消息,得到多个消息主题标识及各个所述消息主题标识对应的分区消息,可以包括如下步骤501~503,具体如下:
501、获取预先发布的kafka消息的消息主题;
502、根据所述消息主题,对所述局部有序消息队列中的各个分区消息进行分析,确定各个所述分区消息的消息主题标识;
503、订阅各个所述分区消息的消息主题标识,得到所述多个消息主题标识及各个所述消息主题标识对应的所述分区消息。
分布式消息队列为kafka。
具体地,Kafka获取到的每条消息都有一个消息主题,根据预先发布的消息主题,对分布式的消息进行分区存储,并对每个分区存储的消息进行分析,根据分析结果,确定每个分区消息的消息主题标识,并对消息主题标识进行发布,消费者按需订阅分区消息的消息主题标识,得到消息主题标识及消息主题标识对应的分区消息。
在一个具体实施方式中,根据预先发布的kafka消息的消息主题划分多个分区,得到分区总数M后,对获取到的消息中的分区键值进行哈希(hash)算法,得到分区键值的哈希值N,则分区键值对应的分区序号可以采用哈希值取余运算,即分区序号P=N%M,将同一分区键值计算的P值发送到对应的第P个分区中,得到各个消息主题标识的分区消息。
本实施例中,通过先发布的kafka消息的消息主题和Kafka集群进行分区,使得消费者根据接收到的消息主题标识进行按需订阅,得到消息主题标识及各个消息主题标识对应的分区消息,实现消息的局部有序化。
402、将所述消息主题标识作为键、所述消息主题标识对应的分区消息作为值,得到多个键值对消息队列。
403、获取预先创建的用于消费所述分布式消息队列中消息的多个内存队列,并将所述多个键值对消息队列中,相同键值的分区消息路由至一个所述内存队列,生成多个内存队列消息。
404、针对每个所述内存队列消息,分别开启预先配置的子线程对所述内存队列消息进行消费,生成所述全局有序消息队列。
其中,内存队列是用于存放消息的队列,具有先进先出的特点。本实施例中,相同键值的分区消息路由到一个内存队列。本实施例中的键值为消息主题标识,因此,一个消息主题的分区消息放到一个内存队列,由于不同的局部有序消息队列中存储的分区消息的消息主题可能相同,因此,一个内存队列中存放至少一个分区消息,也即一个内存队列包含至少一个局部有序消息队列,从而后续从每个内存队列中取出分区消息进行消费。
具体地,区块链的底层链将订阅的每个kafka数据转化为键值对,得到多个键值对消息队列,在一具体实施方式中,每个键值对消息队列可以表示为:MAP<partitionKey,LinkedBlockingQueue>,其中,partitionKey为分区消息的主题标识,LinkedBlockingQueue为消息队列。
进一步地,获取预先创建的用于消费所述分布式消息队列中消息的多个内存队列,并将所述键值对消息队列中,相同键值的所述分区消息路由至一个所述内存队列,生成多个内存队列消息,再采用针对每个所述内存队列消息,分别开启预先配置的子线程对所述内存队列消息进行消费,生成所述全局有序消息队列。
本实施例中,通过底层链对消息队列进行结构转化,得到上链便捷快速的键值对消息队列,进而通过子线程对每个内存队列消息进行消费,得到全局有序消息队列,实现局部有序消息队列转化为全局有序消息队列,使得全局上链具备有序性,确保事务的一致性。
305、将所述全局有序消息队列中的所述具有相同消息主题的分区消息作为上链数据,在所述区块链***上链。
其中,上链数据可以是一种结构体,示例性地,上链数据的结构可以如下:

其中的"txParam"、"chain"、"scene"、"funcParam"、"user"、"sk"、"certId"、"useCns"、"cnsName"、"key"均为区块链中的参数,分别为区块链函数、区块链类型、场景、传参、用户、私钥、证书ID、智能合约、智能合约名称、智能合约版本。上链数据在区块链***中上链场景可以是存证、溯源或数字藏品等。
具体地,在确定全局有序消息队列中的所述具有相同消息主题的分区消息后,将该分区消息作为上链数据,并基于每个分区消息中包含的用户标识和私钥,对该上链数据进行上链处理,实现了对不同业务节点的上链信息的整合,如此可解决多种区块链中的数据不兼容的技术问题,进而可在一定程度上解决区块链***中交易、维护和迁移困难的技术问题。此外,由于全局有序消息队列具备有序性,从而保障了上链数据的上链的全局有序性。
值得说明的是,对上链数据在区块链中进行上链还可以是通过同步方式,其具体过程为:发送上链请求,判断上链数据是否达到上限,如果达到上限,则调用回退函数,如fallback。
在一具体实施方式中,上链信息包括待上链的区块链的链通道标识和智能合约版本标识,其中,如图5所示,步骤305中所述将所述全局有序消息队列中的所述具有相同消息主题的分区消息作为上链数据,在所述区块链***上链,可以包括如下步骤601~602,具体如下:
601、根据所述链通道标识和所述智能合约版本标识,确定所述上链数据的目标区块链。
其中,链通道标识是用于唯一标识区块链的符号,智能合约版本标识是用于对智能合约的版本进行唯一标识的符号。在区块链***中,包含多个区块链,每个区块链具有唯一的链通道标识,同时,在区块链***的智能合约层,具有多个智能合约,每个智能合约根据具体应用需要进行版本升级,在进行上链之前,需要对智能合约的版本进行验证,确保对应的智能合约版本为符合要求的智能合约版本。
在一具体实施方式中,如图6所示,步骤601中所述根据所述链通道标识和所述智能合约版本标识,确定所述上链数据的目标区块链,可以包括如下步骤701~703,具体如下:
701、根据所述智能合约版本标识确定所述上链数据所采用的目标智能合约;
702、将所述链通道标识与所述智能合约版本标识进行拼接,得到目标区块链类型标识;
703、根据所述目标区块链类型标识及所述目标智能合约,在预先配置的区块链类型标识、目标智能合约与区块链的映射表中,查找所述目标区块链。
具体地,本实施例中存在多个应用链,不同应用链对应不同的业务需求,采用不同的智能合约,为提高上链效率,本实施例通过智能合约定位目标区块链,减少目标区块链定位的时间开销,有利于提高上链的效率。
其中,映射表为预先配置,用于存储区块链类型标识、目标智能合约与区块链的关联信息。
本实施例中,通过智能合约版本标识确定所述上链数据所采用的目标智能合约,确保所采用的智能合约的版本符合区块链要求,进而对链通道标识与所述智能合约版本标识进行拼接,确定目标区块链类型标识,并在预先配置的映射表中进行查询,定位目标区块链,减少目标区块链定位时间开销。
本实施例中,通过链通道标识和智能合约版本标识的组合方式,快速确定目标区块链,有利于提高查询定位目标链的效率。
602、将所述上链数据在所述目标区块链中进行上链。
在一具体实施方式中,如图7所示,步骤305中所述将所述全局有序消息队列中的所述具有相同消息主题的分区消息作为上链数据,在所述区块链***上链,或,步骤602中所述将所述上链数据在所述目标区块链中进行上链,可以包括如下步骤603~605,具体如下:
603、检测目标区块链是否存在预先配置的区块链网络;
604、若存在,则获取所述目标区块链对应的区块链网络,并利用所述区块链网络中配置的预设上链方法对所述上链数据进行上链;
605、若不存在,则根据所述链通道标识对应的链通道配置实例化区块链网络,并利用实例化的区块链网络中配置的上链方法对所述上链数据进行上链。
其中,区块链网络(network)其对应的是区块链的配置数据,包括主机集群、证书、共识算法、类型(bcos、fabric)等。
目标区块链可以根据上述方法确定,或者通过预先设置或其他方法在区块链***中确定。
具体地,可以通过底层链blockchain领域层查询目标区块链是否存在预先配置的区块链网络缓存(network缓存),其中的底层链是一种存储在区块链网络中的分布式的资料库。若存在,则获取目标区块链对应的区块链网络,并利用所述区块链网络中配置的预设上链方法对所述上链数据进行上链,若不存在,则从区块链对应的数据库中查询目标区块链的配置,并实例化目标区块链对应的区块链网络(network)存入缓存,并执行上链处理。
需要说明的是,在预先配置的区块链网络缓存中,包括区块链网络对应的每个区块链的上链方法。
本实施例中,通过上链信息中包含的链通道标识和智能合约版本标识等参数进行目标区块链快速定位,进而检查预先配置的区块链网络中是否存在目标区块链,若存在,则通过区块链网络中的上链方法执行上链处理,若不存在,则对目标区块链进行实例化,进而执行上链处理。
在一具体实施方式中,如图8所示,在步骤305中所述将所述全局有序消息队列中的所述具有相同消息主题的分区消息作为上链数据,在所述区块链***上链之后,该区块链的数据整合方法还可以包括如下步骤306~308,具体如下:
306、通过区块链网络对上链后的上链数据进行解析,得到解析业务数据;
307、对所述解析业务数据进行填充,得到标准化业务数据;
308、将所述标准化业务数据写入预设数据库。
其中,预设配置规则具体包括但不限于:正则表达式、字段标准化、数据清洗等。
本实施例中,通过对上链数据进行标准化,再存入预设数据库,确保后续数据查询使用的便捷性。
在一具体实施方式中,如图9所示,在步骤305中所述将所述全局有序消息队列中的所述具有相同消息主题的分区消息作为上链数据,在所述区块链***上链之后,该区块链的数据整合方法还可以包括如下步骤309~311,具体如下:
309、获取预先存储的上链结果表,所述上链结果表中包括上链成功的数据;
310、将所述上链数据与所述上链结果表中上链成功的数据进行对比校验,得到对比校验结果,并根据对比校验结果,确定是否存在上链失败数据;
311、若存在所述上链失败数据,则对所述上链失败数据进行二次上链。
需要说明的是,区块链将上链成功的数据存入上链结果表,智能合约层定时将上链结果表数据存入数据库中,示例性地,数据库可以是redis数据库、hbase数据库、mongodb数据库、clickhouse数据库或dorisdb数据库等,其中的mongodb数据库有利于提高对上链数据的持久化存储,clickhouse数据库和dorisdb数据库有利于提高对上链数据的查询和分析性能,进而后续在数据库进行数据对比校验,有利于提高数据比对校验的速度。
本实施例中,通过对上链数据与上链成功的数据进行对比校验,根据对比校验结果,确定是否存在上链失败数据,若存在,则对上链失败数据进行二次上链,确保上链信息全部实现上链,提高上链数据的完整性。
为了更好实现本申请实施例中区块链的数据整合方法,在区块链的数据整合方法基础之上,本申请实施例中还提供一种区块链的数据整合装置,应用于区块链***,所述区块链***包括用于传输消息的消息中间件,所述消息中间件包括用于存储消息的分布式消息队列。如图10所示,所述区块链的数据整合装置800包括:
获取模块801,用于获取区块链***中多个业务节点的上链信息;
发送模块802,用于将所述上链信息发送给所述消息中间件的分布式消息队列中;
分析模块803,用于对所述分布式消息队列中的消息进行分析,得到所述上链信息的局部有序消息队列集合,所述局部有序消息队列集合包括多个局部有序消息队列,每个所述局部有序消息队列存储一个分区消息,每个分区消息对应一个消息主题;
整合模块804,用于对所述局部有序消息队列集合进行有序消费,得到全局有序消息队列集合,所述全局有序消息队列集合包括多个标记有顺序的全局有序消息队列,每个所述全局有序消息队列存储具有相同消息主题的分区消息;
上链模块805,用于将所述全局有序消息队列中的所述具有相同消息主题的分区消息作为上链数据,在所述区块链***上链。
本申请实施例中,通过获取区块链***中多个业务节点的上链信息,将上链信息发送给所述消息中间件的分布式消息队列中,对所述分布式消息队列中的消息进行分析,得到多个局部有序消息队列集合,对所述局部有序消息队列集合进行有序消费,得到全局有序消息队列集合,将所述全局有序消息队列中的所述具有相同消息主题的分区消息作为上链数据,在所述区块链***上链,实现了对不同业务节点的上链信息的整合,由于全局有序消息队列具备有序性,从而保障了上链数据的上链的全局有序性。
在本申请一些实施例中,所述整合模块804具体用于:
订阅所述局部有序消息队列的消息,得到多个消息主题标识及各个所述消息主题标识对应的分区消息;
将所述消息主题标识作为键、所述消息主题标识对应的分区消息作为值,得到多个键值对消息队列;
获取预先创建的用于消费所述分布式消息队列中消息的多个内存队列,并将所述多个键值对消息队列中,相同键值的分区消息路由至一个所述内存队列,生成多个内存队列消息;
针对每个所述内存队列消息,分别开启预先配置的子线程对所述内存队列消息进行消费,生成所述全局有序消息队列。
在本申请一些实施例中,所述分布式消息队列为kafka,所述整合模块804具体用于:
获取预先发布的kafka消息的消息主题;
根据所述消息主题,对所述局部有序消息队列中的各个分区消息进行分析,确定各个所述分区消息的消息主题标识;
订阅各个所述分区消息的消息主题标识,得到所述多个消息主题标识及各个所述消息主题标识对应的所述分区消息。
在本申请一些实施例中,所述上链信息包括待上链的区块链的链通道标识和智能合约版本标识,其中,所述上链模块805具体用于:
根据所述链通道标识和所述智能合约版本标识,确定所述上链数据的目标区块链;
将所述上链数据在所述目标区块链中进行上链。
在本申请一些实施例中,所述上链模块805具体用于:
根据所述智能合约版本标识确定所述上链数据所采用的目标智能合约;
将所述链通道标识与所述智能合约版本标识进行拼接,得到目标区块链类型标识;
根据所述目标区块链类型标识及所述目标智能合约,在预先配置的区块链类型标识、目标智能合约与区块链的映射表中,查找所述目标区块链。
在本申请一些实施例中,所述上链模块805具体用于:
检测所述目标区块链是否存在预先配置的区块链网络;
若存在,则获取所述目标区块链对应的区块链网络,并利用所述区块链网络中配置的预设上链方法对所述上链数据进行上链;
若不存在,则根据所述链通道标识对应的链通道配置实例化区块链网络,并利用实例化的区块链网络中配置的上链方法对所述上链数据进行上链。
在本申请一些实施例中,该区块链的数据整合装置还包括:
解析模块,用于通过区块链网络对上链后的上链数据进行解析,得到解析业务数据;
填充模块,用于对所述解析业务数据进行填充,得到标准化业务数据;
写入模块,用于将所述标准化业务数据写入预设数据库。
在本申请一些实施例中,该区块链的数据整合装置还包括:
第一获取模块,用于获取预先存储的上链结果表,所述上链结果表中包括上链成功的数据;
对比模块,用于将所述上链数据与所述上链结果表中上链成功的数据进行对比校验,得到对比校验结果,并根据对比校验结果,确定是否存在上链失败数据;
二次上链模块,用于若存在所述上链失败数据,则对所述上链失败数据进行二次上链。
本申请实施例还提供一种计算机设备,其集成了本申请实施例所提供的任一种区块链的数据整合装置,所述计算机设备包括:
一个或多个处理器;
存储器;以及
一个或多个应用程序,其中所述一个或多个应用程序被存储于所述存储器中,并配置为由所述处理器执行上述区块链的数据整合方法实施例中任一实施例中所述的区块链的数据整合方法中的步骤。
本申请实施例还提供一种计算机设备,其集成了本申请实施例所提供的任一种区块链的数据整合装置。如图11所示,其示出了本申请实施例所涉及的计算机设备的结构示意图,具体来讲:
该计算机设备可以包括一个或者一个以上处理核心的处理器901、一个或一个以上计算机可读存储介质的存储器902、电源903和输入单元904等部件。本领域技术人员可以理解,图11中示出的计算机设备结构并不构成对计算机设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。其中:
处理器901是该计算机设备的控制中心,利用各种接口和线路连接整个计算机设备的各个部分,通过运行或执行存储在存储器902内的软件程序和/或模块,以及调用存储在存储器902内的数据,执行计算机设备的各种功能和处理数据,从而对计算机设备进行整体监控。可选的,处理器901可包括一个或多个处理核心;优选的,处理器901可集成应用处理器和调制解调处理器,其中,应用处理器主要处理操作***、用户界面和应用程序等,调制解调处理器主要处理无线通信。可以理解的是,上述调制解调处理器也可以不集成到处理器901中。
存储器902可用于存储软件程序以及模块,处理器901通过运行存储在存储器902的软件程序以及模块,从而执行各种功能应用以及数据处理。存储器902可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作***、至少一个功能所需的应用程序(比如声音播放功能、图像播放功能等)等;存储数据区可存储根据计算机设备的使用所创建的数据等。此外,存储器902可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。相应地,存储器902还可以包括存储器控制器,以提供处理器901对存储器902的访问。
计算机设备还包括给各个部件供电的电源903,优选的,电源903可以通过电源管理***与处理器901逻辑相连,从而通过电源管理***实现管理充电、放电、以及功耗管理等功能。电源903还可以包括一个或一个以上的直流或交流电源、再充电***、电源故障检测电路、电源转换器或者逆变器、电源状态指示器等任意组件。
该计算机设备还可包括输入单元904,该输入单元904可用于接收输入的数字或字符信息,以及产生与用户设置以及功能控制有关的键盘、鼠标、操作杆、光学或者轨迹球信号输入。
尽管未示出,计算机设备还可以包括显示单元等,在此不再赘述。具体在本实施例中,计算机设备中的处理器901会按照如下的指令,将一个或一个以上的应用程序的进程对应的可执行文件加载到存储器902中,并由处理器901来运行存储在存储器902中的应用程序,从而实现各种功能,如下:
获取区块链***中多个业务节点的上链信息;
将所述上链信息发送给所述消息中间件的分布式消息队列中;
对所述分布式消息队列中的消息进行分析,得到所述上链信息的局部有序消息队列集合,所述局部有序消息队列集合包括多个局部有序消息队列,每个所述局部有序消息队列存储一个分区消息,每个分区消息对应一个消息主题;
对所述局部有序消息队列集合进行有序消费,得到全局有序消息队列集合,所述全局有序消息队列集合包括多个标记有顺序的全局有序消息队列,每个所述全局有序消息队列存储具有相同消息主题的分区消息;
将所述全局有序消息队列中的所述具有相同消息主题的分区消息作为上链数据,在所述区块链***上链。
本领域普通技术人员可以理解,上述实施例的各种方法中的全部或部分步骤可以通过指令来完成,或通过指令控制相关的硬件来完成,该指令可以存储于一计算机可读存储介质中,并由处理器进行加载和执行。
为此,本申请实施例提供一种计算机可读存储介质,该存储介质可以包括:只读存储器(ROM,Read Only Memory)、随机存取记忆体(RAM,Random Access Memory)、磁盘或光盘等。其上存储有计算机程序,所述计算机程序被处理器进行加载,以执行本申请实施例所提供的任一种区块链的数据整合方法中的步骤。例如,所述计算机程序被处理器进行加载可以执行如下步骤:
获取区块链***中多个业务节点的上链信息;
将所述上链信息发送给所述消息中间件的分布式消息队列中;
对所述分布式消息队列中的消息进行分析,得到所述上链信息的局部有序消息队列集合,所述局部有序消息队列集合包括多个局部有序消息队列,每个所述局部有序消息队列存储一个分区消息,每个分区消息对应一个消息主题;
对所述局部有序消息队列集合进行有序消费,得到全局有序消息队列集合,所述全局有序消息队列集合包括多个标记有顺序的全局有序消息队列,每个所述全局有序消息队列存储具有相同消息主题的分区消息;
将所述全局有序消息队列中的所述具有相同消息主题的分区消息作为上链数据,在所述区块链***上链。
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见上文针对其他实施例的详细描述,此处不再赘述。
具体实施时,以上各个单元或结构可以作为独立的实体来实现,也可以进行任意组合,作为同一或若干个实体来实现,以上各个单元或结构的具体实施可参见前面的方法实施例,在此不再赘述。
以上各个操作的具体实施可参见前面的实施例,在此不再赘述。
以上对本申请实施例所提供的一种区块链的数据整合方法、装置、计算机设备及存储介质进行了详细介绍,本文中应用了具体个例对本申请的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本申请的方法及其核心思想;同时,对于本领域的技术人员,依据本申请的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本申请的限制。

Claims (15)

  1. 一种区块链的数据整合方法,其特征在于,应用于区块链***,所述区块链***包括用于传输消息的消息中间件,所述消息中间件包括用于存储消息的分布式消息队列,所述区块链的数据整合方法包括:
    获取所述区块链***中多个业务节点的上链信息;
    将所述上链信息发送给所述消息中间件的所述分布式消息队列中;
    对所述分布式消息队列中的消息进行分析,得到所述上链信息的局部有序消息队列集合,所述局部有序消息队列集合包括多个局部有序消息队列,每个所述局部有序消息队列存储一个分区消息,每个分区消息对应一个消息主题;
    对所述局部有序消息队列集合进行有序消费,得到全局有序消息队列集合,所述全局有序消息队列集合包括多个标记有顺序的全局有序消息队列,每个所述全局有序消息队列存储具有相同消息主题的分区消息;
    将所述全局有序消息队列中的所述具有相同消息主题的分区消息作为上链数据,在所述区块链***上链。
  2. 根据权利要求1所述的区块链的数据整合方法,其特征在于,所述对所述局部有序消息队列集合进行有序消费,得到全局有序消息队列集合,包括:
    订阅所述局部有序消息队列的消息,得到多个消息主题标识及各个所述消息主题标识对应的分区消息;
    将所述消息主题标识作为键、所述消息主题标识对应的分区消息作为值,得到多个键值对消息队列;
    获取预先创建的用于消费所述分布式消息队列中消息的多个内存队列,并将所述多个键值对消息队列中,相同键值的分区消息路由至一个所述内存队列,生成多个内存队列消息;
    针对每个所述内存队列消息,分别开启预先配置的子线程对所述内存队列消息进行消费,生成所述全局有序消息队列。
  3. 根据权利要求2所述的区块链的数据整合方法,其特征在于,所述分布式消息队列为kafka,所述订阅所述局部有序消息队列的消息,得到多个消息主题标识及各个所述消息主题标识对应的分区消息,包括:
    获取预先发布的kafka消息的消息主题;
    根据所述消息主题,对所述局部有序消息队列中的各个分区消息进行分析,确定各个所述分区消息的消息主题标识;
    订阅各个所述分区消息的消息主题标识,得到所述多个消息主题标识及各个所述消息主题标识对应的所述分区消息。
  4. 根据权利要求1-3任一项所述的区块链的数据整合方法,其特征在于,所述上链信息包括待上链的区块链的链通道标识和智能合约版本标识,其中,
    所述将所述全局有序消息队列中的所述具有相同消息主题的分区消息作为上链数据,在所述区块链***上链,包括:
    根据所述链通道标识和所述智能合约版本标识,确定所述上链数据的目标区块链;
    将所述上链数据在所述目标区块链中进行上链。
  5. 根据权利要求4所述的区块链的数据整合方法,其特征在于,所述根据所述链通道标识和所述智能合约版本标识,确定所述上链数据的目标区块链,包括:
    根据所述智能合约版本标识确定所述上链数据所采用的目标智能合约;
    将所述链通道标识与所述智能合约版本标识进行拼接,得到目标区块链类型标识;
    根据所述目标区块链类型标识及所述目标智能合约,在预先配置的区块链类型标识、目标智能合约与区块链的映射表中,查找所述目标区块链。
  6. 根据权利要求4或5所述的区块链的数据整合方法,其特征在于,所述将所述上链数据在所述目标区块链中进行上链,包括:
    检测所述目标区块链是否存在预先配置的区块链网络;
    若存在,则获取所述目标区块链对应的区块链网络,并利用所述区块链网络中配置的预设上链方法对所述上链数据进行上链;
    若不存在,则根据所述链通道标识对应的链通道配置实例化区块链网络,并利用实例化的区块链网络中配置的上链方法对所述上链数据进行上链。
  7. 根据权利要求1-6中任一项所述的区块链的数据整合方法,其特征在于,在所述将所述全局有序消息队列中的所述具有相同消息主题的分区消息作为上链数据,在所述区块链***上链之后,还包括:
    通过区块链网络对上链后的上链数据进行解析,得到解析业务数据;
    对所述解析业务数据进行填充,得到标准化业务数据;
    将所述标准化业务数据写入预设数据库。
  8. 根据权利要求1-7中任一项所述的区块链的数据整合方法,其特征在于,在所述将所述全局有序消息队列中的所述具有相同消息主题的分区消息作为上链数据,在所述区块链***上链之后,还包括:
    获取预先存储的上链结果表,所述上链结果表中包括上链成功的数据;
    将所述上链数据与所述上链结果表中上链成功的数据进行对比校验,得到对比校验结果,并根据所述对比校验结果,确定是否存在上链失败数据;
    若存在所述上链失败数据,则对所述上链失败数据进行二次上链。
  9. 一种区块链的数据整合装置,其特征在于,应用于区块链***,所述区块链***包括用于传输消息的消息中间件,所述消息中间件包括用于存储消息的分布式消息队列,所述区块链的数据整合装置包括:
    获取模块,用于获取所述区块链***中多个业务节点的上链信息;
    发送模块,用于将所述上链信息发送给所述消息中间件的所述分布式消息队列中;
    分析模块,用于对所述分布式消息队列中的消息进行分析,得到所述上链信息的局部有序消息队列集合,所述局部有序消息队列集合包括多个局部有序消息队列,每个所述局部有序消息队列存储一个分区消息,每个分区消息对应一个消息主题;
    整合模块,用于对所述局部有序消息队列集合进行有序消费,得到全局有序消息队列集合,所述全局有序消息队列集合包括多个标记有顺序的全局有序消息队列,每个所述全局有序消息队列存储具有相同消息主题的分区消息;
    上链模块,用于将所述全局有序消息队列中的所述具有相同消息主题的分区消息作为上链数据,在所述区块链***上链。
  10. 根据权利要求9所述的区块链的数据整合装置,其特征在于,所述整合模块,用于:
    订阅所述局部有序消息队列的消息,得到多个消息主题标识及各个所述消息主题标识对应的分区消息;
    将所述消息主题标识作为键、所述消息主题标识对应的分区消息作为值,得到多个键值对消息队列;
    获取预先创建的用于消费所述分布式消息队列中消息的多个内存队列,并将所述多个键值对消息队列中,相同键值的分区消息路由至一个所述内存队列,生成多个内存队列消息;
    针对每个所述内存队列消息,分别开启预先配置的子线程对所述内存队列消息进行消费,生成所述全局有序消息队列。
  11. 根据权利要求10所述的区块链的数据整合装置,其特征在于,所述分布式消息队列为kafka,所述整合模块,用于:
    获取预先发布的kafka消息的消息主题;
    根据所述消息主题,对所述局部有序消息队列中的各个分区消息进行分析,确定各个所述分区消息的消息主题标识;
    订阅各个所述分区消息的消息主题标识,得到所述多个消息主题标识及各个所述消息主题标识对应的所述分区消息。
  12. 根据权利要求9-11中任一项所述的区块链的数据整合装置,其特征在于,所述上链信息包括待上链的区块链的链通道标识和智能合约版本标识,其中,所述上链模块,用于:
    根据所述链通道标识和所述智能合约版本标识,确定所述上链数据的目标区块链;
    将所述上链数据在所述目标区块链中进行上链。
  13. 根据权利要求12所述的区块链的数据整合装置,其特征在于,所述上链模块,用于:
    根据所述智能合约版本标识确定所述上链数据所采用的目标智能合约;
    将所述链通道标识与所述智能合约版本标识进行拼接,得到目标区块链类型标识;
    根据所述目标区块链类型标识及所述目标智能合约,在预先配置的区块链类型标识、目标智能合约与区块链的映射表中,查找所述目标区块链。
  14. 一种计算机设备,其特征在于,包括:
    一个或多个处理器;以及
    存储器,其中,所述存储器中存储有一个或多个应用程序,所述一个或多个应用程序被配置为由所述处理器执行以实现权利要求1至8任一项所述的区块链的数据整合方法中的步骤。
  15. 一种计算机可读存储介质,其特征在于,其上存储有计算机程序,所述计算机程序被处理器进行加载,以执行权利要求1至8任一项所述的区块链的数据整合方法中的步骤。
PCT/CN2023/113768 2022-08-19 2023-08-18 区块链的数据整合方法、装置、计算机设备及存储介质 WO2024037629A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211001630.1A CN117633102A (zh) 2022-08-19 2022-08-19 区块链的数据整合方法、装置、计算机设备及存储介质
CN202211001630.1 2022-08-19

Publications (1)

Publication Number Publication Date
WO2024037629A1 true WO2024037629A1 (zh) 2024-02-22

Family

ID=89940785

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/113768 WO2024037629A1 (zh) 2022-08-19 2023-08-18 区块链的数据整合方法、装置、计算机设备及存储介质

Country Status (2)

Country Link
CN (1) CN117633102A (zh)
WO (1) WO2024037629A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118093147A (zh) * 2024-04-29 2024-05-28 浙江农商数字科技有限责任公司 一种基于任务链和分治法的海量数据汇总方法及***

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111930533A (zh) * 2020-07-28 2020-11-13 银盛支付服务股份有限公司 一种基于kafka的生产消费同一数据的有序处理方法及***
WO2021051531A1 (zh) * 2019-09-19 2021-03-25 平安科技(深圳)有限公司 处理多集群作业记录的方法、装置、设备及存储介质
CN113347238A (zh) * 2021-05-26 2021-09-03 湖南大学 基于区块链的消息分区方法及***、设备、存储介质
CN113347164A (zh) * 2021-05-24 2021-09-03 湖南大学 基于区块链的分布式共识***及方法、设备、存储介质
CN114390097A (zh) * 2022-01-10 2022-04-22 北京新华夏信息技术有限公司 基于消息队列的区块链运行方法、***及其应用

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2021051531A1 (zh) * 2019-09-19 2021-03-25 平安科技(深圳)有限公司 处理多集群作业记录的方法、装置、设备及存储介质
CN111930533A (zh) * 2020-07-28 2020-11-13 银盛支付服务股份有限公司 一种基于kafka的生产消费同一数据的有序处理方法及***
CN113347164A (zh) * 2021-05-24 2021-09-03 湖南大学 基于区块链的分布式共识***及方法、设备、存储介质
CN113347238A (zh) * 2021-05-26 2021-09-03 湖南大学 基于区块链的消息分区方法及***、设备、存储介质
CN114390097A (zh) * 2022-01-10 2022-04-22 北京新华夏信息技术有限公司 基于消息队列的区块链运行方法、***及其应用

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118093147A (zh) * 2024-04-29 2024-05-28 浙江农商数字科技有限责任公司 一种基于任务链和分治法的海量数据汇总方法及***

Also Published As

Publication number Publication date
CN117633102A (zh) 2024-03-01

Similar Documents

Publication Publication Date Title
US11487771B2 (en) Per-node custom code engine for distributed query processing
US9363195B2 (en) Configuring cloud resources
US10382380B1 (en) Workload management service for first-in first-out queues for network-accessible queuing and messaging services
WO2021088641A1 (zh) 数据发送方法、处理方法、接收方法及其设备、存储介质
US10802753B2 (en) Distributed compute array in a storage system
WO2024037629A1 (zh) 区块链的数据整合方法、装置、计算机设备及存储介质
WO2024016596A1 (zh) 容器集群调度的方法、装置、设备及存储介质
CN114201421A (zh) 一种数据流处理方法、存储控制节点及可读存储介质
CN112685148A (zh) 海量终端的异步通信方法、装置、计算机设备和存储介质
US11190620B2 (en) Methods and electronic devices for data transmission and reception
WO2022214012A1 (zh) 实现应用程序的多语言翻译的***、方法、设备和介质
US20240205292A1 (en) Data processing method and apparatus, computer device, and computer-readable storage medium
US10313450B2 (en) Method for transparently connecting augmented network socket operations
CN110168513B (zh) 在不同存储***中对大文件的部分存储
US20090132582A1 (en) Processor-server hybrid system for processing data
AU2017382907B2 (en) Technologies for scaling user interface backend clusters for database-bound applications
CN116126916A (zh) 一种基于智能网卡的数据查询方法、装置及设备
US11868805B2 (en) Scheduling workloads on partitioned resources of a host system in a container-orchestration system
WO2021232860A1 (zh) 通信方法、装置及***
US12009976B2 (en) Configuration of a server in view of a number of clients connected to the server
CN113254151B (zh) 超级计算机***虚拟化方法和装置
US20240095104A1 (en) Asynchronous communication in cluster infrastructures
CN117093387B (zh) 消息处理方法、装置、电子设备和存储介质
US20240202207A1 (en) Distributed function data transformation system
US20240220334A1 (en) Data processing method in distributed system, and related system

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23854525

Country of ref document: EP

Kind code of ref document: A1