Detailed Description
In order to better understand the technical solutions in the present application, the following description will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments herein without making any inventive effort, shall fall within the scope of the present application.
As previously described, it was discovered during the development of blockchain platforms that the network environment can have a significant impact on the communication between nodes. Once the transmission data between the nodes exceeds the transmission capacity of the nodes in the current network environment, the problem of communication unclogging can be caused. In particular, for nodes in the blockchain that execute the heartbeat mechanism, such nodes, once they trigger the connection detection logic of the heartbeat mechanism, disconnect the established connection with other nodes and attempt reconnection. Thus, when the network environment is poor, the transmission data between the nodes is too large, which easily causes the nodes to trigger the connection detection logic, so that the communication is forcedly interrupted.
Therefore, the technical scheme for solving the problems can ensure that nodes of the blockchain can stably and effectively communicate under the current network environment.
FIG. 1 is a flow chart of a data transmission method of a blockchain in an embodiment of the present application. The method shown in fig. 1 may be performed by a corresponding apparatus, including:
step S102, when a first node (may refer to the present node) in the blockchain prepares to send first target data to a second node (may refer to the opposite node) in the blockchain, determining a first network transmission status between the first node and the second node.
The method for determining the network transmission condition between the nodes is not particularly limited in the embodiments of the present application.
As an exemplary introduction.
According to preset logic, network test can be dynamically carried out on a connection channel between the first node and the second node, and network transmission conditions obtained by the network test are locally cached. Correspondingly, when the first node prepares to send the first target data, the step obtains the network transmission condition between the first node and the second node from the local cache. Or, when the first node prepares to send the first target data, a network test may be performed on a connection channel between the first node and the second node, so as to determine a network transmission condition between the first node and the second node.
In addition, the blockchain may be in any form, such as a federated chain, a public chain, a private chain, etc., and embodiments of the present application are not specifically limited.
Step S104, a first data splitting reference (the data splitting reference refers to a splitting manner of splitting data) that matches the first network transmission condition is determined.
Wherein the first network transmission condition may include: network transmission efficiency between the first node and the second node. The method includes the steps that when first target data exceeds network transmission efficiency between a first node and a second node, a first data splitting reference is determined. For example, the network transmission efficiency is determined to be data with one maximum transmission of 5M, and assuming that the size of the first target data is 16M, the determined first data splitting reference should split the first target data into at least 4 parts, and each 4 parts of data is not greater than 5M.
And S106, splitting the first target data according to the first data splitting reference to obtain at least one piece of first splitting data.
Specifically, after the first split data is obtained, the step may further configure an identifier of the first target data for the first split data, so as to indicate that the first split data is derived from the first target data. Meanwhile, a splitting sequence number can be further configured for each first splitting data, so that the receiving node can orderly synthesize each first splitting data based on the splitting sequence number, and restore the first splitting data to obtain first target data.
Step S108, the at least one first split data is respectively sent to the second nodes, so that the second nodes synthesize first target data based on the at least one first split data to deliver the upper layer processing.
The embodiment of the present application does not specifically limit the transmission mode of the first split data.
As an exemplary introduction.
The step may sequentially send the at least one first split data to the second node based on one connection channel established between the first node and the second node, or may send the at least one first split data to the second node in parallel based on a plurality of connection channels established between the first node and the second node.
In addition, the first split data may be sent based on determining the response mechanism based on the above. And under the condition of determining the response mechanism, the second node feeds back response information to the first node after successfully receiving the first split data. If the first node does not receive the response information from the second node after sending a certain first split data, the first split data can be sent to the second node again according to the relevant rule until the sending times reach the requirement or after sending, the response information of the second node is received.
Based on the data transmission method of the blockchain shown in fig. 1, the scheme of the embodiment of the application can adaptively split data to be transmitted according to the network transmission state between the first node and the second node, and respectively send the split obtained data, so that the transmission data between the nodes can not exceed the transmission capability of the nodes in the current network environment, and the communication smoothness between the nodes can be ensured. In addition, for the nodes executing the heartbeat mechanism in the block chain, the problem of error initiation reconnection caused by overlarge transmission data can be avoided, and the stability and the effectiveness of communication between the nodes are ensured.
Further, on the basis of the foregoing, the method of the embodiment of the present application may further receive, based on the first node, data sent by other nodes in the foregoing manner.
That is, the method of the embodiment of the application further includes:
step S110, at least one second split data sent by a third node in the blockchain to the first node is received.
It should be understood that the third node may transmit the second target data to the first node according to the data transmission method shown in the above-described step S102-step S108. The at least one second split data is obtained by splitting the second target data by the third node according to a second data splitting reference, wherein the second data splitting reference is obtained by determining based on a second network transmission condition between the corresponding first node and the third node when the third node prepares to send the second target data;
step S112, synthesizing the at least one second split data into second target data.
As an exemplary introduction to step S110 and step S112.
The message carrying the second split data sent by the third node also contains the identifier of the second target data and the split sequence number corresponding to the second split data. After receiving the second split data, the method creates a file aiming at the second target data in a cache space of the first node based on the identification of the second target data so as to cache the second split data and the split sequence number corresponding to the second split data. After the caching of all the second split data is completed, each second split data in the file can be orderly synthesized according to the splitting sequence indicated by the splitting sequence number so as to restore and obtain second target data.
The method of determining the network transmission conditions between the first node and the second node is described in further detail below.
As previously described, the network transmission conditions between the first node and the second node may include, but are not limited to: network transmission efficiency between the first node and the second node.
Correspondingly, the method of the embodiment of the application can detect the network transmission efficiency between the first node and the second node by sending the test data. That is, when step S102 is executed, first, after a connection channel is established between the first node and the second node, communication between the first node and the second node is initialized, and after the initialization is completed, test data is transmitted to the second node based on the connection channel. And then, receiving test feedback data sent by the second node, wherein the test feedback data indicates the receiving time of the second node for the test data. And finally, determining the network transmission efficiency between the first node and the second node based on the size of the test data, the sending time of the test data and the receiving time of the test data.
As an exemplary introduction.
Assuming that the test data size is 600m, the transmission time of the test data is 3:10, the receiving time of the test data is 3:15. According to the above information, it can be determined that the transmission duration of the test data is 3:15-3:10=5 minutes, and the corresponding network transmission efficiency is 600 m/(5×60S) =2 m/S.
After obtaining the network transmission efficiency between the first node and the second node, the first data splitting reference can be further determined based on the network transmission efficiency.
Of course, in addition to network transmission efficiency, the method of the embodiment of the present application may further determine the first data splitting reference based on other network information related to transmission of the first target data. For example, the first data splitting reference is determined further based on the network load of the first node and/or the network load of the second node. Since the manner is not unique, the description is not repeated here.
It should be understood that the method according to the embodiments of the present application may dynamically send transmission data according to the network transmission conditions between nodes. Therefore, after the transmission data is split according to the determined data splitting reference, if the network transmission condition is further deteriorated, the split obtained data can be split again based on the new splitting reference.
That is, in the embodiment of the present application, the first target data may be obtained by splitting the third target data by the first node according to the third data splitting reference. Correspondingly, the third data splitting reference is determined based on the network transmission condition between the corresponding first node and the second node when the first node is ready to send the third target data.
The method of the present embodiment is described below by way of example with reference to specific implementations.
The method of the embodiment is applied to data transmission among nodes in the alliance chain.
As shown in fig. 2, the main flow of sending target data to the opposite node by the node of the federation chain includes:
in step S201, the present node establishes a connection with the counterpart node.
Step S202, the node initiates network detection and determines the network transmission efficiency with the opposite node.
In this step, after the connection channel is successfully established with the opposite node, the present node immediately sends a test data packet to the opposite node based on the connection channel, so as to test the network transmission efficiency with the opposite node, thereby updating the data splitting reference.
Step S203, the node determines whether to split the target data based on the data splitting reference corresponding to the network transmission efficiency.
In the step, if the size of the target data exceeds the network transmission efficiency, determining that the target data needs to be split; otherwise, it is determined that the target data does not need to be split.
In step S204, after determining that the target data needs to be split, the node splits the target data into 2 sub-packets (sub-packets 1 and 2) based on the data splitting reference corresponding to the network transmission efficiency.
In step S205, the present node sends the sub-packet 1 to the opposite node based on the ACK mechanism.
In step S206, after receiving the sub-packet 1, the other node caches the sub-packet 1 and sends an ACK response message of the sub-packet 1 to the other node.
In step S207, after receiving the ACK response message of the sub-packet 1, the node initiates network probing, and updates the network transmission efficiency with the other node.
In step S208, the present node determines whether splitting of the sub-packet 2 is required based on the updated network transmission efficiency with the other node.
In step S209, after determining that the sub-packet 2 does not need to be split, the node sends the sub-packet 2 to the other node based on the ACK mechanism.
In step S210, after receiving the sub-packet 2, the other node caches the sub-packet 2 and sends an ACK response message of the sub-packet 2 to the other node.
In step S211, the opposite node synthesizes the sub-packet 1 and the sub-packet 2 into the target data, and submits the target data to the upper layer of the federation chain.
The foregoing is an introduction to the methods of embodiments of the present application. It will be appreciated that suitable modifications may be made without departing from the principles set forth herein above, and such modifications are also intended to be considered within the scope of the embodiments of the present application.
Corresponding to the above-mentioned data transmission method of the blockchain, as shown in fig. 3, the embodiment of the present application further provides a data transmission device 300 based on the blockchain, including:
the transmission status determination module 310 determines a network transmission status between a first node in a blockchain and a second node in the blockchain when the first node is ready to send first target data to the second node.
The split reference determining module 320 determines a matched first data split reference based on the network transmission condition between the first node and the second node.
The data splitting module 330 splits the first target data according to the first data splitting reference to obtain at least one first split data.
And a data sending module 340, configured to send the at least one first split data to the second node respectively.
Based on the data transmission device of the blockchain shown in fig. 3, the scheme of the embodiment of the application can adaptively split data to be transmitted according to the network transmission state between the first node and the second node, and respectively send the split obtained data, so that the transmission data between the nodes can not exceed the transmission capability of the nodes in the current network environment, and the communication smoothness between the nodes can be ensured. In addition, for the nodes executing the heartbeat mechanism in the block chain, the problem of error initiation reconnection caused by overlarge transmission data can be avoided, and the stability and the effectiveness of communication between the nodes are ensured.
Optionally, the apparatus of the embodiment of the present application further includes:
the data receiving module is used for receiving at least one second split data sent to the first node by a third node in the blockchain, wherein the at least one second split data is obtained by splitting second target data by the third node according to a second data splitting reference, and the second data splitting reference is obtained by determining a second network transmission condition between the corresponding first node and the third node when the third node is ready to send the second target data;
and the data synthesis module synthesizes the at least one second split data into the second target data.
Optionally, the first network transmission condition includes: network transmission efficiency between the first node and the second node.
Optionally, the split reference determining module 320 specifically sends test data to the second node based on the connection channel after the first node establishes the connection channel with the second node; then, receiving test feedback data sent by the second node, wherein the test feedback data indicates the receiving time of the second node for the test data; and determining the network transmission efficiency between the first node and the second node based on the size of the test data, the sending time of the test data and the receiving time of the test data.
Optionally, the split reference determining module 320 determines the matched first data split reference based on a network transmission condition between the first node and the second node, a network load of the first node, and/or a network load of the second node.
Optionally, the first target data is obtained by splitting third target data by the first node according to a third data splitting reference, and the third data splitting reference is obtained by determining based on a network transmission condition between the first node and the second node corresponding to when the first node is ready to send the third target data.
Optionally, the data sending module 340 sends the at least one first split data to the second node respectively, specifically based on a determined response mechanism.
Optionally, the blockchain is a coalition chain.
Obviously, the data transmission device of the blockchain in the embodiment of the present application may be used as an execution body of the data transmission method of the blockchain shown in fig. 1, so that the data transmission device can implement the functions implemented by the data transmission method in fig. 1 and 2. Since the principle is the same, the description is not repeated here.
Fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present application. Referring to fig. 4, at the hardware level, the electronic device includes a processor, and optionally an internal bus, a network interface, and a memory. The Memory may include a Memory, such as a Random-Access Memory (RAM), and may further include a non-volatile Memory (non-volatile Memory), such as at least 1 disk Memory. Of course, the electronic device may also include hardware required for other services.
The processor, network interface, and memory may be interconnected by an internal bus, which may be an ISA (Industry Standard Architecture ) bus, a PCI (Peripheral Component Interconnect, peripheral component interconnect standard) bus, or EISA (Extended Industry Standard Architecture ) bus, among others. The buses may be classified as address buses, data buses, control buses, etc. For ease of illustration, only one bi-directional arrow is shown in FIG. 4, but not only one bus or type of bus.
And the memory is used for storing programs. In particular, the program may include program code including computer-operating instructions. The memory may include memory and non-volatile storage and provide instructions and data to the processor.
The processor reads the corresponding computer program from the nonvolatile memory into the memory and then runs, and forms a data transmission device on a logic level. The processor is used for executing the programs stored in the memory and is specifically used for executing the following operations:
determining a first network transmission condition between a first node in a blockchain and a second node in the blockchain when the first node prepares to send first target data to the second node;
determining a first data splitting reference matched with the first network transmission condition;
splitting the first target data according to the first data splitting reference to obtain at least one first splitting data;
and respectively sending the at least one first split data to the second node so that the second node synthesizes the first target data based on the at least one first split data to deliver upper-layer processing.
The data transmission method of the blockchain disclosed in the embodiment shown in fig. 1 of the present application may be applied to a processor or implemented by the processor. The processor may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in a processor or by instructions in the form of software. The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; but also digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The disclosed methods, steps, and logic blocks in the embodiments of the present application may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in connection with the embodiments of the present application may be embodied directly in hardware, in a decoded processor, or in a combination of hardware and software modules in a decoded processor. The software modules may be located in a random access memory, flash memory, read only memory, programmable read only memory, or electrically erasable programmable memory, registers, etc. as well known in the art. The storage medium is located in a memory, and the processor reads the information in the memory and, in combination with its hardware, performs the steps of the above method.
It should be understood that the electronic device of the embodiment of the present application may implement the functions of the data transmission device of the blockchain in the embodiment shown in fig. 1 and fig. 2, which are not described herein again.
Of course, other implementations, such as a logic device or a combination of hardware and software, are not excluded from the electronic device of the present application, that is, the execution subject of the following processing flow is not limited to each logic unit, but may be hardware or a logic device.
Furthermore, embodiments of the present application provide a computer-readable storage medium storing one or more programs, the one or more programs including instructions, which when executed by a portable electronic device comprising a plurality of application programs, enable the portable electronic device to perform the method of the embodiment shown in fig. 1, and in particular to perform the method of:
determining a first network transmission condition between a first node in a blockchain and a second node in the blockchain when the first node prepares to send first target data to the second node;
determining a first data splitting reference matched with the first network transmission condition;
splitting the first target data according to the first data splitting reference to obtain at least one first splitting data;
and respectively sending the at least one first split data to the second node so that the second node synthesizes the first target data based on the at least one first split data to deliver upper-layer processing.
It should be appreciated that the above instructions, when executed by a portable electronic device comprising a plurality of applications, enable the blockchain data transmission device described above to perform the functions of the embodiments shown in fig. 1 and 2, and are not described in detail herein.
It will be appreciated by those skilled in the art that embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, the present specification may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present description can take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
The foregoing describes specific embodiments of the present disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims can be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
The foregoing is merely an example of the present specification and is not intended to limit the present specification. Various modifications and alterations to this specification will become apparent to those skilled in the art. Any modifications, equivalent substitutions, improvements, or the like, which are within the spirit and principles of the present description, are intended to be included within the scope of the claims of the present description.