CN111245745B - Message sending method, device, node equipment and storage medium - Google Patents

Message sending method, device, node equipment and storage medium Download PDF

Info

Publication number
CN111245745B
CN111245745B CN202010015541.7A CN202010015541A CN111245745B CN 111245745 B CN111245745 B CN 111245745B CN 202010015541 A CN202010015541 A CN 202010015541A CN 111245745 B CN111245745 B CN 111245745B
Authority
CN
China
Prior art keywords
sending
message
queue
target
priority
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010015541.7A
Other languages
Chinese (zh)
Other versions
CN111245745A (en
Inventor
刘攀
李茂材
王宗友
蓝虎
周开班
孔利
时一防
朱耿良
刘区城
杨常青
张劲松
黄焕坤
崔嘉辉
廖志勇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202010015541.7A priority Critical patent/CN111245745B/en
Publication of CN111245745A publication Critical patent/CN111245745A/en
Application granted granted Critical
Publication of CN111245745B publication Critical patent/CN111245745B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/50Queue scheduling
    • H04L47/62Queue scheduling characterised by scheduling criteria
    • H04L47/625Queue scheduling characterised by scheduling criteria for service slots or service orders
    • H04L47/6275Queue scheduling characterised by scheduling criteria for service slots or service orders based on priority
    • 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
    • G06F9/546Message passing systems or structures, e.g. queues
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/548Queue
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L2209/00Additional information or applications relating to cryptographic mechanisms or cryptographic arrangements for secret or secure communication H04L9/00
    • H04L2209/46Secure multiparty computation, e.g. millionaire problem
    • H04L2209/463Electronic voting
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/50Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols using hash chains, e.g. blockchains or hash trees

Abstract

The application provides a message sending method, a message sending device, node equipment and a storage medium, and belongs to the technical field of block chains. Node equipment applied to a blockchain system, the method comprising: receiving target messages sent by other node equipment in the block chain system, and determining the message priority of the target messages; distributing the target message to a target sending queue matched with the message priority in at least two sending queues; and sending the messages in the at least two sending queues according to the sending priority of each sending queue in the at least two sending queues. The node device in the block chain system distributes the target message to different sending queues according to the received message priority of the target message sent by other node devices in the block chain system, and then sends the message according to different sending priorities, so that important messages, such as consensus messages, can be sent out preferentially, and the consensus efficiency of the whole block chain system is improved.

Description

Message sending method, device, node equipment and storage medium
Technical Field
The present application relates to the field of block chain technologies, and in particular, to a message sending method, an apparatus, a node device, and a storage medium.
Background
The blockchain system is a distributed system, and the consensus mechanism is an indispensable ring in the blockchain system, and can assist in keeping data consistency among nodes in the blockchain system through the consensus mechanism, that is, solve the consistency problem of the distributed system. The consensus mechanism is simply a voting mechanism, since the voting node needs to send its voting result to other nodes and receive the voting result sent by other nodes. I.e. the nodes communicate with each other to achieve consensus.
In the related art, when nodes of a block chain system communicate with each other, a communication connection is often established, and a sending node sending a message sends the message to a destination node according to a first-come first-sent sequence. If the node loses the consensus information, the consensus efficiency of the whole block chain is affected.
Disclosure of Invention
The embodiment of the application provides a message sending method, a message sending device, node equipment and a storage medium, so that important messages such as consensus messages can be sent out preferentially, and the consensus efficiency of the whole block chain is improved.
The technical scheme is as follows:
in one aspect, a message sending method is provided, where the message sending method is applied to a node device in a block chain system, and the method includes:
receiving target messages sent by other node devices in the block chain system, and determining the message priority of the target messages, wherein the message priority is used for indicating the sending sequence of the messages;
distributing the target message to a target sending queue matched with the message priority in at least two sending queues;
and sending the messages in the at least two sending queues according to the sending priority of each sending queue in the at least two sending queues.
In one aspect, a message sending apparatus is provided, and is applied to a node device in a blockchain system, where the apparatus includes:
a message receiving module, configured to receive a target message sent by other node devices in the blockchain system, and determine a message priority of the target message, where the message priority is used to indicate a sending order of the messages;
the message distribution module is used for distributing the target message to a target sending queue matched with the message priority in at least two sending queues;
And the message sending module is used for sending the messages in the at least two sending queues according to the sending priority of each sending queue in the at least two sending queues.
In an optional implementation manner, the message receiving module is further configured to query, according to a message type of the target message, a message priority corresponding to the message type; and taking the message priority corresponding to the message type as the message priority of the target message.
In an optional implementation manner, the correspondence between the message type and the message priority may be:
the message priority corresponding to the consensus message is a high-level priority;
the message priority corresponding to the transaction pool synchronous message is a middle priority;
the message priority corresponding to the heartbeat message between the node device block synchronization message and the node device is low-level priority.
In an optional implementation manner, the message distribution module is further configured to distribute the target message to a first target sending queue if the first target sending queue matched with the message priority is not full; and if the first target sending queue is full and the first target sending queue is not the sending queue with the lowest sending priority, inserting the target message into a second target sending queue with the sending priority adjacent to and lower than the first target sending queue.
In an optional implementation manner, the first target transmission queue is a transmission queue with the highest transmission priority;
the message distribution module is further configured to insert the target message into the second target sending queue if the second target sending queue is not full; and if the second target sending queue is full, caching the target message, and stopping sending the messages in the sending queue with the sending priority lower than that of the first target sending queue.
In an optional implementation manner, after the caching the target message, the apparatus further includes:
and the detection module is used for detecting the first target sending queue, and if the first target sending queue is not full, the target message is distributed to the first target sending queue.
In an optional implementation manner, the first target sending queue is not a sending queue with the highest sending priority;
the message distribution module is further configured to insert the target message into the second target sending queue if the second target sending queue is not full; if the second target send queue is full, discarding the target message.
In an optional implementation manner, the apparatus further includes:
and the message abandon module is used for abandoning the target message if the first target sending queue is full and the first target sending queue is the sending queue with the lowest sending priority.
In an optional implementation manner, the message sending module is further configured to send a message in a first sending queue, where the first sending queue is a sending queue with the highest sending priority among the at least two sending queues; and if the messages in the first sending queue are sent completely, sending the messages in a second sending queue, wherein the second sending queue is a sending queue with adjacent sending priority and lower than the first sending queue.
In an optional implementation manner, the message sending module is further configured to send the message in the first sending queue if the message in the second sending queue is sent completely and the first sending queue is not empty.
In an optional implementation manner, the message sending module is further configured to send a message in a third sending queue if the message in the second sending queue is sent completely and the first sending queue is empty, where the third sending queue is a sending queue whose sending priority is adjacent to and lower than the second sending queue.
In an optional implementation manner, the third sending queue is a sending queue with the lowest sending priority;
the message sending module is further configured to send a message in the third sending queue; and detecting the first sending queue and the second sending queue, and if any one of the first sending queue and the second sending queue is not empty, sending the messages in the first sending queue and the second sending queue.
In an optional implementation manner, the message sending module is configured to send a message in the third sending queue if the first sending queue and the second sending queue are both empty; and detecting the first sending queue and the second sending queue again until any one of the first sending queue and the second sending queue is not empty or the third sending queue is empty.
In one aspect, a node device is provided, where the node device includes a processor and a memory, and the memory is configured to store at least one piece of program code, where the at least one piece of program code is loaded and executed by the processor to implement operations performed in a message sending method in an embodiment of the present application.
In one aspect, a storage medium is provided, where at least one section of program code is stored in the storage medium, and the at least one section of program code is used to execute a message sending method in this embodiment.
The technical scheme provided by the embodiment of the application has the following beneficial effects:
in the embodiment of the application, the node device in the blockchain system allocates the target message to different sending queues according to the received message priority of the target message sent by other node devices in the blockchain system, and then sends the message according to different sending priorities, so that important messages, such as consensus messages, can be sent out preferentially, and the consensus efficiency of the whole blockchain system is improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a system architecture diagram of a block chain system according to an embodiment of the present application;
Fig. 2 is a schematic structural diagram of a block chain according to an embodiment of the present application;
FIG. 3 is a flow chart of a new block generation provided according to an embodiment of the present application;
FIG. 4 is a functional architecture diagram of a node device in a blockchain system according to an embodiment of the present application;
fig. 5 is a flowchart of a message sending method according to an embodiment of the present application;
FIG. 6 is a flow chart of a method for distributing a target message according to an embodiment of the present application;
FIG. 7 is a flow chart of sending messages in send queues according to an embodiment of the present application;
fig. 8 is a block diagram of a message sending apparatus according to an embodiment of the present application;
fig. 9 is a schematic structural diagram of a terminal provided in an embodiment of the present application;
fig. 10 is a schematic structural diagram of a computer device provided according to an embodiment of the present application.
Detailed Description
To make the objects, technical solutions and advantages of the present application more clear, embodiments of the present application will be described in further detail below with reference to the accompanying drawings.
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
Hereinafter, terms related to the present application are explained.
Block chain (English: blockchain): the method is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. The blockchain is essentially a decentralized database, which is a string of data blocks associated by using cryptography, each data block contains information of a batch of network transactions, and the information is used for verifying the validity (anti-counterfeiting) of the information and generating the next block. The blockchain may include a blockchain underlying platform, a platform product services layer, and an application services layer.
The block chain underlying platform can comprise processing modules such as user management, basic service, intelligent contract and operation monitoring. The user management module is responsible for identity information management of all blockchain participants, and comprises public and private key generation maintenance (account management), key management, user real identity and blockchain address corresponding relation maintenance (authority management) and the like, and under the authorization condition, the user management module supervises and audits the transaction condition of certain real identities and provides rule configuration (wind control audit) of risk control; the basic service module is deployed on all block chain node equipment and used for verifying the validity of the service request, recording the service request to storage after the effective request is identified in a consensus, and for a new service request, the basic service firstly performs interface adaptation analysis and authentication processing (interface adaptation), then encrypts service information (consensus management) through a consensus algorithm, transmits the encrypted service information to a shared account (network communication) completely and consistently, and records and stores the encrypted service information; the intelligent contract module is responsible for registering and issuing contracts, triggering the contracts and executing the contracts, developers can define contract logics through a certain programming language, issue the contract logics to a block chain (contract registration), call keys or other event triggering and executing according to the logics of contract clauses, complete the contract logics and simultaneously provide the function of upgrading and canceling the contracts; the operation monitoring module is mainly responsible for deployment, configuration modification, contract setting, cloud adaptation in the product release process and visual output of real-time states in product operation, such as: alarm, monitoring network conditions, monitoring node equipment health status, and the like.
The platform product service layer provides basic capability and an implementation framework of typical application, and developers can complete block chain implementation of business logic based on the basic capability and the characteristics of the superposed business. The application service layer provides the application service based on the block chain scheme to the business participants for use.
Consensus mechanism (English: consensus mechanism): the mathematical algorithm is used for establishing trust and obtaining rights and interests among different nodes in a block chain system. In the block chain system, the verification and confirmation of the transaction can be completed in a short time through the voting of the special node devices, and if a plurality of node devices with irrelevant benefits can achieve the consensus, all the node devices in the system can also achieve the consensus.
Smart contract (english: smart contract): is a computer protocol intended to propagate, validate or execute contracts in an informational manner. Each node device in the blockchain system can automatically execute a contract program according to a specific condition, can operate data stored in the chain, and is an important way for a user to interact with the blockchain and realize business logic by using the blockchain. The goal of smart contracts is to provide a secure method over traditional contracts and to reduce other transaction costs associated with the contracts, which allows for trusted transactions that are traceable and irreversible without third parties.
Public key (public key) and private key (private key): is a key pair (i.e., a public key and a private key) obtained by an algorithm, the public key being a public part of the key pair, and the private key being a private part. Public keys are typically used to encrypt data, verify digital signatures, and the like. By means of this algorithm it is ensured that the resulting key pair is unique, and that when using this key pair, if one of the keys is used to encrypt a piece of data, the other key must be used to decrypt it, e.g. if the data is encrypted with the public key, the private key must be used to decrypt it, and if the data is encrypted with the private key, the public key must be used to decrypt it, otherwise the decryption will not succeed.
The message sending method provided by the embodiment of the application can be applied to a scene that the node equipment in the block chain system sends messages to other node equipment in the block chain system. In a blockchain system, communication between node devices may be achieved by establishing a communication connection between the node devices. For any node device in the blockchain system, the node device may receive messages sent by other node devices in the blockchain system, and may also send messages to other node devices. Because the node device has limited caching capability, that is, only a part of the received messages can be cached, if the node device receives too many messages and the messages received by the node device are not completely sent, the node device can lose the messages sent by other node devices. Certainly, the message lost by the node device may be retransmitted after a period of time, if the importance degree of the lost message is not high, the influence on the block chain system is not great, and if the importance degree of the lost message is high, such as a consensus message, the block chain consensus may not be consistent, and further, the consensus needs to be performed again, which causes a problem of slow service response. Even for some consensus algorithms, the loss of the consensus message may cause the failure of the consensus survival, resulting in the stop of the service availability, which has a large impact on the blockchain system.
The following describes main steps of a message sending method provided in an embodiment of the present application. For any node device in the block chain system, the node device can divide the messages into different message priorities and then configure at least two sending queues, wherein each sending queue is matched with one message priority. Correspondingly, the transmission queue also has a transmission priority, the transmission queue with a high transmission priority is matched with the transmission queue with a high message priority, and the transmission queue with a low transmission priority is matched with the transmission queue with a low message priority. The node device may allocate the received target message to different transmission queues, and then transmit the target message respectively. Optionally, the node device may divide the message into a message of a high priority, a message of a medium priority, and a message of a low priority, and the transmission priority of the corresponding transmission queue may be divided into a high transmission priority, a medium transmission priority, and a low transmission priority. The node apparatus may allocate a message of a high priority to a transmission queue of a high transmission priority, allocate a message of a medium priority to a transmission queue of a medium transmission priority, and allocate a message of a low priority to a transmission queue of a low transmission priority.
The present embodiment provides a blockchain system 100 implemented based on the above-mentioned blockchain technique, and a system architecture of the blockchain system is described below.
Referring to fig. 1, the blockchain system may include a plurality of node apparatuses 101, and may further include a client.
Node device 101 may be any form of computing device in a network, such as a server, a host, a user terminal, etc. The node apparatus 101 and the node apparatus 101 can share data therebetween. Among them, the node devices 101 may establish a P2P network based on a Peer-To-Peer (P2P) protocol. The P2P Protocol is an application layer Protocol that runs on top of the Transmission Control Protocol (TCP) Protocol.
Each node apparatus 101 may receive input information during normal operation, and maintain shared data in the blockchain system based on the received input information. In order to ensure information intercommunication in the blockchain system, information connection can exist between each node device in the blockchain system, and information transmission can be carried out between the node devices through the information connection. For example, when any node device in the blockchain system receives input information, other node devices in the blockchain system acquire the input information according to a consensus algorithm, and store the input information as data in shared data, so that the data stored in all the node devices in the blockchain system are consistent.
Each node device in the blockchain system has a node device identifier corresponding thereto, and each node device in the blockchain system can store node device identifiers of other node devices in the blockchain system, so that the generated block is broadcast to other node devices in the blockchain system according to the node device identifiers of the other node devices in the subsequent process. Each node device may maintain a node device identifier list as shown in table 1 below, and store the node device name and the node device identifier in the node device identifier list correspondingly. The node device identifier may be an IP (Internet Protocol) address and any other information that can be used to identify the node device, and table 1 only illustrates the IP address as an example.
TABLE 1
Node device name Node device identification
Node device 1 117.114.151.174
Node device 2 117.116.189.145
Node device N 119.123.789.258
Each node device in the blockchain system stores one identical blockchain. The block chain is composed of a plurality of blocks, referring to fig. 2, the block chain is composed of a plurality of blocks, the starting block includes a block header and a block main body, the block header stores an input information characteristic value, a version number, a timestamp and a difficulty value, and the block main body stores input information; the next block of the starting block takes the starting block as a parent block, the next block also comprises a block head and a block main body, the block head stores the input information characteristic value of the current block, the block head characteristic value of the parent block, the version number, the timestamp and the difficulty value, and the like, so that the block data stored in each block in the block chain is associated with the block data stored in the parent block, and the safety of the input information in the block is ensured.
When each block in the block chain is generated, referring to fig. 3, when the node device where the block chain is located receives input information, the input information is verified, after the verification is completed, the input information is stored in the memory pool, and the hash tree for recording the input information is updated; and then, updating the updating time stamp to the time when the input information is received, trying different random numbers, and calculating the characteristic value for multiple times, so that the calculated characteristic value can meet the following formula:
SHA256(SHA256(version+prev_hash+merkle_root+ntime+nbits+x))<TARGET
wherein SHA256 is a characteristic value algorithm used for calculating a characteristic value; version is version information of the relevant block protocol in the block chain; prev _ hash is a block head characteristic value of a parent block of the current block; merkle _ root is a characteristic value of the input information; ntime is the update time of the update timestamp; nbits is the current difficulty, is a fixed value within a period of time, and is determined again after exceeding a fixed time period; x is a random number; TARGET is a feature threshold, which can be determined from nbits.
Therefore, when the random number meeting the formula is obtained through calculation, the information can be correspondingly stored, and the block head and the block main body are generated to obtain the current block. And then, the node equipment where the block chain is located respectively sends the newly generated blocks to other node equipment in the block chain system where the newly generated blocks are located according to the node equipment identifications of the other node equipment in the block chain system, the newly generated blocks are verified by the other node equipment, and the newly generated blocks are added to the block chain stored by the newly generated blocks after the verification is completed.
The functional architecture of the node apparatus 101 in the block chain system will be described below.
Referring to fig. 4, the node device 101 may be functionally divided into a hardware layer, an intermediate layer, an operating system layer and an application layer, and the specific functions involved may be as follows:
1) routing, a basic function that the node device has for supporting communication between the node devices.
The node device may have the following functions in addition to the routing function:
2) the application is used for being deployed in a block chain, realizing specific services according to actual service requirements, recording data related to the realization functions to form recording data, carrying a digital signature in the recording data to represent a source of task data, and sending the recording data to other node equipment in the block chain system for the other node equipment to add the recording data to a temporary block when the source and integrity of the recording data are verified successfully.
For example, the services implemented by the application include:
2.1) wallet, for providing the function of transaction of electronic money, including initiating transaction (i.e. sending the transaction record of current transaction to other node devices in the blockchain system, after the other node devices are successfully verified, writing the record data of transaction into the temporary blocks of the blockchain as the response of affirming that the transaction is valid; of course, the wallet also supports the querying of the electronic money remaining in the electronic money address.
2.2) the shared account book is used for providing functions of operations such as storage, query and modification of account data, sending the record data of the operations on the account data to other node devices in the block chain system, writing the record data into a temporary block as a response for acknowledging that the account data is valid after the other node devices verify the validity, and also sending confirmation to the node device initiating the operations.
2.3) Intelligent contracts, computerized agreements, which can execute the terms of a certain contract, are realized by codes deployed on a shared account for execution when certain conditions are met, are used for completing automated transactions according to actual business requirement codes, such as inquiring the logistics status of goods purchased by a buyer, and transferring the electronic money of the buyer to the address of a merchant after the buyer signs the goods; of course, intelligent contracts are not limited to executing contracts for trading, but may also execute contracts that process received information.
3) And the Block chain comprises a series of blocks (blocks) which are mutually connected according to the generated chronological order, new blocks cannot be removed once being added into the Block chain, and the blocks record the record data submitted by the node equipment in the Block chain system.
It is understood that the method steps provided by the embodiments of the present application can be executed by a computer device, including but not limited to a server or a terminal. A node device may also be referred to as a computer device.
Fig. 5 is a flow chart of a message sending method according to an embodiment of the present application, and as shown in fig. 5, in the embodiment of the present application, a node device applied in a blockchain system is taken as an example for description. The message sending method comprises the following steps:
501. the node equipment receives target messages sent by other node equipment in the block chain system, and determines the message priority of the target messages, wherein the message priority is used for indicating the sending sequence of the messages.
In this embodiment of the present application, node devices in a blockchain system may communicate with each other, and any node device may receive a message broadcast by other node devices, may also broadcast the message to other node devices, and may also send the message to a specified node device according to a stored node device identifier of other node devices.
The target message is a message received by the node device and sent by other node devices, and the node device can send the target message to other node devices after receiving the target message. The node devices may send messages of multiple message types, such as consensus messages, transaction pool synchronization messages, node device block synchronization messages, and heartbeat messages between node devices. For any target message, the node device may parse the target message, and determine the message type of the target message according to the parsed message type identifier. The node device may query, according to the message type of the target message, a message priority corresponding to the message type, and use the message priority corresponding to the message type as the message priority of the target message. For example, the node device may divide the message priority into a high priority, a medium priority and a low priority, and accordingly, the message priority corresponding to the consensus message may be the high priority, the message priority corresponding to the transaction pool synchronization message may be the medium priority, and the message priority corresponding to the heartbeat message between the node device block synchronization message and the node device may be the low priority. The node device may further divide the message priority into more levels, which is not limited in this embodiment of the present application. The message priority can be used for indicating the sending sequence of the messages, the messages with high message priority are sent preferentially, and the messages with low message priority are sent in the later sequence.
In an optional implementation manner, the node device may maintain a correspondence between a message type and a message priority, where the correspondence may be the same as or different from a correspondence maintained by other node devices in the block chain system. For example, all node devices in the blockchain system may maintain the same correspondence between message types and message priorities, that is, the message priorities of the messages of the same message type in each node device are the same. Of course, the node devices in the blockchain system may also set the correspondence between the message types and the message priorities according to the processing capabilities of the node devices, that is, the message priorities of the messages of the same message type corresponding to the node devices with different processing capabilities may be different.
For example, a node device with a weak processing capability may divide the message priority corresponding to the message type into two levels, i.e., a high-level priority level and a low-level priority level; the node device with stronger processing capability can divide the message priority corresponding to the message type into three levels, i.e. high-level priority, medium-level priority and low-level priority. For messages of the type transaction pool synchronization message, the message priority in the less capable node device is a high level priority, and the message priority in the more capable node device is a medium level priority.
502. And the node equipment distributes the target message to a target sending queue matched with the message priority in at least two sending queues.
In the embodiment of the present application, the message priority is matched with the transmission queue, the rank division of the message priority is consistent with the transmission priority division of the transmission queue, the message priority may be divided into at least two ranks, and the corresponding transmission priority may also be divided into at least two ranks. If the node device divides the message priority into three levels of high, medium and low, the sending priority is also divided into three levels of high, medium and low, and each sending priority corresponds to at least one sending queue.
In an alternative implementation, the target sending queue with the matched message priority may be full, and the node device may allocate the target message to other sending queues. Correspondingly, the steps can be as follows: if the first target sending queue matched with the message priority is not full, the node equipment can distribute the target message to the first target sending queue; if the first target transmission queue is full, the node device may perform processing in two cases:
in the first case, if the first target sending queue is not the sending queue with the lowest sending priority, the node device may insert the target message into a second target sending queue with a sending priority adjacent to and lower than the first target sending queue. The node device may insert the target message into a head of a second target sending queue, may also insert the target message into a tail of the second target sending queue, and may also insert the target message into a front of a message in the second target sending queue, which is ranked the first and has a lower message priority than the target message.
When the first target sending queue is the sending queue with the highest sending priority, if the second target sending queue is not full, the node equipment inserts the target message into the second target sending queue; if the second target transmission queue is full, the node device may cache the target message, and stop transmitting the message in the transmission queue with the transmission priority lower than that of the first target transmission queue. I.e. only the messages in the transmission queue with the highest transmission priority are transmitted in order not to block the messages of higher priority. In addition, the node device may perform real-time detection on the first target send queue, wait for the first target send queue to release space, and if the first target send queue is not full, that is, the node device sends a message in the first target send queue, the node device may allocate the target message to the first target send queue.
When the first target sending queue is not the sending queue with the highest sending priority, that is, the first target sending queue is the sending queue with the middle priority, if the second target sending queue is not full, the node device may insert the target message into the second target sending queue, and the insertion manner is the same as that described above, and is not described again; if the second target transmission queue is full, the node device may discard the target message and wait for retransmission of the target message.
In the second case, if the first target transmission queue is the transmission queue with the lowest transmission priority, the node device may discard the target message and wait for the retransmission of the target message.
For example, referring to fig. 6, fig. 6 is a schematic diagram illustrating the received target message being allocated to different sending queues according to message priority. In fig. 6, for example, the node device divides the message priority into three levels, i.e., a high priority level, a medium priority level and a low priority level, and correspondingly, the at least two sending queues are three sending queues matched with the node device, and the three sending queues are a high priority sending queue, a medium priority sending queue and a low priority sending queue respectively according to the sending priority levels from high to low. The high-priority is matched with the high-priority sending queue, the medium-priority is matched with the medium-priority sending queue, and the low-priority is matched with the low-priority sending queue. For messages with high priority corresponding to the message type, such as consensus messages and the like, when the high-priority sending queue is not full, the node equipment distributes the messages to the high-priority sending queue; when the high-priority sending queue is full and the medium-priority sending queue is not full, the node equipment inserts the high-priority sending queue into the medium-priority sending queue; if the medium-priority sending queue is full, the node equipment caches the target message, waits for the message in the high-priority sending queue to be dequeued, and stops sending the messages in the medium-priority sending queue and the low-priority sending queue. For messages with the message types corresponding to the medium priority, such as transaction pool synchronization messages and the like, when the medium priority sending queue is not full, the node equipment distributes the messages to the medium priority sending queue; and when the medium-priority sending queue is full and the low-priority sending queue is not full, the node equipment inserts the medium-priority sending queue into the low-priority sending queue, and if the low-priority sending queue is full, the node equipment discards the target message. For messages with the message types corresponding to low priority, such as heartbeat messages between block synchronization messages of node equipment and the node equipment, the node equipment distributes the messages to a low priority sending queue when the low priority sending queue is not full; if the low-priority send queue is full, the node device discards the target message.
503. And the node equipment transmits the messages in the at least two transmission queues according to the transmission priority of each of the at least two transmission queues.
In this embodiment, the node device may preferentially read the messages in the transmission queue with the highest transmission priority, then sequentially transmit the messages in the transmission queue, and after the transmission of the messages in the transmission queue with the highest priority is completed, transmit the messages in the other transmission queues, so as to ensure that the messages with the highest priority can be reliably transmitted to other node devices in time.
In an alternative implementation manner, the node device may sequentially transmit the messages according to the transmission priority order. Correspondingly, the steps can be as follows: the node equipment sends the messages in a first sending queue, the first sending queue is the sending queue with the highest sending priority in at least two sending queues, if the messages in the first sending queue are sent completely, the messages in a second sending queue are sent, and the second sending queue is the sending queue with the adjacent sending priority and lower than the first sending queue. After the node device finishes sending the message in the second sending queue, the node device may further continue to send the message in a third sending queue, where the third sending queue is a sending queue whose sending priority is adjacent to and lower than the second sending queue. And repeating the above steps until the message in the sending queue with the lowest priority is sent, and at this time, the node device starts sending the message in the first sending queue again.
In an optional implementation manner, the node device may preferentially send the message in the sending queue with the higher sending priority, and send the message in the sending queue with the lower sending priority when the sending queue with the higher sending priority is empty. Correspondingly, the node device may detect the first sending queue, and if the message in the second sending queue is sent completely and the first sending queue is not empty, the node device may send the message in the first sending queue; if the message in the second sending queue is sent completely and the first sending queue is empty, the node device may send the message in the third sending queue.
It should be noted that, if the third transmit queue is the transmit queue with the lowest transmit priority, that is, the node device sets three transmit queues, which are the first transmit queue, the second transmit queue and the third transmit queue, respectively, and the first transmit queue is the transmit queue with the highest transmit priority, and the third transmit queue is the transmit queue with the lowest transmit priority. The node device may send a message in the third sending queue, then detect the first sending queue and the second sending queue, and send the message in the first sending queue and the second sending queue if any one of the first sending queue and the second sending queue is not empty; and if the first sending queue and the second sending queue are both empty, sending a message in a third sending queue. And the node equipment detects the first sending queue and the second sending queue again until any one of the first sending queue and the second sending queue is not empty or the third sending queue is empty. Changing a description mode, the node device performs a detection on the first sending queue and the second sending queue once every time it sends a message in the third sending queue, if the message to be sent is in the first sending queue or the second sending queue, the message is sent, and if the first sending queue and the second sending queue do not have a message to be sent, a message in the third sending queue is sent again until there is a message in the first sending queue or the second sending queue or the message in the third sending queue is empty, that is, there is no message to be sent in all the sending queues.
For example, referring to fig. 7, fig. 7 is a flowchart illustrating an example of a node device sending a message in each sending queue. In fig. 7, three transmission queues with priorities set by the node device are taken as an example, and are a high-priority transmission queue, a medium-priority transmission queue, and a low-priority transmission queue. The node equipment firstly judges whether the high-priority sending queue is empty, if not, the node equipment sends the messages in the high-priority sending queue, and if the high-priority sending queue is empty, the node equipment judges whether the medium-priority sending queue is empty. If the medium priority sending queue is not empty, the message in the medium priority sending queue is sent, then whether the high priority sending queue is empty or not is judged, and circulation is carried out. If the medium priority sending queue is empty, and the high priority sending queue and the medium priority sending queue are both empty, a message in the low priority queue is sent, and then whether the high priority sending queue is empty or not is judged, and circulation is carried out.
It should be noted that, the above steps 501 to 503 are an implementation manner exemplarily shown in the embodiment of the present application, and the above process may also be implemented in other manners, for example, the node device may simultaneously perform the steps of allocating the target message to the sending queue and sending the messages in each queue.
In the embodiment of the application, the node device in the blockchain system allocates the target message to different sending queues according to the received message priority of the target message sent by other node devices in the blockchain system, and then sends the message according to different sending priorities, so that important messages, such as consensus messages, can be sent out preferentially, and the consensus efficiency of the whole blockchain system is improved.
Fig. 8 is a block diagram of a message sending apparatus according to an embodiment of the present application. The message sending means may be a computer program (comprising program code) running on a computer device, for example the message sending means being an application software; the apparatus may be configured to execute corresponding steps in the message sending method provided in the embodiment of the present application, and referring to fig. 8, the apparatus includes: a message receiving module 801, a message allocating module 802, and a message sending module 803.
A message receiving module 801, configured to receive a target message sent by other node devices in the blockchain system, and determine a message priority of the target message, where the message priority is used to indicate a sending order of the message;
a message distribution module 802, configured to distribute the target message to a target sending queue, which is matched with the message priority, of the at least two sending queues;
A message sending module 803, configured to send the messages in the at least two sending queues according to the sending priority of each sending queue in the at least two sending queues.
In an optional implementation manner, the message receiving module 801 is further configured to query, according to a message type of the target message, a message priority corresponding to the message type; and taking the message priority corresponding to the message type as the message priority of the target message.
In an optional implementation manner, the correspondence between the message type and the message priority may be:
the message priority corresponding to the consensus message is a high-level priority;
the message priority corresponding to the transaction pool synchronous message is a middle priority;
the message priority corresponding to the heartbeat message between the node device block synchronization message and the node device is low-level priority.
In an optional implementation manner, the message allocating module 802 is further configured to allocate the target message to the first target sending queue if the first target sending queue whose message priority is matched is not full; and if the first target sending queue is full and the first target sending queue is not the sending queue with the lowest sending priority, inserting the target message into a second target sending queue with the sending priority adjacent to and lower than the first target sending queue.
In an optional implementation manner, the first target transmission queue is a transmission queue with the highest transmission priority;
the message distribution module 802 is further configured to insert the target message into the second target sending queue if the second target sending queue is not full; and if the second target sending queue is full, caching the target message, and stopping sending the message in the sending queue with the sending priority lower than that of the first target sending queue.
In an optional implementation manner, after the target message is cached, the apparatus further includes:
and the detection module is used for detecting the first target sending queue, and distributing the target message to the first target sending queue if the first target sending queue is not full.
In an alternative implementation, the first target transmission queue is not the transmission queue with the highest transmission priority;
the message distribution module 802 is further configured to insert the target message into the second target sending queue if the second target sending queue is not full; if the second destination send queue is full, the destination message is discarded.
In an optional implementation, the apparatus further comprises:
and the message abandoning module is used for abandoning the target message if the first target sending queue is full and the first target sending queue is the sending queue with the lowest sending priority.
In an optional implementation manner, the message sending module 803 is further configured to send a message in a first sending queue, where the first sending queue is a sending queue with the highest sending priority in the at least two sending queues; and if the messages in the first sending queue are sent completely, sending the messages in a second sending queue, wherein the second sending queue is a sending queue with adjacent sending priority and lower than the first sending queue.
In an optional implementation manner, the message sending module 803 is further configured to send the message in the first sending queue if the message in the second sending queue is sent completely and the first sending queue is not empty.
In an optional implementation manner, the message sending module 803 is further configured to send a message in a third sending queue if the message in the second sending queue is sent completely and the first sending queue is empty, where the third sending queue is a sending queue whose sending priority is adjacent to and lower than that of the second sending queue.
In an alternative implementation, the third sending queue is the sending queue with the lowest sending priority;
a message sending module 803, configured to send a message in a third sending queue; and detecting the first sending queue and the second sending queue, and if any one of the first sending queue and the second sending queue is not empty, sending the messages in the first sending queue and the second sending queue.
In an optional implementation manner, the message sending module 803 is configured to send a message in a third sending queue if the first sending queue and the second sending queue are both empty; and detecting the first sending queue and the second sending queue again until any one of the first sending queue and the second sending queue is not empty or the third sending queue is empty.
In the embodiment of the application, the node device in the blockchain system allocates the target message to different sending queues according to the received message priority of the target message sent by other node devices in the blockchain system, and then sends the message according to different sending priorities, so that important messages, such as consensus messages, can be sent out preferentially, and the consensus efficiency of the whole blockchain system is improved.
It should be noted that: in the message sending apparatus provided in the above embodiment, when running an application program, only the division of the above functional modules is used as an example, and in practical applications, the above function distribution may be completed by different functional modules according to needs, that is, the internal structure of the apparatus is divided into different functional modules, so as to complete all or part of the above described functions. In addition, the message sending apparatus provided in the foregoing embodiment and the message sending method embodiment belong to the same concept, and specific implementation processes thereof are described in the method embodiment, and are not described herein again.
In the embodiment of the present application, the node device may be implemented as a terminal or a computer device, and when implemented as a terminal, the terminal may implement the operation performed by the message sending method, and when implemented as a computer device, the computer device may implement the operation performed by the message sending method, or the computer device and the terminal may interact with each other to implement the operation performed by the message sending method.
Fig. 9 is a block diagram of a terminal 900 in a block chain system according to an embodiment of the present application. The terminal 900 may be: a smart phone, a tablet computer, an MP3 player (Moving Picture Experts Group Audio Layer III, motion video Experts compression standard Audio Layer 3), an MP4 player (Moving Picture Experts Group Audio Layer IV, motion video Experts compression standard Audio Layer 4), a notebook computer, or a desktop computer. Terminal 900 may also be referred to by other names such as user equipment, portable terminals, laptop terminals, desktop terminals, etc.
In general, terminal 900 includes: a processor 901 and a memory 902.
Processor 901 may include one or more processing cores, such as a 4-core processor, an 8-core processor, and so forth. The processor 901 may be implemented in at least one hardware form of a DSP (Digital Signal Processing), an FPGA (Field-Programmable Gate Array), and a PLA (Programmable Logic Array). The processor 901 may also include a main processor and a coprocessor, where the main processor is a processor for Processing data in an awake state, and is also called a Central Processing Unit (CPU); a coprocessor is a low power processor for processing data in a standby state. In some embodiments, the processor 901 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content required to be displayed on the display screen. In some embodiments, the processor 901 may further include an AI (Artificial Intelligence) processor for processing computing operations related to machine learning.
Memory 902 may include one or more computer-readable storage media, which may be non-transitory. Memory 902 may also include high-speed random access memory, as well as non-volatile memory, such as one or more magnetic disk storage devices, flash memory storage devices. In some embodiments, a non-transitory computer readable storage medium in memory 902 is used to store at least one instruction for execution by processor 901 to implement the messaging methods provided by the method embodiments herein.
In some embodiments, terminal 900 can also optionally include: a peripheral interface 903 and at least one peripheral. The processor 901, memory 902, and peripheral interface 903 may be connected by buses or signal lines. Various peripheral devices may be connected to the peripheral interface 903 via a bus, signal line, or circuit board. Specifically, the peripheral device includes: at least one of a radio frequency circuit 904, a display screen 905, a camera assembly 906, an audio circuit 907, a positioning assembly 908, and a power supply 909.
The peripheral interface 903 may be used to connect at least one peripheral related to I/O (Input/Output) to the processor 901 and the memory 902. In some embodiments, the processor 901, memory 902, and peripheral interface 903 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 901, the memory 902 and the peripheral interface 903 may be implemented on a separate chip or circuit board, which is not limited by this embodiment.
The Radio Frequency circuit 904 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The radio frequency circuitry 904 communicates with communication networks and other communication devices via electromagnetic signals. The radio frequency circuit 904 converts an electrical signal into an electromagnetic signal to transmit, or converts a received electromagnetic signal into an electrical signal. Optionally, the radio frequency circuit 904 comprises: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a subscriber identity module card, and so forth. The radio frequency circuit 904 may communicate with other terminals via at least one wireless communication protocol. The wireless communication protocols include, but are not limited to: metropolitan area networks, various generation mobile communication networks (2G, 3G, 4G, and 5G), Wireless local area networks, and/or WiFi (Wireless Fidelity) networks. In some embodiments, the radio frequency circuit 904 may also include NFC (Near Field Communication) related circuits, which are not limited in this application.
The display screen 905 is used to display a UI (User Interface). The UI may include graphics, text, icons, video, and any combination thereof. When the display screen 905 is a touch display screen, the display screen 905 also has the ability to capture touch signals on or over the surface of the display screen 905. The touch signal may be input to the processor 901 as a control signal for processing. At this point, the display 905 may also be used to provide virtual buttons and/or a virtual keyboard, also referred to as soft buttons and/or a soft keyboard. In some embodiments, the display 905 may be one, providing the front panel of the terminal 900; in other embodiments, the display 905 may be at least two, respectively disposed on different surfaces of the terminal 900 or in a foldable design; in still other embodiments, the display 905 may be a flexible display disposed on a curved surface or a folded surface of the terminal 900. Even more, the display screen 905 may be arranged in a non-rectangular irregular figure, i.e. a shaped screen. The Display panel 905 can be made of LCD (Liquid Crystal Display), OLED (Organic Light-Emitting Diode), and other materials.
The camera assembly 906 is used to capture images or video. Optionally, camera assembly 906 includes a front camera and a rear camera. Generally, the front camera is arranged on the front panel of the node device, and the rear camera is arranged on the back of the node device. In some embodiments, the number of the rear cameras is at least two, and each rear camera is any one of a main camera, a depth-of-field camera, a wide-angle camera and a telephoto camera, so that the main camera and the depth-of-field camera are fused to realize a background blurring function, and the main camera and the wide-angle camera are fused to realize panoramic shooting and VR (Virtual Reality) shooting functions or other fusion shooting functions. In some embodiments, camera assembly 906 may also include a flash. The flash lamp can be a monochrome temperature flash lamp or a bicolor temperature flash lamp. The double-color-temperature flash lamp is a combination of a warm-light flash lamp and a cold-light flash lamp, and can be used for light compensation at different color temperatures.
Audio circuit 907 may include a microphone and a speaker. The microphone is used for collecting sound waves of a user and the environment, converting the sound waves into electric signals, and inputting the electric signals to the processor 901 for processing, or inputting the electric signals to the radio frequency circuit 904 for realizing voice communication. For stereo sound acquisition or noise reduction purposes, the microphones may be multiple and disposed at different locations of the terminal 900. The microphone may also be an array microphone or an omni-directional pick-up microphone. The speaker is used to convert electrical signals from the processor 901 or the radio frequency circuit 904 into sound waves. The loudspeaker can be a traditional film loudspeaker or a piezoelectric ceramic loudspeaker. When the speaker is a piezoelectric ceramic speaker, the speaker can be used for purposes such as converting an electric signal into a sound wave audible to a human being, or converting an electric signal into a sound wave inaudible to a human being to measure a distance. In some embodiments, audio circuit 907 may also include a headphone jack.
The positioning component 908 is used to locate a current geographic Location of the terminal 900 for navigation or LBS (Location Based Service). The Positioning component 908 may be a Positioning component based on the GPS (Global Positioning System) in the united states, the beidou System in china, the graves System in russia, or the galileo System in the european union.
The power supply 909 is used to supply power to the various components in the terminal 900. The power source 909 may be ac, dc, disposable or rechargeable. When power source 909 comprises a rechargeable battery, the rechargeable battery may support wired or wireless charging. The rechargeable battery may also be used to support fast charge technology.
In some embodiments, terminal 900 can also include one or more sensors 910. The one or more sensors 910 include, but are not limited to: acceleration sensor 911, gyro sensor 912, pressure sensor 913, fingerprint sensor 914, optical sensor 915, and proximity sensor 916.
The acceleration sensor 911 can detect the magnitude of acceleration in three coordinate axes of the coordinate system established with the terminal 900. For example, the acceleration sensor 911 may be used to detect the components of the gravitational acceleration in three coordinate axes. The processor 901 can control the display screen 905 to display the user interface in a landscape view or a portrait view according to the gravitational acceleration signal collected by the acceleration sensor 911. The acceleration sensor 911 may also be used for acquisition of motion data of a game or a user.
The gyro sensor 912 can detect the body direction and the rotation angle of the terminal 900, and the gyro sensor 912 can cooperate with the acceleration sensor 911 to acquire the 3D motion of the user on the terminal 900. Based on the data collected by gyroscope sensor 912, processor 901 may implement the following functions: motion sensing (such as changing the UI according to a user's tilting operation), image stabilization at the time of photographing, game control, and inertial navigation.
The pressure sensor 913 may be disposed on a side bezel of the terminal 900 and/or underneath the display 905. When the pressure sensor 913 is disposed on the side frame of the terminal 900, the user's holding signal of the terminal 900 may be detected, and the processor 901 performs left-right hand recognition or shortcut operation according to the holding signal collected by the pressure sensor 913. When the pressure sensor 913 is disposed at a lower layer of the display screen 905, the processor 901 controls the operability control on the UI interface according to the pressure operation of the user on the display screen 905. The operability control comprises at least one of a button control, a scroll bar control, an icon control and a menu control.
The fingerprint sensor 914 is used for collecting a fingerprint of the user, and the processor 901 identifies the user according to the fingerprint collected by the fingerprint sensor 914, or the fingerprint sensor 914 identifies the user according to the collected fingerprint. Upon recognizing that the user's identity is a trusted identity, processor 901 authorizes the user to perform relevant sensitive operations including unlocking the screen, viewing encrypted information, downloading software, paying, and changing settings, etc. The fingerprint sensor 914 may be disposed on the front, back, or side of the terminal 900. When a physical key or vendor Logo is provided on the terminal 900, the fingerprint sensor 914 may be integrated with the physical key or vendor Logo.
The optical sensor 915 is used to collect ambient light intensity. In one embodiment, the processor 901 may control the display brightness of the display screen 905 based on the ambient light intensity collected by the optical sensor 915. Specifically, when the ambient light intensity is high, the display brightness of the display screen 905 is increased; when the ambient light intensity is low, the display brightness of the display screen 905 is adjusted down. In another embodiment, the processor 901 can also dynamically adjust the shooting parameters of the camera assembly 906 according to the ambient light intensity collected by the optical sensor 915.
Proximity sensor 916, also known as a distance sensor, is typically disposed on the front panel of terminal 900. The proximity sensor 916 is used to collect the distance between the user and the front face of the terminal 900. In one embodiment, when the proximity sensor 916 detects that the distance between the user and the front face of the terminal 900 gradually decreases, the processor 901 controls the display 905 to switch from the bright screen state to the dark screen state; when the proximity sensor 916 detects that the distance between the user and the front surface of the terminal 900 gradually becomes larger, the display 905 is controlled by the processor 901 to switch from the breath screen state to the bright screen state.
Those skilled in the art will appreciate that the configuration shown in fig. 9 does not constitute a limitation of terminal 900, and may include more or fewer components than those shown, or may combine certain components, or may employ a different arrangement of components.
Fig. 10 is a schematic structural diagram of a computer device, where the computer device 1000 may have a relatively large difference due to different configurations or performances, and may include one or more processors (CPUs) 1001 and one or more memories 1002, where the memory 1002 stores at least one instruction, and the at least one instruction is loaded and executed by the processors 1001 to implement the methods provided by the foregoing method embodiments. Certainly, the computer device may further have a wired or wireless network interface, a keyboard, an input/output interface, and other components to facilitate input and output, and the computer device may further include other components for implementing functions of the device, which are not described herein again.
The embodiment of the present application further provides a computer-readable storage medium, where the computer-readable storage medium is applied to a node device in a blockchain system, and the computer-readable storage medium stores at least one program code, where the at least one program code is used for being executed by a processor and implementing an operation performed by the node device in the message sending method in the embodiment of the present application.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, where the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
The above description is only exemplary of the present application and should not be taken as limiting, as any modification, equivalent replacement, or improvement made within the spirit and principle of the present application should be included in the protection scope of the present application.

Claims (19)

1. A message sending method, applied to a node device in a block chain system, the method comprising:
receiving target messages sent by other node devices in the block chain system, and determining the message priority of the target messages, wherein the message priority is used for indicating the sending sequence of the messages; the node equipment is configured with at least two sending queues, and each sending queue is matched with one message priority;
when a first target sending queue matched with the message priority is not full, distributing the target message to the first target sending queue;
When the first target sending queue is full and the first target sending queue is the sending queue with the highest sending priority, if the second target sending queue is not full, the target message is inserted into the second target sending queue; if the second target sending queue is full, caching the target message, and stopping sending the messages in the sending queue with the sending priority lower than that of the first target sending queue; the sending priority of the second target sending queue is adjacent to and lower than that of the first target sending queue;
sending messages in a first sending queue, wherein the first sending queue is the sending queue with the highest sending priority in the at least two sending queues;
if the message in the first sending queue is sent completely, sending the message in a second sending queue, wherein the second sending queue is a sending queue with adjacent sending priority and lower than the first sending queue;
the method further comprises the following steps: after the target message is cached, detecting the first target sending queue, and if the first target sending queue is not full, distributing the target message to the first target sending queue.
2. The method of claim 1, wherein determining the message priority of the target message comprises:
inquiring the message priority corresponding to the message type according to the message type of the target message;
and taking the message priority corresponding to the message type as the message priority of the target message.
3. The method of claim 2, wherein the correspondence between the message type and the message priority is:
the message priority corresponding to the consensus message is a high-level priority;
the message priority corresponding to the transaction pool synchronous message is a middle priority;
the message priority corresponding to the heartbeat message between the node device block synchronization message and the node device is low-level priority.
4. The method of claim 1, further comprising:
when the first target sending queue is full, and the first target sending queue is not the sending queue with the highest sending priority and is not the sending queue with the lowest sending priority, if the second target sending queue is not full, the target message is inserted into the second target sending queue; if the second target send queue is full, discarding the target message.
5. The method of claim 1, further comprising:
and if the first target sending queue is full and the first target sending queue is the sending queue with the lowest sending priority, discarding the target message.
6. The method of claim 1, wherein the transmitting the messages in the at least two transmit queues according to the transmit priority of each of the at least two transmit queues comprises:
sending the message in a first sending queue, wherein the first sending queue is the sending queue with the highest sending priority in the at least two sending queues;
and if the messages in the first sending queue are sent completely, sending the messages in a second sending queue, wherein the second sending queue is a sending queue with adjacent sending priority and lower than the first sending queue.
7. The method of claim 6, further comprising:
and if the messages in the second sending queue are sent completely and the first sending queue is not empty, sending the messages in the first sending queue.
8. The method of claim 6, further comprising:
And if the messages in the second sending queue are sent completely and the first sending queue is empty, sending the messages in a third sending queue, wherein the third sending queue is a sending queue with a sending priority level which is adjacent and lower than that of the second sending queue.
9. The method of claim 8, wherein the third transmit queue is the transmit queue with the lowest transmit priority;
the sending the message in the third sending queue includes:
sending a message in the third sending queue;
and detecting the first sending queue and the second sending queue, and if any one of the first sending queue and the second sending queue is not empty, sending the messages in the first sending queue and the second sending queue.
10. A message transmission apparatus, for a node device in a block chain system, the apparatus comprising:
a message receiving module, configured to receive a target message sent by other node devices in the blockchain system, and determine a message priority of the target message, where the message priority is used to indicate a sending order of the messages; wherein the node device is configured with at least two sending queues, each sending queue matching one of the message priorities;
The message distribution module is used for distributing the target message to a first target sending queue when the first target sending queue matched with the message priority is not full; when the first target sending queue is full and the first target sending queue is the sending queue with the highest sending priority, if the second target sending queue is not full, the target message is inserted into the second target sending queue; if the second target sending queue is full, caching the target message, and stopping sending the messages in the sending queue with the sending priority lower than that of the first target sending queue; the transmission priority of the second target transmission queue is adjacent to and lower than that of the first target transmission queue;
a message sending module, configured to send a message in a first sending queue, where the first sending queue is a sending queue with a highest sending priority in the at least two sending queues; if the message in the first sending queue is sent completely, sending the message in a second sending queue, wherein the second sending queue is a sending queue with adjacent sending priority and lower than the first sending queue;
the message distribution module is further configured to detect the first target sending queue after the target message is cached, and distribute the target message to the first target sending queue if the first target sending queue is not full.
11. The apparatus of claim 10, wherein the message receiving module is further configured to:
inquiring the message priority corresponding to the message type according to the message type of the target message;
and taking the message priority corresponding to the message type as the message priority of the target message.
12. The apparatus of claim 11, wherein the correspondence between the message type and the message priority is:
the message priority corresponding to the consensus message is a high-level priority;
the message priority corresponding to the transaction pool synchronous message is a middle priority;
the message priority corresponding to the heartbeat message between the node device block synchronization message and the node device is low-level priority.
13. The apparatus of claim 10, wherein the message allocation module is further configured to:
when the first target sending queue is full, and the first target sending queue is not the sending queue with the highest sending priority and is not the sending queue with the lowest sending priority, if the second target sending queue is not full, the target message is inserted into the second target sending queue;
if the second target send queue is full, discarding the target message.
14. The apparatus of claim 10, further comprising:
and the message abandon module is used for abandoning the target message if the first target sending queue is full and the first target sending queue is the sending queue with the lowest sending priority.
15. The apparatus of claim 10, wherein the messaging module is further configured to:
and if the messages in the second sending queue are sent completely and the first sending queue is not empty, sending the messages in the first sending queue.
16. The apparatus of claim 15, wherein the messaging module is further configured to:
and if the messages in the second sending queue are sent completely and the first sending queue is empty, sending the messages in a third sending queue, wherein the third sending queue is a sending queue with a sending priority level which is adjacent and lower than that of the second sending queue.
17. The apparatus of claim 16, wherein the third transmit queue is the transmit queue with the lowest transmit priority;
the message sending module is further configured to:
sending a message in the third sending queue;
And detecting the first sending queue and the second sending queue, and if any one of the first sending queue and the second sending queue is not empty, sending the messages in the first sending queue and the second sending queue.
18. A node device, characterized in that the node device comprises a processor and a memory, the memory being configured to store at least one piece of program code, the at least one piece of program code being loaded by the processor and being configured to perform the message sending method according to any of the claims 1 to 9.
19. A storage medium for storing at least one program code for executing the message sending method according to any one of claims 1 to 9.
CN202010015541.7A 2020-01-07 2020-01-07 Message sending method, device, node equipment and storage medium Active CN111245745B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010015541.7A CN111245745B (en) 2020-01-07 2020-01-07 Message sending method, device, node equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010015541.7A CN111245745B (en) 2020-01-07 2020-01-07 Message sending method, device, node equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111245745A CN111245745A (en) 2020-06-05
CN111245745B true CN111245745B (en) 2022-05-24

Family

ID=70879920

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010015541.7A Active CN111245745B (en) 2020-01-07 2020-01-07 Message sending method, device, node equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111245745B (en)

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111510396B (en) * 2020-06-30 2020-10-27 腾讯科技(深圳)有限公司 Message sending method and related device
CN111935000B (en) 2020-09-25 2021-01-08 支付宝(杭州)信息技术有限公司 Message transmission method and device
CN111934998B (en) 2020-09-25 2021-02-09 支付宝(杭州)信息技术有限公司 Message transmission method and device
CN111934997B (en) 2020-09-25 2021-01-12 支付宝(杭州)信息技术有限公司 Message transmission method and device
CN113079079B (en) 2020-09-25 2022-08-02 支付宝(杭州)信息技术有限公司 Message transmission method and device
CN111934996B (en) 2020-09-25 2021-01-12 支付宝(杭州)信息技术有限公司 Message transmission method and device
CN111934990B (en) 2020-09-25 2021-02-09 支付宝(杭州)信息技术有限公司 Message transmission method and device
CN111935314B (en) 2020-09-25 2021-01-12 支付宝(杭州)信息技术有限公司 Block chain system, message transmission method and device
CN111935315B (en) 2020-09-25 2021-01-12 支付宝(杭州)信息技术有限公司 Block synchronization method and device
CN117241231A (en) * 2022-10-27 2023-12-15 青岛意想意创技术发展有限公司 Message scheduling method and device based on priority information
CN115550280B (en) * 2022-11-24 2023-03-31 云账户技术(天津)有限公司 Multi-level message queue implementation method, system, electronic device and readable storage medium

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100365978C (en) * 2006-02-23 2008-01-30 华为技术有限公司 Method and device for realizing classified service to business provider
WO2013097248A1 (en) * 2011-12-31 2013-07-04 华为技术有限公司 Distributed task processing method, device and system based on message queue
CN106708607B (en) * 2015-11-12 2020-12-22 创新先进技术有限公司 Congestion control method and device for message queue
CN107800546B (en) * 2016-08-31 2021-03-30 华为技术有限公司 Management method and device for broadcast messages
US11675715B2 (en) * 2019-03-27 2023-06-13 Intel Corporation Low pin-count architecture with prioritized message arbitration and delivery
CN109995666A (en) * 2019-04-12 2019-07-09 深圳市元征科技股份有限公司 A kind of method for message transmission and relevant apparatus

Also Published As

Publication number Publication date
CN111245745A (en) 2020-06-05

Similar Documents

Publication Publication Date Title
CN111245745B (en) Message sending method, device, node equipment and storage medium
CN110602089B (en) Block chain-based medical data storage method, device, equipment and storage medium
CN110971414B (en) Method, device, terminal and server for generating signature
CN110401715B (en) Resource collection task management method, device, storage medium and system
CN111339086B (en) Block processing method, and data query method and device based on block chain
CN111340482B (en) Conflict detection method, device, node equipment and storage medium
CN110598482A (en) Block chain-based digital certificate management method, device, equipment and storage medium
CN110597924B (en) Block chain-based user identification processing method, device, equipment and storage medium
CN110689460A (en) Traffic accident data processing method, device, equipment and medium based on block chain
CN110687821A (en) Intelligent home control system and method based on block chain
CN110826103B (en) Method, device, equipment and storage medium for processing document authority based on blockchain
CN111241115B (en) Data synchronization method, device, equipment and storage medium
CN110690999B (en) Bandwidth allocation method, device and equipment based on block chain and storage medium
CN111339181B (en) Block storage method, block storage device, node equipment and storage medium
CN111080443A (en) Service processing method, device, equipment and storage medium based on block chain
CN110933113A (en) Block chain-based interactive behavior detection method, device, equipment and storage medium
CN110598386A (en) Data processing method, device and equipment based on block chain and storage medium
CN111212074A (en) Qualification determination method, device, equipment and storage medium based on block chain
CN110677262A (en) Block chain-based information notarization method, device and system
CN111667371B (en) Resource aggregation method, system, device and storage medium based on block chain
CN110727894B (en) Target material setting method, device, equipment and storage medium
CN110597840A (en) Partner relationship establishing method, device, equipment and storage medium based on block chain
CN110570289A (en) service processing method, device, equipment and storage medium based on block chain
CN110597868A (en) Information query method, device, terminal and storage medium based on block chain
CN111694892A (en) Resource transfer method, device, terminal, server and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40024843

Country of ref document: HK

SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant