Data communication method, device, electronic device and storage medium based on blockchain

By querying and analyzing the attributes of communication messages on the blockchain and determining the display order, the problem of messy message display order caused by non-serial sending in blockchain technology is solved, and the order display and consistency of messages are realized.

CN116033023BActive Publication Date: 2024-12-03NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310101016.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-06
Publication Date
2024-12-03
Estimated Expiration
2043-02-06

AI Technical Summary

Technical Problem

The existing communication message sending method based on blockchain technology has the problem of confusing display order of multiple messages during non-serial transmission.

Method used

By querying the target communication channel on the blockchain, the sending terminal identification, the sending terminal local timestamp and the overhead timestamp of each message are obtained, and the message is displayed in sequence in the preset interface. Avoid confusion in sequence.

Benefits of technology

It realizes that multiple communication messages are displayed in sequence under parallel transmission mode, solving the problem of sequential confusion caused by non-serial transmission mode, and improving the display consistency of communication messages.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116033023B_ABST
    Figure CN116033023B_ABST
Patent Text Reader

Abstract

The present application provides a data communication method, device, electronic device and storage medium based on blockchain, and relates to the field of blockchain technology. The method includes: in response to a query operation on a target communication channel, sending a query request to the blockchain, receiving at least one target communication message returned by the blockchain, each target communication message includes a preset message attribute, and the preset message attribute includes: a sending terminal identifier corresponding to the target communication message, a local timestamp of the sending terminal and an on-chain timestamp; determining the display order of each target communication message according to the preset message attribute of each target communication message, and displaying each target communication message on a preset communication interface according to the display order of each target communication message, so that each target communication message can be displayed in sequence on the preset communication interface, avoiding the problem of sequence confusion caused by the non-serial sending method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of blockchain technology, and in particular to a blockchain-based data communication method, device, electronic device and storage medium. Background Art

[0002] Blockchain is a chain of blocks. Each block stores certain information, and they are connected into a chain in the order of their generation. This chain is stored in all servers. As long as there is one server in the entire system that can work, the entire blockchain is safe.

[0003] In the prior art, when communication messages are sent based on blockchain technology, it is often implemented through serial sending technology.

[0004] It can be seen that the existing blockchain-based technology has certain requirements for the sending method when sending communication messages. Therefore, for non-serial sending methods, there is a problem of disordered display order of multiple communication messages. Summary of the invention

[0005] The purpose of this application is to provide a blockchain-based data communication method, device, electronic device and storage medium to address the deficiencies in the above-mentioned prior art, which can avoid the problem of disordered display order of multiple communication messages caused by non-serial transmission methods.

[0006] To achieve the above purpose, the technical solution adopted in the embodiment of the present application is as follows:

[0007] In a first aspect, the present invention provides a blockchain-based data communication method, which is applied to a first terminal, and the method includes:

[0008] In response to a query operation on a target communication channel, sending a query request to a blockchain, wherein the target communication channel is a communication channel between the first terminal and the second terminal;

[0009] Receiving a query result returned by the blockchain according to the query request, the query result including at least one target communication message, wherein each target communication message includes preset message attributes, and the preset message attributes include: a sending terminal identifier corresponding to the target communication message, a local timestamp of the sending terminal, and an on-chain timestamp;

[0010] The display order of each of the target communication messages is determined according to the preset message attribute of each of the target communication messages, and each of the target communication messages is displayed on the preset communication interface according to the display order of each of the target communication messages.

[0011] In an optional implementation manner, the target communication message includes a plurality of messages, and determining the display order of each of the target communication messages according to a preset message attribute of each of the target communication messages includes:

[0012] Obtaining preset message attributes of any two target communication messages among the plurality of target communication messages;

[0013] If it is determined according to the preset message attribute that the terminal identifiers corresponding to the arbitrary two target communication messages are the same, then the display order of the arbitrary two target communication messages is determined according to the local timestamp of the sending terminal of each of the arbitrary two target communication messages;

[0014] If it is determined according to the preset message attribute that the terminal identifiers corresponding to the arbitrary two target communication messages are different, the display order of the arbitrary two target communication messages is determined according to the uplink timestamp of each of the arbitrary two target communication messages.

[0015] In an optional implementation manner, displaying each of the target communication messages on a preset communication interface includes:

[0016] If the preset message attribute of any of the target communication messages indicates that the sending terminal identifier of any of the target communication messages is the second terminal identifier, target status prompt information is displayed when any of the target communication messages is displayed on the preset communication interface, and the target status prompt information is used to indicate that any of the target communication messages has been received.

[0017] In an optional implementation, in response to the query operation on the target communication channel, before sending the query request to the blockchain, the method further includes:

[0018] In response to the sending operation of the first communication message, the first communication message is sent to the blockchain, and the sending status of the first communication message is obtained, wherein the sending status includes: not submitted to the blockchain, submitted but not successfully uploaded to the blockchain, and uploaded to the blockchain;

[0019] According to the sending status of the first communication message, prompt information of the first communication message is displayed.

[0020] In an optional implementation manner, displaying prompt information of the first communication message according to the sending status of the first communication message includes:

[0021] If it is determined that the sending status of the first communication message is not submitted for uplink or has been submitted but not successfully uploaded, indicating through the prompt information that the first communication message is being sent but the next communication message can be input;

[0022] If it is determined that the sending status of the first communication message is already on the link, the prompt information indicates that the first communication message has been sent.

[0023] In an optional implementation, in response to the sending operation of the first communication message, sending the first communication message to the blockchain includes:

[0024] In response to the sending operation of the first communication message, a message header of the first communication message is generated according to a preset message protocol, the message header including: a message protocol version identifier, a first terminal identifier, a current local timestamp of the first terminal, and a first communication message identifier;

[0025] According to the message header of the first communication message, the first communication message is sent to the blockchain, so that the blockchain performs an on-chain operation after receiving the first communication message, appends on-chain attributes to the first communication message according to the on-chain time of the first communication message, and writes the first communication message into the target communication channel, wherein the on-chain attributes include an on-chain timestamp.

[0026] In an optional embodiment, the method further comprises:

[0027] Receiving a notification of chaining sent by the blockchain after determining that the first communication message is successfully chained;

[0028] A query operation for the target communication channel is generated through the on-chain notification, and a query request is sent to the blockchain through a callback function in the on-chain notification.

[0029] In a second aspect, the present invention provides a blockchain-based data communication device, applied to a first terminal, the device comprising:

[0030] A response module, configured to send a query request to the blockchain in response to a query operation on a target communication channel, wherein the target communication channel is a communication channel between the first terminal and the second terminal;

[0031] A receiving module, configured to receive a query result returned by the blockchain according to the query request, wherein the query result includes at least one target communication message, wherein each target communication message includes preset message attributes, and the preset message attributes include: a sending terminal identifier corresponding to the target communication message, a local timestamp of the sending terminal, and an on-chain timestamp;

[0032] The determination module is used to determine the display order of each target communication message according to the preset message attribute of each target communication message, and display each target communication message on the preset communication interface according to the display order of each target communication message.

[0033] In an optional implementation manner, the target communication message includes multiple messages, and the determination module is specifically used to obtain preset message attributes of any two target communication messages among the multiple target communication messages;

[0034] If it is determined according to the preset message attribute that the terminal identifiers corresponding to the arbitrary two target communication messages are the same, then the display order of the arbitrary two target communication messages is determined according to the local timestamp of the sending terminal of each of the arbitrary two target communication messages;

[0035] If it is determined according to the preset message attribute that the terminal identifiers corresponding to the arbitrary two target communication messages are different, the display order of the arbitrary two target communication messages is determined according to the uplink timestamp of each of the arbitrary two target communication messages.

[0036] In an optional embodiment, the determination module is specifically used to display target status prompt information when displaying any of the target communication messages on the preset communication interface if the preset message attributes of any of the target communication messages indicate that the sending terminal identifier of any of the target communication messages is the second terminal identifier, and the target status prompt information is used to indicate that any of the target communication messages has been received.

[0037] In an optional implementation, the response module is further configured to, in response to a sending operation of the first communication message, send the first communication message to the blockchain, and obtain a sending status of the first communication message, wherein the sending status includes: not submitted to the blockchain, submitted but not successfully uploaded to the blockchain, and uploaded to the blockchain;

[0038] According to the sending status of the first communication message, prompt information of the first communication message is displayed.

[0039] In an optional implementation manner, the response module is further configured to, if it is determined that the sending status of the first communication message is not submitted for uplink or has been submitted but not successfully uploaded, indicate through the prompt information that the first communication message is being sent, but the next communication message can be input;

[0040] If it is determined that the sending status of the first communication message is already on the link, the prompt information indicates that the first communication message has been sent.

[0041] In an optional implementation, the response module is further used to generate a message header of the first communication message according to a preset message protocol in response to the sending operation of the first communication message, wherein the message header includes: a message protocol version identifier, a first terminal identifier, a current local timestamp of the first terminal, and a first communication message identifier;

[0042] According to the message header of the first communication message, the first communication message is sent to the blockchain, so that the blockchain performs an on-chain operation after receiving the first communication message, appends on-chain attributes to the first communication message according to the on-chain time of the first communication message, and writes the first communication message into the target communication channel, wherein the on-chain attributes include an on-chain timestamp.

[0043] In an optional implementation, the response module is further used to receive a notification of blockchain upload sent after determining that the first communication message is successfully uploaded to the blockchain;

[0044] A query operation for the target communication channel is generated through the on-chain notification, and a query request is sent to the blockchain through a callback function in the on-chain notification.

[0045] In a third aspect, the present invention provides an electronic device, comprising: a processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the storage medium through the bus, and the processor executes the machine-readable instructions to perform the steps of the blockchain-based data communication method as described in any of the aforementioned implementations.

[0046] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the blockchain-based data communication method as described in any of the aforementioned embodiments are executed.

[0047] The beneficial effects of this application are:

[0048] The blockchain-based data communication method, device, electronic device and storage medium provided by the embodiments of the present application include: in response to a query operation on a target communication channel, sending a query request to the blockchain, wherein the target communication channel is a communication channel between a first terminal and a second terminal; receiving a query result returned by the blockchain according to the query request, the query result including at least one target communication message, wherein each target communication message includes a preset message attribute, and the preset message attribute includes: a sending terminal identifier, a sending terminal local timestamp and an on-chain timestamp corresponding to the target communication message; determining the display order of each target communication message according to the preset message attributes of each target communication message, and displaying each target communication message on a preset communication interface according to the display order of each target communication message. By applying the embodiments of the present application, it is possible to comprehensively determine the display order of each target communication message according to the sending terminal identifier, the sending terminal local timestamp and the on-chain timestamp corresponding to each target communication message, which can be applied to a parallel sending mode, and based on this, each target communication message can be displayed in sequence when displayed on the preset communication interface, avoiding the problem of sequence confusion caused by a non-serial sending mode. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0050] Figure 1 A flowchart of a blockchain-based data communication method provided in an embodiment of the present application;

[0051] Figure 2 A flowchart of another blockchain-based data communication method provided in an embodiment of the present application;

[0052] Figure 3 A flowchart of another blockchain-based data communication method provided in an embodiment of the present application;

[0053] Figure 4 A flowchart of another blockchain-based data communication method provided in an embodiment of the present application;

[0054] Figure 5 A flowchart of another blockchain-based data communication method provided in an embodiment of the present application;

[0055] Figure 6 A flowchart of another blockchain-based data communication method provided in an embodiment of the present application;

[0056] Figure 7 A schematic diagram of functional modules of a blockchain-based data communication device provided in an embodiment of the present application;

[0057] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0058] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations.

[0059] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for which protection is sought, but merely represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.

[0060] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.

[0061] With the development of blockchain technology, while bringing new technical forms and businesses, it has also brought new development directions to various industries. For example, in the communications industry, the original communication model based on the C / S architecture is an architecture that relies heavily on centralized servers. Once the server goes down or the service provider has problems, all communication services will be interrupted. In addition, all user data is in the hands of the service provider, and users cannot benefit from their own data. After the emergence of blockchain, decentralized services can also be applied to communication services, thereby realizing the decentralization of communication services.

[0062] In the prior art, when communication messages are sent based on blockchain technology, it is often implemented through serial sending technology. When sending communication messages through serial sending technology, it is often required that the next communication message can only be sent after the current communication message is sent successfully, otherwise there will be a problem of confusion in the display order of multiple communication messages.

[0063] In view of this, an embodiment of the present application provides a data communication method based on blockchain, and the application of this method can avoid the problem of disordered display order of multiple communication messages caused by non-serial sending methods.

[0064] Figure 1 The present invention provides a flowchart of a blockchain-based data communication method, which can be applied to a first terminal. Optionally, the first terminal can be a computer, server, mobile terminal or other electronic device with data processing function. Figure 1 As shown, the method includes:

[0065] S101. In response to a query operation on a target communication channel, a query request is sent to a blockchain.

[0066] The target communication channel is a communication channel between the first terminal and the second terminal, that is, the target communication channel can store communication messages between the first terminal and the second terminal. In some embodiments, the target communication channel can be constructed based on a blockchain. Then, for the first terminal, if it is necessary to obtain communication messages in the target communication channel, a query operation for the target communication channel can be generated. In response to the query operation, the first terminal can send a query request to the blockchain.

[0067] Optionally, the second terminal may be a communication terminal of the same type or a different type as the first terminal. For example, the first terminal may be a laptop computer, the second terminal may be a smart phone, or both the first terminal and the second terminal may be smart phones, which is not limited here.

[0068] It should be noted that, in some embodiments, the target communication client may be installed on the first terminal and the second terminal respectively, and the blockchain may be used as a target communication server for communicating with each target communication client. For example, the target communication client may be an instant messaging client, which is not limited here.

[0069] S102. Receive a query result returned by the blockchain according to the query request, where the query result includes at least one target communication message.

[0070] Each target communication message includes preset message attributes, and the preset message attributes include: a sending terminal identifier corresponding to the target communication message, a local timestamp of the sending terminal, and an uplink timestamp.

[0071] Optionally, depending on the number of communications between the first terminal and the second terminal, the query result returned by the blockchain based on the query request sent by the first terminal may include one or more target communication messages, which is not limited here.

[0072] For each target communication message, the sending terminal identifier in its preset message attributes can indicate the source of the target communication message, that is, whether the target communication message is sent from the first terminal to the second terminal, or from the second terminal to the first terminal; the sending terminal local timestamp in the preset message attributes can indicate the local timestamp when the sending terminal sends the target communication message. It can be understood that for the same terminal, target communication messages sent at different times will correspond to different sending terminal local timestamps; the on-chain timestamp in the preset message attributes can represent the time when the target communication message is registered on the blockchain.

[0073] S103: Determine a display order of each target communication message according to a preset message attribute of each target communication message, and display each target communication message on a preset communication interface according to the display order of each target communication message.

[0074] Based on the above description, after obtaining the preset message attributes of each target communication message, the display order of each target communication message can be comprehensively determined according to the sending terminal identifier, the sending terminal local timestamp and the uplink timestamp corresponding to each target communication message. Based on this, when displaying each target communication message on the preset communication interface, it can be displayed in sequence, avoiding the problem of order confusion caused by non-serial sending methods.

[0075] In summary, the embodiment of the present application provides a data communication method based on blockchain, which can be applied to a first terminal, and the method includes: in response to a query operation on a target communication channel, sending a query request to the blockchain, wherein the target communication channel is a communication channel between the first terminal and the second terminal; receiving a query result returned by the blockchain according to the query request, the query result includes at least one target communication message, wherein each target communication message includes a preset message attribute, and the preset message attribute includes: a sending terminal identifier, a sending terminal local timestamp, and an on-chain timestamp corresponding to the target communication message; determining the display order of each target communication message according to the preset message attributes of each target communication message, and displaying each target communication message on a preset communication interface according to the display order of each target communication message. By applying the embodiment of the present application, it is possible to comprehensively determine the display order of each target communication message according to the sending terminal identifier, the sending terminal local timestamp, and the on-chain timestamp corresponding to each target communication message, which can be applied to a parallel sending mode, and based on this, each target communication message can be displayed in sequence on the preset communication interface, avoiding the problem of sequence confusion caused by a non-serial sending mode.

[0076] Figure 2 A flowchart of another blockchain-based data communication method provided in an embodiment of the present application. Optionally, the target communication message includes multiple messages, such as Figure 2 As shown, the above-mentioned determining the display order of each target communication message according to the preset message attribute of each target communication message includes:

[0077] S201. Obtain preset message attributes of any two target communication messages among multiple target communication messages.

[0078] For any two target communication messages among the multiple target communication messages, preset message attributes of each target communication message may be obtained respectively, and the display order of the two target communication messages may be determined accordingly. For details, please refer to the following determination rules.

[0079] S202: If it is determined according to preset message attributes that the terminal identifiers corresponding to any two target communication messages are the same, a display order of the any two target communication messages is determined according to a local timestamp of a sending terminal of each of the any two target communication messages.

[0080] S203: If it is determined according to the preset message attributes that the terminal identifiers corresponding to any two target communication messages are different, the display order of the any two target communication messages is determined according to the uplink timestamp of each of the any two target communication messages.

[0081] Based on the above description, for the preset message attributes of the two target communication messages, we can first compare whether the sending terminal identifiers corresponding to the two target communication messages are the same. If they are the same, it means that the two target communication messages are sent by the same terminal. Then we can further compare the sending terminal local timestamps of the two target communication messages, and determine the display order of the two target communication messages according to the order of their corresponding sending terminal local timestamps. Among them, if the sending terminal local timestamp of the first target communication message of any two target communication messages is earlier than the sending terminal local timestamp of the second target communication message, the display order of the first target communication message should be earlier than that of the second target communication message.

[0082] In some embodiments, if it is determined that the sending terminal identifiers corresponding to any two target communication messages are different, the uplink timestamps of the two target communication messages can be compared, and the display order of the two target communication messages can be determined according to the order of their corresponding uplink timestamps. Among them, if the uplink timestamp of the first target communication message of any two target communication messages is earlier than the uplink timestamp of the second target communication message, the display order of the first target communication message should be earlier than that of the second target communication message.

[0083] Optionally, the above-mentioned displaying each target communication message on the preset communication interface includes:

[0084] If the preset message attribute of any target communication message indicates that the sending terminal identifier of any target communication message is the second terminal identifier, target status prompt information is displayed when any target communication message is displayed on the preset communication interface, and the target status prompt information is used to indicate that any target communication message has been received.

[0085] The second terminal identifier is the identifier of the second terminal. Optionally, the second terminal identifier may be a serial number of the second terminal, a user name for logging into the target communication client on the second terminal, etc., which is not limited here.

[0086] Optionally, during the communication between the first terminal and the second terminal, there may be a target communication message sent by the second terminal to the first terminal in the target communication channel. It can be understood that in this case, the sending terminal identifier of the target communication message sent by the second terminal to the first terminal will be the second terminal identifier; then for the first terminal, the first terminal needs to obtain the target communication message sent by the second terminal to the first terminal in the target communication channel and display it accordingly. In some embodiments, in order to enable the first terminal to synchronously provide a status prompt when displaying the target communication message sent by the second terminal, the received target status prompt information can be displayed near the target communication message when displaying the target communication message.

[0087] It is worth noting that, for the second terminal, if the second terminal determines through the blockchain that the first terminal has received and displayed the target communication message sent to the first terminal, optionally, the second terminal can display the target status prompt information that has been received by the other party near the target communication message.

[0088] In some embodiments, when the target status prompt information is displayed near the target communication message, the target status prompt information can be suspended above, below, or at a preset position of the current interface of the target communication message, which is not limited here; of course, according to the actual application scenario, the target status prompt information can also be displayed in the form of a pop-up window, and the display method of the target status prompt information is not limited here, and may vary according to the actual application scenario.

[0089] Figure 3 A flowchart of another data communication method based on blockchain provided in an embodiment of the present application. Optionally, Figure 3 As shown, before sending a query request to the blockchain in response to a query operation on the target communication channel, the method further includes:

[0090] S301. In response to a sending operation of a first communication message, the first communication message is sent to a blockchain, and a sending status of the first communication message is obtained.

[0091] Among them, the sending status includes: not submitted to the chain, submitted but not successfully uploaded to the chain, and uploaded to the chain, that is, the sending of the first communication message needs to go through these three sending states in sequence. It should be noted that the first communication message can be any communication message in the above-mentioned target communication channel, which is not limited here. In addition, since the chain operation takes a certain amount of time, there will be a sending status of submitted but not successfully uploaded to the chain during the submission process; not submitted to the chain, that is, the chain request for the first communication message has not been submitted to the blockchain.

[0092] Optionally, a target communication client may be installed on the first terminal, and during the communication process, a communication message may be sent to the second terminal by logging into the target communication client.

[0093] In some embodiments, the first communication message can be generated through the message editing interface of the target communication client, and the generated first communication message can include messages of types such as text, pictures, symbols, emoticons, voice, video, etc., which are not limited here. Optionally, the edited first communication message can generate a sending operation for the first communication message through the sending control in the target communication client, and in response to the sending operation, the first terminal can send the first communication message to the blockchain, wherein the sending status of the first communication message can be synchronously obtained according to whether the first communication message is sent successfully.

[0094] It should be noted that, in response to the sending operation of the first communication message, the first terminal can first write the first communication message into the database of the first terminal, and then send the first communication message to the blockchain, and determine the sending status of the first communication message according to the interaction with the blockchain.

[0095] S302: Display prompt information of the first communication message according to the sending status of the first communication message.

[0096] Based on the above description, after obtaining the sending status of the first communication message, optionally, prompt information related to the first communication message can be synchronously displayed on the first terminal so that the user can make further adjustment operations through the prompt information, thereby improving the user experience of the data communication method of the present application.

[0097] Figure 4 A flowchart of another blockchain-based data communication method provided in an embodiment of the present application. Optionally, Figure 4 As shown, according to the sending status of the first communication message, the prompt information of the first communication message is displayed, including:

[0098] S401: If it is determined that the sending status of the first communication message is not submitted for uplink or has been submitted but not successfully uploaded, indicate through prompt information that the first communication message is being sent but the next communication message can be input.

[0099] Among them, if the prompt information indicates that the first communication message is being sent but the next message can be continuously input, it means that the user can continue to input the next communication message. It is worth noting that at this time the user can continue to input one or more communication messages, and the number of communication messages continuously input is not limited.

[0100] Compared with the prior art, when the first communication message is not uploaded to the chain, the user can continuously input and send the next communication message through the first terminal, that is, the present application can realize parallel sending, and by applying the embodiments of the present application, when multiple communication messages continuously sent by the first terminal are displayed through the second terminal, the problem of disorderly display of the multiple communication messages can be avoided, that is, the display order of the multiple communication messages on the second terminal can be guaranteed to be consistent with the sending order of the multiple communication messages on the first terminal, which can improve the applicability of the method of the present application.

[0101] S402: If it is determined that the sending status of the first communication message is already on the chain, indicate through prompt information that the first communication message has been sent.

[0102] In some embodiments, if it is determined that the sending status of the first communication message is uploaded, a prompt message indicating that the first communication message has been sent can be displayed so that the user can know the sending status of the first communication message in time, thereby improving the user experience of the present application.

[0103] It should be noted that the present application does not limit the prompting method of the prompting information. The prompting method of the prompting information can refer to the prompting method of the above-mentioned target status prompting information, which will not be repeated here.

[0104] Figure 5 A flowchart of another data communication method based on blockchain provided in an embodiment of the present application. Optionally, Figure 5 As shown, in response to the sending operation of the first communication message, sending the first communication message to the blockchain includes:

[0105] S501: In response to a sending operation of a first communication message, generate a message header of the first communication message according to a preset message protocol.

[0106] The message header includes: a message protocol version identifier, a first terminal identifier, a current local timestamp of the first terminal, and a first communication message identifier.

[0107] Among them, communication messages can be transmitted between the first terminal and the blockchain based on a preset message protocol. Optionally, the preset message protocol can specify the message header of the communication message in the following format, as follows: |version|deviceId|timestamp|uuid|, wherein version can indicate the message protocol version identifier, deviceId can indicate the sending terminal identifier corresponding to the communication message, timestamp can indicate the local timestamp of the sending terminal corresponding to the communication message, and uuid can indicate the communication message identifier. Optionally, uuid can be determined according to the communication message, and different communication messages will correspond to different uuids.

[0108] Based on the definition of the preset message protocol, for the first communication message, the first terminal can determine the message header of the first communication message according to the preset message protocol in response to the sending operation of the first communication message. It is worth noting that, since the first communication message has not yet been uploaded to the link, the message header of the first communication message generated at this time does not include the upload timestamp of the first communication message.

[0109] S502. According to the message header of the first communication message, the first communication message is sent to the blockchain, so that the blockchain performs an on-chain operation after receiving the first communication message, appends on-chain attributes to the first communication message according to the on-chain time of the first communication message, and writes the first communication message into the target communication channel, wherein the on-chain attributes include an on-chain timestamp.

[0110] Based on the message header of the first communication message determined above, the content of the first communication message can be used as the message body to send the first communication message to the blockchain. For the blockchain, after receiving the first communication message, the blockchain can perform a chain operation, and when the first communication message is successfully chained, the chain time of the first communication message is obtained, and the chain attribute is added to the first communication message according to the chain time, and the first communication message is written into the target communication channel.

[0111] It is worth noting that after the first communication message is written into the target communication channel, if the first terminal queries and obtains the latest communication message in the target communication channel at this time, then the aforementioned target communication message will be obtained at this time, wherein each target communication message includes preset message attributes. For the subsequent explanation of this part, please refer to the aforementioned relevant part, which will not be repeated here.

[0112] Figure 6 A flowchart of another blockchain-based data communication method provided in an embodiment of the present application. Optionally, Figure 6 As shown, the above method also includes:

[0113] S601. Receive a notification of the blockchain being uploaded after determining that the first communication message is successfully uploaded to the blockchain.

[0114] S602: Generate a query operation for the target communication channel through the on-chain notification, and send a query request to the blockchain through the callback function in the on-chain notification.

[0115] Based on the above embodiment, if the blockchain determines that the first communication message is successfully uploaded to the chain, a notification of the upload can be sent to the first terminal, and the notification of the upload can include a callback function; further, the first terminal can generate a query operation for the target communication channel according to the notification of the upload, and send a query request to the blockchain through the callback function.

[0116] Optionally, for the target communication channel, it can store the target communication messages in the historical communication process between the first terminal and the second terminal, wherein each target communication message can correspond to an index. In some embodiments, during a specific query, the callback function can carry the index of the latest target communication message currently received by the first terminal, so that when performing a query, the unreceived target communication messages can be queried based on the index of the latest target communication message currently received, thereby avoiding repeated queries for the same target communication message, thereby improving the communication efficiency of the method of the present application.

[0117] For example, assume that the first terminal U1 continuously sends A, B and C communication messages, and the other party continuously sends a, b and c communication messages through the second terminal U2, and each communication message carries the sending terminal identifier and the sending terminal local timestamp. Optionally, if the first terminal obtains the order of communication messages in the target communication channel by querying the target communication channel: a, B, A, b, C, c, the order of communication messages in the target communication channel is sorted in sequence according to the uplink time.

[0118] In combination with the above embodiments, for the first terminal, since communication messages B and A correspond to the same sending terminal, that is, both correspond to the first terminal, when communication messages B and A are displayed on the first terminal, the display order of the two is determined according to the local timestamps of the sending terminals corresponding to communication messages B and A respectively. It can be understood that through analysis, it can be seen that the display order of communication message A should be before communication message B; for communication messages a and A, since the two correspond to different sending terminals, it is necessary to determine the display order of the two communication messages in the first terminal according to the uplink timestamps of the two respectively. Through analysis, it can be seen that the display order of communication message a should be before communication message A.

[0119] In addition, in some embodiments, for communication message A, if the sending status of communication message A is not submitted to the chain or submitted but not successfully uploaded to the chain, it can be prompted in the communication interface that communication message A is being sent, but the next communication message can be entered; if the sending status of communication message A is submitted but not successfully uploaded to the chain, communication message A can be inserted into the communication dialog box and displayed as received; if the sending status of communication message A is uploaded to the chain, a prompt message that communication message A has been sent can be displayed in the communication interface. For other communication messages, please refer to the description of this part, which will not be repeated here.

[0120] In summary, by applying the embodiments of the present application, the consistency of the display order of communication messages during the data communication process between the first terminal and the second terminal can be ensured.

[0121] In addition, it should be noted that the above embodiment of the present application is described by taking the communication process of two terminals as an example. Of course, according to the actual application scenario, the present application can also be applied to the terminal process of multiple terminals. When applied to multiple terminals, each terminal can refer to the method of the present application to display multiple target communication messages in order.

[0122] Figure 7 This is a functional module diagram of a blockchain-based data communication device provided in an embodiment of the present application. The device can be applied to a first terminal. The basic principle and technical effects of the device are the same as those of the corresponding method embodiment described above. For the sake of brief description, the parts not mentioned in this embodiment can be referred to the corresponding contents in the method embodiment. Figure 7 As shown, the data communication device 100 includes:

[0123] A response module 110, configured to send a query request to the blockchain in response to a query operation on a target communication channel, wherein the target communication channel is a communication channel between the first terminal and the second terminal;

[0124] The receiving module 120 is used to receive the query result returned by the blockchain according to the query request, wherein the query result includes at least one target communication message, wherein each target communication message includes preset message attributes, and the preset message attributes include: a sending terminal identifier corresponding to the target communication message, a local timestamp of the sending terminal, and an on-chain timestamp;

[0125] The determination module 130 is used to determine the display order of each target communication message according to the preset message attribute of each target communication message, and display each target communication message on the preset communication interface according to the display order of each target communication message.

[0126] In an optional implementation manner, the target communication message includes multiple messages, and the determination module 130 is specifically configured to obtain preset message attributes of any two target communication messages among the multiple target communication messages;

[0127] If it is determined according to the preset message attribute that the terminal identifiers corresponding to the arbitrary two target communication messages are the same, then the display order of the arbitrary two target communication messages is determined according to the local timestamp of the sending terminal of each of the arbitrary two target communication messages;

[0128] If it is determined according to the preset message attribute that the terminal identifiers corresponding to the arbitrary two target communication messages are different, the display order of the arbitrary two target communication messages is determined according to the uplink timestamp of each of the arbitrary two target communication messages.

[0129] In an optional embodiment, the determination module 130 is specifically used to display target status prompt information when displaying any of the target communication messages on the preset communication interface if the preset message attributes of any of the target communication messages indicate that the sending terminal identifier of any of the target communication messages is the second terminal identifier, and the target status prompt information is used to indicate that any of the target communication messages has been received.

[0130] In an optional implementation, the response module 110 is further configured to, in response to a sending operation of the first communication message, send the first communication message to the blockchain, and obtain a sending status of the first communication message, wherein the sending status includes: not submitted to the blockchain, submitted but not successfully uploaded to the blockchain, and uploaded to the blockchain;

[0131] According to the sending status of the first communication message, prompt information of the first communication message is displayed.

[0132] In an optional implementation, the response module 110 is further configured to indicate through the prompt information that the first communication message is being sent, but the next communication message can be input if it is determined that the sending status of the first communication message is not submitted for uplinking or has been submitted but not successfully uploaded for uplinking;

[0133] If it is determined that the sending status of the first communication message is already on the link, the prompt information indicates that the first communication message has been sent.

[0134] In an optional implementation, the response module 110 is further configured to generate a message header of the first communication message according to a preset message protocol in response to a sending operation of the first communication message, wherein the message header includes: a message protocol version identifier, a first terminal identifier, a current local timestamp of the first terminal, and a first communication message identifier;

[0135] According to the message header of the first communication message, the first communication message is sent to the blockchain, so that the blockchain performs an on-chain operation after receiving the first communication message, appends on-chain attributes to the first communication message according to the on-chain time of the first communication message, and writes the first communication message into the target communication channel, wherein the on-chain attributes include an on-chain timestamp.

[0136] In an optional implementation, the response module 110 is further configured to receive a notification of the blockchain being uploaded after determining that the first communication message is uploaded successfully;

[0137] A query operation for the target communication channel is generated through the on-chain notification, and a query request is sent to the blockchain through a callback function in the on-chain notification.

[0138] The above-mentioned device is used to execute the method provided by the aforementioned embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.

[0139] The above modules may be one or more integrated circuits configured to implement the above methods, such as one or more application specific integrated circuits (ASICs), or one or more microprocessors, or one or more field programmable gate arrays (FPGAs). For another example, when a module is implemented in the form of a processing element scheduling program code, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).

[0140] Figure 8 The following is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device can be integrated into the above-mentioned data communication device. Figure 8 As shown, the electronic device may include: a processor 210, a storage medium 220 and a bus 230, the storage medium 220 stores machine-readable instructions executable by the processor 210, when the electronic device is running, the processor 210 and the storage medium 220 communicate through the bus 230, and the processor 210 executes the machine-readable instructions to perform the steps of the above method embodiment. The specific implementation method and technical effect are similar and will not be repeated here.

[0141] Optionally, the present application further provides a storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above method embodiment are executed. The specific implementation method and technical effect are similar and will not be repeated here.

[0142] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation, such as 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 mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0143] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0144] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0145] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (English: processor) to perform some steps of the methods of each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (English: Read-Only Memory, abbreviated: ROM), random access memory (English: Random Access Memory, abbreviated: RAM), disk or optical disk and other media that can store program codes.

[0146] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0147] The above are only preferred embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application. It should be noted that similar numbers and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. The above are only preferred embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.

Claims

1. A data communication method based on blockchain, characterized in that: Applied to a first terminal, the method includes: In response to a query operation on a target communication channel, sending a query request to a blockchain, wherein the target communication channel is a communication channel between the first terminal and the second terminal; Receiving a query result returned by the blockchain according to the query request, the query result including at least one target communication message, wherein each target communication message includes preset message attributes, and the preset message attributes include: a sending terminal identifier corresponding to the target communication message, a local timestamp of the sending terminal, and an on-chain timestamp; Determining a display order of each of the target communication messages according to a preset message attribute of each of the target communication messages, and displaying each of the target communication messages on a preset communication interface according to the display order of each of the target communication messages; The step of determining the display order of each of the target communication messages according to the preset message attribute of each of the target communication messages comprises: If it is determined according to the preset message attributes that the terminal identifiers corresponding to any two target communication messages are the same, then the display order of the any two target communication messages is determined according to the local timestamp of the sending terminal of each of the any two target communication messages; If it is determined according to the preset message attribute that the terminal identifiers corresponding to any two target communication messages are different, the display order of the any two target communication messages is determined according to the uplink timestamp of each of the any two target communication messages.

2. The method according to claim 1, characterized in that: The target communication message includes a plurality of messages, and the method further includes: The preset message attributes of any two target communication messages among the multiple target communication messages are obtained.

3. The method according to claim 1, characterized in that The displaying of each target communication message on the preset communication interface includes: If the preset message attribute of any of the target communication messages indicates that the sending terminal identifier of any of the target communication messages is the second terminal identifier, target status prompt information is displayed when any of the target communication messages is displayed on the preset communication interface, and the target status prompt information is used to indicate that any of the target communication messages has been received.

4. The method according to any one of claims 1 to 3, characterized in that: In response to the query operation on the target communication channel, before sending the query request to the blockchain, the method further includes: In response to the sending operation of the first communication message, the first communication message is sent to the blockchain, and the sending status of the first communication message is obtained, wherein the sending status includes: not submitted to the blockchain, submitted but not successfully uploaded to the blockchain, and uploaded to the blockchain; According to the sending status of the first communication message, prompt information of the first communication message is displayed.

5. The method according to claim 4, characterized in that The displaying prompt information of the first communication message according to the sending status of the first communication message includes: If it is determined that the sending status of the first communication message is not submitted for uplink or has been submitted but not successfully uploaded, indicating through the prompt information that the first communication message is being sent but the next communication message can be input; If it is determined that the sending status of the first communication message is already on the link, the prompt information indicates that the first communication message has been sent.

6. The method according to claim 4, characterized in that The step of sending the first communication message to the blockchain in response to the sending operation of the first communication message includes: In response to the sending operation of the first communication message, a message header of the first communication message is generated according to a preset message protocol, the message header including: a message protocol version identifier, a first terminal identifier, a current local timestamp of the first terminal, and a first communication message identifier; According to the message header of the first communication message, the first communication message is sent to the blockchain, so that the blockchain performs an on-chain operation after receiving the first communication message, appends on-chain attributes to the first communication message according to the on-chain time of the first communication message, and writes the first communication message into the target communication channel, wherein the on-chain attributes include an on-chain timestamp.

7. The method according to claim 6, characterized in that The method further comprises: Receiving a notification of chaining sent by the blockchain after determining that the first communication message is successfully chained; A query operation for the target communication channel is generated through the on-chain notification, and a query request is sent to the blockchain through a callback function in the on-chain notification.

8. A data communication device based on blockchain, characterized in that: Applied to a first terminal, the device includes: A response module, configured to send a query request to the blockchain in response to a query operation on a target communication channel, wherein the target communication channel is a communication channel between the first terminal and the second terminal; A receiving module, configured to receive a query result returned by the blockchain according to the query request, wherein the query result includes at least one target communication message, wherein each target communication message includes preset message attributes, and the preset message attributes include: a sending terminal identifier corresponding to the target communication message, a local timestamp of the sending terminal, and an on-chain timestamp; A determination module, configured to determine a display order of each of the target communication messages according to a preset message attribute of each of the target communication messages, and display each of the target communication messages on a preset communication interface according to the display order of each of the target communication messages; The determination module is specifically configured to determine the display order of any two target communication messages according to the local timestamp of the sending terminal of each of the two target communication messages if it is determined according to the preset message attributes that the terminal identifiers corresponding to the two target communication messages are the same; If it is determined according to the preset message attributes that the terminal identifiers corresponding to any two target communication messages are different, the display order of the any two target communication messages is determined according to the uplink timestamp of each of the any two target communication messages.

9. An electronic device, characterized in that: include: A processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the storage medium through the bus, and the processor executes the machine-readable instructions to perform the steps of the blockchain-based data communication method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, the steps of the blockchain-based data communication method as described in any one of claims 1 to 7 are executed.