CN108270874B - Application program updating method and device - Google Patents

Application program updating method and device Download PDF

Info

Publication number
CN108270874B
CN108270874B CN201810112015.5A CN201810112015A CN108270874B CN 108270874 B CN108270874 B CN 108270874B CN 201810112015 A CN201810112015 A CN 201810112015A CN 108270874 B CN108270874 B CN 108270874B
Authority
CN
China
Prior art keywords
block
target
data
target block
intelligent contract
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
CN201810112015.5A
Other languages
Chinese (zh)
Other versions
CN108270874A (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.)
Wuhan Douyu Network Technology Co Ltd
Original Assignee
Wuhan Douyu Network Technology 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 Wuhan Douyu Network Technology Co Ltd filed Critical Wuhan Douyu Network Technology Co Ltd
Priority to CN201810112015.5A priority Critical patent/CN108270874B/en
Publication of CN108270874A publication Critical patent/CN108270874A/en
Application granted granted Critical
Publication of CN108270874B publication Critical patent/CN108270874B/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
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/34Network arrangements or protocols for supporting network services or applications involving the movement of software or configuration parameters 
    • 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/06Protocols specially adapted for file transfer, e.g. file transfer protocol [FTP]
    • 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/1095Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Transfer Between Computers (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the invention provides an updating method and a device of an application program, wherein the method comprises the following steps: generating an update file of an application program to be updated, wherein a block chain network is deployed between a server and a client corresponding to the application program to be updated in advance, and the server and the client are user nodes in the block chain network; executing an intelligent contract in the block chain network, wherein the intelligent contract is used for generating a target block according to the updated file; and sending the generated target block to each user node in the block chain network through the block chain network so that each user node can execute an intelligent contract, wherein the intelligent contract is also used for carrying out security check on the received target block and updating the application program according to the target block passing the check. The embodiment of the invention can avoid malicious tampering of the update file by a third party, and the update file is sent by adopting a block chain technology, so that not only can synchronous update of all clients be ensured, but also the network bandwidth pressure of the server is reduced.

Description

Application program updating method and device
Technical Field
The present invention relates to the field of information technologies, and in particular, to a method and an apparatus for updating an application based on a block chain technology.
Background
With the continuous development of computer network technology, the functions of terminal devices are more and more powerful. The terminal equipment can bear various application programs, so that various requirements of users are met. To meet the changing demands of users, application providers typically push update information of applications to terminal devices.
At present, with the development of software development technology, the updating of application programs is also an important aspect. When a software developer finds that software has a BUG or a BUG, all clients are forced to be updated, and the software developer hopes to cover all user terminal equipment as soon as possible without errors. Therefore, how to ensure the integrity of the issued updated file and avoid malicious behaviors such as interception, tampering or virus addition by a third party has an important effect on updating the application program. Meanwhile, when the application program is updated, due to the fact that a large number of clients request the latest update files, network bandwidth is insufficient when the client software server distributes the update files, and therefore some clients cannot update; and some clients of edge nodes exist, so that updating is very slow, application program updating cannot be completed in time, and user experience is influenced.
Disclosure of Invention
In view of the above, the present invention is proposed in order to provide an update method and apparatus of an application program that overcomes or at least partially solves the above problems.
In a first aspect of the present invention, a method for updating an application program is provided, where the method includes:
generating an update file of an application program to be updated, wherein a block chain network is deployed between a server and a client corresponding to the application program to be updated in advance, and the server and the client are user nodes in the block chain network;
executing an intelligent contract in the block chain network, wherein the intelligent contract is used for generating a target block according to the updating file;
and sending the generated target block to each user node in the block chain network through the block chain network so as to allow each user node to execute an intelligent contract, wherein the intelligent contract is also used for carrying out security check on the received target block and updating an application program according to the checked target block.
Optionally, the executing the intelligent contract in the blockchain network includes:
obtaining block data and a block data structure of a last block of the target block from the blockchain network;
generating block data of a target block according to the block data of the previous block, the update file and a preset mapping relation between the block data of the target block and the block data of the previous block;
and generating the target block according to the block data structure and the block data of the target block.
Optionally, the block data structure includes a block number, a timestamp, a first encoded value, a first key value, block data, a preset value, a random number, and a second encoded value; the first encoding value is a second encoding value of a last block of the current block, the first key value is an MD5 value of the update file corresponding to the current block, and the second encoding value is a hash value of data obtained by combining the block number, the timestamp, the first encoding value, the first key value, the block data, the preset value, and the random number.
Optionally, the executing the intelligent contract in the blockchain network includes:
obtaining block data and a block data structure of a last block of the target block from the blockchain network;
splitting the update file into at least one sub-update data packet;
respectively generating block data of the block corresponding to each sub-update data packet according to the block data of the previous block and each sub-update data packet;
and respectively generating a target block corresponding to each sub-update data packet according to the block data structure and the block data of the block corresponding to each sub-update data packet.
In a second aspect of the present invention, there is provided another method for updating an application program, the method including:
receiving a target block sent by a server through a block chain network, wherein the target block is generated by executing an intelligent contract in the block chain network by the server, and the intelligent contract is used for generating the target block according to an update file of an application program to be updated; a block chain network is pre-deployed between a server and a client corresponding to the application program to be updated, and the server and the client are user nodes in the block chain network;
executing the intelligent contract, wherein the intelligent contract is further used for performing security check on the received target block;
and updating the application program according to the checked target block.
Optionally, the executing the smart contract comprises:
acquiring block data of a last block of the target blocks from the block chain network;
and performing security check on the target block according to the block data of the previous block and a preset mapping relation between the block data of the target block and the block data of the previous block.
In a third aspect of the present invention, there is provided an apparatus for updating an application, the apparatus comprising:
the system comprises a generation module, a service module and a service module, wherein the generation module is used for generating an update file of an application program to be updated, a block chain network is deployed between a server and a client corresponding to the application program to be updated in advance, and the server and the client are user nodes in the block chain network;
the server side processing module is used for executing an intelligent contract in the block chain network, and the intelligent contract is used for generating a target block according to the update file;
and the server side communication module is used for sending the generated target blocks to each user node in the block chain network through the block chain network so as to enable each user node to execute an intelligent contract, and the intelligent contract is also used for carrying out security check on the received target blocks and updating the application program according to the checked target blocks.
In a fourth aspect of the present invention, there is provided another apparatus for updating an application, the apparatus including:
the client communication module is used for receiving a target block sent by a server through a block chain network, wherein the target block is generated by the server executing an intelligent contract in the block chain network, and the intelligent contract is used for generating the target block according to an update file of an application program to be updated; a block chain network is pre-deployed between a server and a client corresponding to the application program to be updated, and the server and the client are user nodes in the block chain network;
the client processing module is used for executing the intelligent contract, and the intelligent contract is also used for carrying out security check on the received target block;
and the program updating module is used for updating the application program according to the verified target block.
Furthermore, the invention also provides a computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method as set forth in any of the above.
Furthermore, the present invention also provides a computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the steps of any of the above methods when executing the program.
According to the method and the device for updating the application program, provided by the embodiment of the invention, the target block is generated according to the update file corresponding to the application program to be updated by executing the intelligent contract which is pre-deployed in the block chain network between the server and the client of the application program to be updated, and then the generated target block is sent to each user node in the block chain network through the block chain network, so that each user node can perform security verification on the received target block and update the application program according to the verified target block. The embodiment of the invention can avoid malicious behaviors of a third party such as interception and tampering of the update file or addition of viruses, and the like, and can ensure synchronous update of all clients and reduce network bandwidth pressure of the server by adopting the block chain technology to send the update file to each user node in the block chain network.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
fig. 1 is a flowchart of an application program updating method according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating an application update method according to another embodiment of the present invention;
FIG. 3 is a schematic structural diagram of an apparatus for updating an application according to an embodiment of the present invention;
FIG. 4 is a schematic structural diagram of an apparatus for updating an application according to another embodiment of the present invention;
FIG. 5 is a schematic diagram of a computer apparatus according to an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. It will be further understood that terms, such as those defined in commonly used dictionaries, should be interpreted as having a meaning that is consistent with their meaning in the context of the prior art and will not be interpreted in an idealized or overly formal sense unless expressly so defined herein.
Fig. 1 schematically shows a flowchart of an update method of an application program according to an embodiment of the present invention. Referring to fig. 1, the method for updating an application program according to an embodiment of the present invention is applicable to server-side execution, and specifically includes the following steps:
step S11, generating an update file of an application program to be updated, wherein a block chain network is deployed in advance between a server and a client corresponding to the application program to be updated, and the server and the client are user nodes in the block chain network.
The applications in this implementation may be a variety of client applications suitable for the terminal device, such as: a game client program, a shopping client program, a live broadcast client program, etc., which are not specifically limited in this embodiment.
The update file in this embodiment is an update data packet of the application to be updated.
And step S12, executing an intelligent contract in the block chain network, wherein the intelligent contract is used for generating a target block according to the update file. In this embodiment, the target block refers to a newly generated block.
Step S13, sending the generated target block to each user node in the block chain network through the block chain network, so that each user node executes an intelligent contract, where the intelligent contract is further used to perform security check on the received target block and update an application program according to the checked target block.
In this embodiment, the blockchain technique has the technique of P2P, and specifically, the P2P technique can be used in all clients of the blockchain to achieve synchronous transmission of the target block, so that the update is faster than that from the server, and the network bandwidth pressure of the server is also reduced.
According to the method for updating the application program, provided by the embodiment of the invention, the target block is generated according to the update file corresponding to the application program to be updated by executing the intelligent contract which is pre-deployed in the block chain network between the server and the client of the application program to be updated, and then the generated target block is sent to each user node in the block chain network through the block chain network, so that each user node can perform security check on the received target block and update the application program according to the checked target block. The embodiment of the invention can avoid malicious behaviors of a third party such as interception and tampering of the update file or addition of viruses, and the like, and can ensure synchronous update of all clients and reduce network bandwidth pressure of the server by adopting the block chain technology to send the update file to each user node in the block chain network.
In an embodiment of the present invention, the executing the intelligent contract in the block chain network is specifically implemented by the following steps:
obtaining block data and a block data structure of a last block of the target block from the blockchain network; wherein, the last block refers to the previous block of the target block.
Generating block data of a target block according to the block data of the previous block, the update file and a preset mapping relation between the block data of the target block and the block data of the previous block;
and generating the target block according to the block data structure and the block data of the target block.
Further, the block data structure comprises a block number, a timestamp, a first encoded value, a first key value, block data, a preset value, a random number and a second encoded value; the first encoding value is a second encoding value of a last block of the current block, the first key value is an MD5 value of the update file corresponding to the current block, and the second encoding value is a hash value of data obtained by combining the block number, the timestamp, the first encoding value, the first key value, the block data, the preset value, and the random number.
In the embodiment of the invention, all the clients of the application program to be updated are added into the block chain network which is deployed in advance, so that all the clients are all user nodes in the block chain, and the block chain network has all functions of the block chain, a distributed account book, a P2P synchronization technology and the like.
The block data structure of the block chain is as follows:
usually, one blockchain must contain some necessary data, one is to check the validity and integrity of the data in the blockchain itself, for example, the blocknumber, the timestamp, the first encoded value, the first key value, the preset value, the random number, and the second encoded value, and the other is the update file of the client software, i.e., the blockchain data. The method comprises the following specific steps:
Struct BlockData{
Int64index;
the block number used to denote the block chain, typically increments from 0.
String previousHash;
The first code value indicates the HASH value of the previous block chain.
Int64timestamp;
// denotes a time stamp.
String key;
The first key value, represents the key value needed to compute the new tile.
String data;
The data field is an update file of the client software, wherein the update file can be an updated resource file or an updated program file, and can also contain the resource file. And for each file, there is a HASH value of the file content to ensure the integrity of the file content.
String zero;
// Preset, which represents the previous 0 data in calculating the HASH value for the new tile.
String randdata;
The random number is used for marking random data and is added into a new block, so that the HASH result calculated by the random data meets the number of 0 issued by the server.
String hash;
The HASH value indicates the HASH value of the current content of the block.
}
After the block is designed, any viewer receiving a block can check the data of the block, and thus, the design of the data structure of the block in the block chain is completed.
When the client application software needs to be updated for the first time, the client reports files needing to be updated, and the server calculates the generation initial block of the file content of each file needing to be updated. The concrete implementation is as follows:
step 1, reading each file to be updated into a memory.
Firstly, reading each independent file to be updated, and reading the content of the whole file into a memory. In the embodiment of the present invention, the update file may be read by using system functions fopen and fread.
FILE*pFile=fopen("beauty.data","rb");
The specified update file is opened by calling the system function fopen.
Where parameter 1 is the name of the open update file.
Wherein the parameter 2 is used to open the update file in a binary manner.
The return value is the handle pFile of the file.
fseek(pFile,0,SEEK_END);
And the read pointer of the file is moved to the tail part of the file by calling the fseek function.
Long Size=ftell(pFile);
And obtaining the Size of the updated file by calling the system function ftell.
Char*buffer=(char*)malloc(Size);
And calling a system function malloc to allocate a section of memory, wherein the allocated size is the size of the updated file.
fread(buffer,1,Size,pFile);
And calling a system function fread to read the content of the whole file into the allocated memory.
fclose(pFile);
The system function fclose is called to close the file handle.
Therefore, the content of the whole update file is read into the allocated memory.
And 2, calculating the Md5 value of the whole update file.
The embodiment of the invention calculates the MD5 value of the read whole update file so as to obtain the KEY value used by subsequent encryption.
KEY=MD5.Create(buffer,Size);
The MD5 result is calculated by calling the interface Create of the MD5 function to calculate the contents of the read file.
Wherein the parameter buff is the memory of the read update file.
Wherein the parameter size is the size of the read update file.
The same scheme described above is used for all update files to calculate the MD5 value for each file.
And 3, calculating the MD5 value of each update file.
The HASH result of its MD5 is computed for each update file of the client.
And 4, the server generates a block of the client software update.
In this embodiment, the block data structure is as follows:
Struct BlockData{
Int64index;
String previousHash;
Int64timestamp;
String key;
String data;
String zero;
String randdata;
String hash;
}
the core of the update is a data field, which contains the content of the client update file to be updated and also contains the MD5 value of the update content. After the server generates the initial block, the initial block is synchronized into the blockchain, so that the synchronization is distributed to all blockchain clients through the blockchain.
Further, after the initial block is generated by the server, when the client application program needs to be updated again subsequently, the generation of a new block is directly realized through an intelligent contract in the block chain network, at this time, the new block is forwarded to all clients in the room through P2P, and meanwhile, the data of the block is also subjected to validity check when all the clients receive the block. The implementation of generating new blocks is as follows:
firstly, the block data and the block data structure of the previous block of the target block are obtained, and the next block is generated according to the block data and the block data structure of the previous block.
In one embodiment, the name of the last block is assumed to be prevblock and the name of the newly generated block, i.e., the target block, is newblock.
1. The block number of the target block is calculated.
Newblock.index=prevblock.index+1;
The block number of the target block is the block number of the last block plus 1.
2. A timestamp of the target block is calculated.
Newblock.timestamp=time();
The timestamp of the target block is the current time of acquisition.
3. And calculating the hash value of the last block of the target block.
Newblock.previousHash=prevblock.hash;
The hash value of the last block of the target block is the obtained hash of the last block.
4. The key value of the last block of the target block is calculated.
Newblock.key=prevblock.key;
The key value of the last block of the target block is the acquired key of the last block.
5. And calculating the data of the target block.
Data is file content + md 5.
Wherein the data content of the target chunk is the content of the update file and the MD5 value of the update file.
6. The randdata value of the update file is calculated.
The randdata value is generated randomly by the client side so as to meet the number of 0 issued by the server just in front of the hash value calculated by the whole target block.
7. And calculating the hash value of the target block.
Newblock.hash=HASH(index+previousHash+timestamp+data+zero+randdata);
The hash value of the target block is composed of an index field, a previousHash field, a timestamp field and a data field of the target block.
The HASH algorithm used in this embodiment is generally SHA-256 algorithm, but other HASH algorithms may be used, and the present invention is not limited thereto.
In another embodiment of the present invention, in order to increase the complexity of the block and further increase the difficulty of hacking, the executing the intelligent contract in the block chain network may further be implemented by:
obtaining block data and a block data structure of a last block of the target block from the blockchain network;
splitting the update file into at least one sub-update data packet:
respectively generating block data of the block corresponding to each sub-update data packet according to the block data of the previous block and each sub-update data packet;
and respectively generating a target block corresponding to each sub-update data packet according to the block data structure and the block data of the block corresponding to each sub-update data packet.
For the block chain, the more blocks, the greater the difficulty of forging the blocks by hackers, and also considering the size of each block and the calculation amount of the block. So that each chunk may contain partially updated file content. In addition, each time the update file of the client software is stored in the block, the update history packet of the software is in the block chain, so that the number of blocks of the block chain is increased, the account book is larger, and the difficulty of tampering by hackers is further increased.
Fig. 2 schematically shows a flowchart of an update method of an application program according to another embodiment of the present invention. Referring to fig. 2, the method for updating an application program according to an embodiment of the present invention is applicable to client-side execution, and specifically includes the following steps:
step S21, receiving a target block sent by a server through a block chain network, wherein the target block is generated by the server executing an intelligent contract in the block chain network, and the intelligent contract is used for generating the target block according to an update file of an application program to be updated; a block chain network is pre-deployed between a server and a client corresponding to the application program to be updated, and the server and the client are user nodes in the block chain network;
step S22, executing the intelligent contract, where the intelligent contract is further used to perform security check on the received target block;
and step S23, updating the application program according to the verified target block.
According to the method for updating the application program, provided by the embodiment of the invention, the received target block is subjected to security verification, and the application program is updated according to the verified target block, wherein the target block is generated according to the update file. The embodiment of the invention can avoid malicious behaviors of a third party such as interception and tampering of the update file or addition of viruses, and the like, and can ensure synchronous update of all clients and reduce network bandwidth pressure of the server by adopting the block chain technology to send the update file to each user node in the block chain network.
In this embodiment of the present invention, the executing of the intelligent contract in step S22 is specifically implemented by the following steps:
acquiring block data of a last block of the target blocks from the block chain network;
and performing security check on the target block according to the block data of the previous block and a preset mapping relation between the block data of the target block and the block data of the previous block.
In this embodiment, the target block refers to a newly generated block, and the previous block refers to a block before the target block.
In this embodiment, when a client in the block chain receives a block, the client performs security check on the block to determine whether the current block is legal, so as to prevent a hacker from forging the block, or the transmission of the block in the network is modified. Each block needs to be security checked. The concrete implementation is as follows:
assume that the last block name is prevblock and then a newly generated block, the target block name, is received as newblock.
1. First, whether its index is correct is determined.
Newblock.index!=prevblock.index+1;
If the block number of the target block is not the block number of the last block plus 1, the target block is not legal, and block error information is directly returned.
2. Then, the hash value of the block is determined.
Newblock.previousHash!=prevblock.hash
And if the hash value of the last block of the target block is not equal to the hash value of the last block, the target block is considered to be illegal, and block error information is directly returned.
3. And judging the hash value of the target block.
The hash value of the target block is a hash result of each data in the entire data structure of the target block.
HASH(Newblock.index+Newblock.previousHash+Newblock.timestamp+Newblock.data+Newblock.randdata+Newblock.zero)!=Newblock.hash;
And if the hash value of the data of the whole block of the target block is not equal to the hash value of the target block, the target block is considered to be illegal, and block error information is directly returned.
4. And judging the update package content of the target block.
The data value of the target block contains the updated file content and the MD5 value of the file content, the MD5 value of the updated content can be calculated again to compare whether the MD5 value stored in the data is consistent, if so, the content is correct and not tampered, otherwise, the block is not updated. Thus, the safety check of the target block is realized.
In the embodiment of the invention, in all the clients of the block chain, all the clients update all the block data by using the P2P technology, so that the software updating function is realized, and meanwhile, the server is also a user node of the block chain, and updates the block, so that the block can be checked again to check whether the updated file block distributed by the server is correct. While subsequent updates to other files can be distributed to all blockchain clients using the methods herein to generate one chunk.
In view of the defects or improvement needs in the prior art, embodiments of the present invention provide a method for implementing client application program update based on a blockchain technique. The blockchain technology can have the function of encrypting and saving the blocks to prevent data from being tampered, and more importantly, the blockchain technology has the technology of P2P, and can synchronize the blocks by using the P2P technology in all the clients of the blockchain, so that the updating from the server is faster, and the network bandwidth pressure of the server is reduced. The use of the blockchain ensures the integrity of the update package, so that anyone cannot tamper with the content of the update package, and simultaneously ensures that all clients must be updated to the latest clients.
For simplicity of explanation, the method embodiments are described as a series of acts or combinations, but those skilled in the art will appreciate that the embodiments are not limited by the order of acts described, as some steps may occur in other orders or concurrently with other steps in accordance with the embodiments of the invention. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred and that no particular act is required to implement the invention.
Fig. 3 schematically shows a structural diagram of an updating apparatus of an application according to an embodiment of the present invention. Referring to fig. 3, the apparatus for updating an application according to an embodiment of the present invention is specifically configured on a server side or implemented by a server device, and includes a generation module 301, a server-side processing module 302, and a server-side communication module 303, where:
a generating module 301, configured to generate an update file of an application program to be updated, where a blockchain network is deployed in advance between a server and a client corresponding to the application program to be updated, and the server and the client are user nodes in the blockchain network;
a server-side processing module 302, configured to execute an intelligent contract in the blockchain network, where the intelligent contract is used to generate a target block according to the update file;
a server side communication module 303, configured to send the generated target block to each user node in the blockchain network through the blockchain network, so that each user node executes an intelligent contract, where the intelligent contract is further configured to perform security check on the received target block, and update an application program according to the checked target block.
In this embodiment of the present invention, the server-side processing module 302 is specifically configured to obtain, from the blockchain network, block data and a block data structure of a previous block of the target block; generating block data of a target block according to the block data of the previous block, the update file and a preset mapping relation between the block data of the target block and the block data of the previous block; and generating the target block according to the block data structure and the block data of the target block.
The block data structure comprises a block number, a timestamp, a first coding value, a first key value, block data, a preset value, a random number and a second coding value; the first encoding value is a second encoding value of a last block of the current block, the first key value is an MD5 value of the update file corresponding to the current block, and the second encoding value is a hash value of data obtained by combining the block number, the timestamp, the first encoding value, the first key value, the block data, the preset value, and the random number.
In another embodiment of the present invention, in order to increase the complexity of a block and further increase the difficulty of hacking, the server-side processing module 302 is specifically configured to obtain the block data and the block data structure of the last block of the target block from the blockchain network; splitting the update file into at least one sub-update data packet; respectively generating block data of the block corresponding to each sub-update data packet according to the block data of the previous block and each sub-update data packet; and respectively generating a target block corresponding to each sub-update data packet according to the block data structure and the block data of the block corresponding to each sub-update data packet.
Fig. 4 is a schematic structural diagram of an application updating apparatus according to another embodiment of the present invention. Referring to fig. 4, the apparatus for updating an application according to an embodiment of the present invention is configured at a client side or implemented by a client, and specifically includes a client communication module 401, a client processing module 402, and a program updating module 403, where:
a client communication module 401, configured to receive a target block sent by a server through a block chain network, where the target block is generated by the server executing an intelligent contract in the block chain network, and the intelligent contract is used to generate the target block according to an update file of an application program to be updated; a block chain network is pre-deployed between a server and a client corresponding to the application program to be updated, and the server and the client are user nodes in the block chain network;
a client processing module 402 configured to execute the intelligent contract, wherein the intelligent contract is further configured to perform security check on the received target block;
and a program updating module 403, configured to update the application program according to the verified target block.
In this embodiment of the present invention, the client processing module 402 is further adapted to obtain block data of a previous block of the target block from the blockchain network; and performing security check on the target block according to the block data of the previous block and a preset mapping relation between the block data of the target block and the block data of the previous block. In this embodiment, whether the block data of the target block satisfies the preset mapping relationship with respect to the block data of the previous block is determined according to the block data of the previous block of the target block and the preset mapping relationship between the block data of the target block and the block data of the previous block, so as to perform security check on the received target block, and if the block data of the target block satisfies the preset mapping relationship with respect to the block data of the previous block, the security check is passed.
For the device embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, refer to the partial description of the method embodiment.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
According to the method and the device for updating the application program, provided by the embodiment of the invention, the target block is generated according to the update file corresponding to the application program to be updated by executing the intelligent contract which is pre-deployed in the block chain network between the server and the client of the application program to be updated, and then the generated target block is sent to each user node in the block chain network through the block chain network, so that each user node can perform security verification on the received target block and update the application program according to the verified target block. The embodiment of the invention can avoid malicious behaviors of a third party such as interception and tampering of the update file or addition of viruses, and the like, and can ensure synchronous update of all clients and reduce network bandwidth pressure of the server by adopting the block chain technology to send the update file to each user node in the block chain network.
Furthermore, an embodiment of the present invention also provides a computer-readable storage medium, on which a computer program is stored, which when executed by a processor implements the steps of the method according to the embodiment shown in fig. 1 or the steps of the method according to the embodiment shown in fig. 2.
In this embodiment, the module/unit integrated with the updating apparatus of the application program according to the embodiment shown in fig. 3 or the updating apparatus of the application program according to the embodiment shown in fig. 4 may be stored in a computer-readable storage medium if it is implemented in the form of a software functional unit and sold or used as a stand-alone product. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments may be implemented. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
Fig. 5 is a schematic diagram of a computer device according to an embodiment of the present invention. The computer device provided by the embodiment of the present invention includes a memory 501, a processor 502, and a computer program stored on the memory 501 and executable on the processor 502, where the processor 502 implements the steps in the embodiment of the method for updating an application program, such as the steps shown in fig. 1 or the steps shown in fig. 2, when executing the computer program. Alternatively, the processor 502 implements the functions of each module/unit in the update apparatus embodiment of the application program when executing the computer program, for example, the generation module 301, the server-side processing module 302, and the server-side communication module 303 shown in fig. 3. Further examples are a client communication module 401, a client processing module 402 and a program update module 403 shown in fig. 4.
Illustratively, the computer program may be partitioned into one or more modules/units that are stored in the memory and executed by the processor to implement the invention. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution process of the computer program in the updating apparatus of the application program according to the embodiment shown in fig. 3 or the updating apparatus of the application program according to the embodiment shown in fig. 4.
The computer device can be a desktop computer, a notebook, a palm computer, a cloud server and other computing devices. The computer device may include, but is not limited to, a processor, a memory. Those skilled in the art will appreciate that the schematic diagram 5 is merely an example of a computer device and is not intended to limit the computer device and may include more or fewer components than those shown, or some components may be combined, or different components, e.g., the computer device may also include input output devices, network access devices, buses, etc.
The Processor may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component, etc. The general purpose processor may be a microprocessor or the processor may be any conventional processor or the like which is the control center for the computer device and which connects the various parts of the overall computer device using various interfaces and lines.
The memory may be used to store the computer programs and/or modules, and the processor may implement various functions of the computer device by running or executing the computer programs and/or modules stored in the memory and calling data stored in the memory. The memory may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the cellular phone, and the like. In addition, the memory may include high speed random access memory, and may also include non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), at least one magnetic disk storage device, a Flash memory device, or other volatile solid state storage device.
Those skilled in the art will appreciate that while some embodiments herein include some features included in other embodiments, rather than others, combinations of features of different embodiments are meant to be within the scope of the invention and form different embodiments. For example, in the following claims, any of the claimed embodiments may be used in any combination.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (9)

1. An update method for an application program, the method comprising:
generating an update file of an application program to be updated, wherein a block chain network is deployed between a server and a client corresponding to the application program to be updated in advance, and the server and the client are user nodes in the block chain network;
executing an intelligent contract in the block chain network, wherein the intelligent contract is used for generating a target block according to the updating file; the executing of the intelligent contract in the blockchain network comprises: obtaining block data and a block data structure of a last block of the target block from the blockchain network; generating block data of a target block according to the block data of the previous block, the update file and a preset mapping relation between the block data of the target block and the block data of the previous block; generating the target block according to the block data structure and the block data of the target block;
and sending the generated target block to each user node in the block chain network through the block chain network so as to allow each user node to execute an intelligent contract, wherein the intelligent contract is also used for carrying out security check on the received target block and updating an application program according to the checked target block.
2. The method of claim 1, wherein the tile data structure comprises a tile number, a timestamp, a first encoded value, a first key value, tile data, a preset value, a random number, and a second encoded value; the first encoding value is a second encoding value of a last block of the current block, the first key value is an MD5 value of the update file corresponding to the current block, and the second encoding value is a hash value of data obtained by combining the block number, the timestamp, the first encoding value, the first key value, the block data, the preset value, and the random number.
3. The method of claim 1 or 2, wherein the executing the intelligent contract in the blockchain network comprises:
obtaining block data and a block data structure of a last block of the target block from the blockchain network;
splitting the update file into at least one sub-update data packet;
respectively generating block data of the block corresponding to each sub-update data packet according to the block data of the previous block and each sub-update data packet;
and respectively generating a target block corresponding to each sub-update data packet according to the block data structure and the block data of the block corresponding to each sub-update data packet.
4. An update method for an application program, the method comprising:
receiving a target block sent by a server through a block chain network, wherein the target block is generated by executing an intelligent contract in the block chain network by the server, and the intelligent contract is used for generating the target block according to an update file of an application program to be updated; a block chain network is pre-deployed between a server and a client corresponding to the application program to be updated, and the server and the client are user nodes in the block chain network; the target tile is generated by the server executing an intelligent contract in the blockchain network, and the method comprises the following steps: obtaining block data and a block data structure of a last block of the target block from the blockchain network; generating block data of a target block according to the block data of the previous block, the update file and a preset mapping relation between the block data of the target block and the block data of the previous block; generating the target block according to the block data structure and the block data of the target block;
executing the intelligent contract, wherein the intelligent contract is further used for performing security check on the received target block;
and updating the application program according to the checked target block.
5. The method of claim 4, wherein executing the smart contract comprises:
acquiring block data of a last block of the target blocks from the block chain network;
and performing security check on the target block according to the block data of the previous block and a preset mapping relation between the block data of the target block and the block data of the previous block.
6. An apparatus for updating an application, the apparatus comprising:
the system comprises a generation module, a service module and a service module, wherein the generation module is used for generating an update file of an application program to be updated, a block chain network is deployed between a server and a client corresponding to the application program to be updated in advance, and the server and the client are user nodes in the block chain network;
the server side processing module is used for executing an intelligent contract in the block chain network, and the intelligent contract is used for generating a target block according to the update file; the executing of the intelligent contract in the blockchain network comprises: obtaining block data and a block data structure of a last block of the target block from the blockchain network; generating block data of a target block according to the block data of the previous block, the update file and a preset mapping relation between the block data of the target block and the block data of the previous block; generating the target block according to the block data structure and the block data of the target block;
and the server side communication module is used for sending the generated target blocks to each user node in the block chain network through the block chain network so as to enable each user node to execute an intelligent contract, and the intelligent contract is also used for carrying out security check on the received target blocks and updating the application program according to the checked target blocks.
7. An apparatus for updating an application, the apparatus comprising:
the client communication module is used for receiving a target block sent by a server through a block chain network, wherein the target block is generated by the server executing an intelligent contract in the block chain network, and the intelligent contract is used for generating the target block according to an update file of an application program to be updated; a block chain network is pre-deployed between a server and a client corresponding to the application program to be updated, and the server and the client are user nodes in the block chain network; the target tile is generated by the server executing an intelligent contract in the blockchain network, and the method comprises the following steps: obtaining block data and a block data structure of a last block of the target block from the blockchain network; generating block data of a target block according to the block data of the previous block, the update file and a preset mapping relation between the block data of the target block and the block data of the previous block; generating the target block according to the block data structure and the block data of the target block;
the client processing module is used for executing the intelligent contract, and the intelligent contract is also used for carrying out security check on the received target block;
and the program updating module is used for updating the application program according to the verified target block.
8. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 3 or according to any one of claims 4 to 5.
9. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the steps of the method according to any of claims 1-3 or any of claims 4-5 when executing the program.
CN201810112015.5A 2018-02-05 2018-02-05 Application program updating method and device Active CN108270874B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810112015.5A CN108270874B (en) 2018-02-05 2018-02-05 Application program updating method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810112015.5A CN108270874B (en) 2018-02-05 2018-02-05 Application program updating method and device

Publications (2)

Publication Number Publication Date
CN108270874A CN108270874A (en) 2018-07-10
CN108270874B true CN108270874B (en) 2021-04-23

Family

ID=62773709

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810112015.5A Active CN108270874B (en) 2018-02-05 2018-02-05 Application program updating method and device

Country Status (1)

Country Link
CN (1) CN108270874B (en)

Families Citing this family (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108833610B (en) * 2018-07-19 2021-08-31 网宿科技股份有限公司 Information updating method, device and system
CN109375944B (en) * 2018-08-28 2021-10-01 浪潮金融信息技术有限公司 Terminal software distribution verification method based on block chain data structure
CN110969458A (en) * 2018-09-29 2020-04-07 武汉斗鱼网络科技有限公司 Integration method of client cluster, client and system
CN109388968B (en) * 2018-10-19 2021-05-14 杭州安恒信息技术股份有限公司 Lightweight Internet of things terminal system based on block chain and control method thereof
CN111258599B (en) * 2018-12-03 2023-06-20 中国电信股份有限公司 Firmware upgrade method, system and computer readable storage medium
CN109714652A (en) * 2018-12-18 2019-05-03 京信通信系统(中国)有限公司 Date storage method, system, storage medium and the equipment of ODN management system
CN109753767B (en) * 2019-01-04 2020-12-18 嘉兴熠智软件科技有限公司 Software distribution and updating method and device based on block chain, server and client
CN109889589B (en) * 2019-02-18 2021-11-23 闪联信息技术工程中心有限公司 System and method for realizing embedded hardware OTA (over the air) upgrading based on block chain
CN110502271A (en) * 2019-07-22 2019-11-26 平安科技(深圳)有限公司 Application program based on block chain sends out version method and system
CN110493345A (en) * 2019-08-23 2019-11-22 北京智芯微电子科技有限公司 Internet-of-things terminal method for upgrading software and system based on block chain
CN110535938B (en) * 2019-08-29 2021-07-27 腾讯科技(深圳)有限公司 Data processing method, equipment and storage medium based on intelligent contract
CN110780979B (en) * 2019-10-28 2021-01-26 北京海益同展信息科技有限公司 Control method and device for configuration under micro-service framework, medium and electronic equipment
KR102365945B1 (en) * 2019-12-12 2022-02-22 (주)포뎁스 Electronic terminal device capable of update processing for application based on blockchain and operating method thereof
CN111651467B (en) * 2020-05-25 2023-09-12 杭州溪塔科技有限公司 Block chain node interface issuing and calling method and device
CN112162770B (en) * 2020-10-20 2023-11-10 深圳技术大学 Firmware version upgrading method and device for realizing integrity verification based on block chain
CN112702419B (en) * 2020-12-21 2023-03-24 杭州趣链科技有限公司 Data processing method, device, equipment and storage medium based on block chain

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106534317A (en) * 2016-11-17 2017-03-22 杭州云象网络技术有限公司 Disaster recovery cloud storage system construction method based on block chain technology
CN106919419A (en) * 2017-02-03 2017-07-04 中钞信用卡产业发展有限公司北京智能卡技术研究院 The update method and device of the intelligent contract program on block chain
CN107077557A (en) * 2016-12-29 2017-08-18 深圳前海达闼云端智能科技有限公司 The method and device that software application is issued and verified
CN107249046A (en) * 2017-08-15 2017-10-13 李俊庄 A kind of distributed cloud storage system construction method based on block chain
CN107426253A (en) * 2017-09-26 2017-12-01 武汉斗鱼网络科技有限公司 A kind of data verification method and client

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2018516026A (en) * 2015-03-20 2018-06-14 リヴェッツ・コーポレーションRivetz Corp. Automatic device integrity authentication using blockchain
US20170352219A1 (en) * 2015-08-06 2017-12-07 Blockchain Technologies Corporation System and method for securely receiving and counting votes in an election
CN106603698A (en) * 2016-12-28 2017-04-26 北京果仁宝科技有限公司 Block chain consensus method based on DPOS and nodes
CN107391944A (en) * 2017-07-27 2017-11-24 北京太云科技有限公司 A kind of electronic health record shared system based on block chain

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106534317A (en) * 2016-11-17 2017-03-22 杭州云象网络技术有限公司 Disaster recovery cloud storage system construction method based on block chain technology
CN107077557A (en) * 2016-12-29 2017-08-18 深圳前海达闼云端智能科技有限公司 The method and device that software application is issued and verified
CN106919419A (en) * 2017-02-03 2017-07-04 中钞信用卡产业发展有限公司北京智能卡技术研究院 The update method and device of the intelligent contract program on block chain
CN107249046A (en) * 2017-08-15 2017-10-13 李俊庄 A kind of distributed cloud storage system construction method based on block chain
CN107426253A (en) * 2017-09-26 2017-12-01 武汉斗鱼网络科技有限公司 A kind of data verification method and client

Also Published As

Publication number Publication date
CN108270874A (en) 2018-07-10

Similar Documents

Publication Publication Date Title
CN108270874B (en) Application program updating method and device
US11501533B2 (en) Media authentication using distributed ledger
CN107294729B (en) Communication method and device between different nodes in block chain
US10630463B2 (en) Meta block chain
CN106778329B (en) Block chain intelligent contract template dynamic updating method, device and system
CN107396360B (en) Block verification method and device
CN107276765B (en) Processing method and device for consensus in block chain
CN111133733B (en) Method and system for automatic blockchain deployment based on cloud platform
CN109784870B (en) Contract management method, contract management device, computer equipment and computer readable storage medium
CN112699081A (en) File self-certification method and device based on block chain
CN109379343B (en) Heterogeneous consensus method of block chains and terminal
CN109634615B (en) Issuing method, verification method and device of application installation package
CN113032357A (en) File storage method and device and server
CN110597824A (en) Data storage method and device based on block chain network
CN112134883B (en) Method, device and related product for carrying out rapid authentication on trust relationship between nodes based on trusted computing
CN112131041A (en) Method, apparatus and computer program product for managing data placement
WO2022068235A1 (en) Information processing method and apparatus for generating random number on the basis of attribute of information, and device
KR101593675B1 (en) User data integrity verification method and apparatus
CN109885258B (en) Data deleting device and method based on block chain
KR102199967B1 (en) Method for preventing falsification data from being stored in network and system performing the method
CN111695098A (en) Multi-distributed cluster access method and device
CN110618989A (en) Information processing method, information processing device and related product
CN107592349B (en) Storage method, first edge network device and related device
CN107395772B (en) Management method and management system for repeated data
CN102750287A (en) Method for including index information and download authentication server

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant