A blockchain-based method and device for real-time collaborative editing of a document

By using a bidirectional hash chain and a lazy deletion algorithm on a blockchain P2P network, the security and consistency issues of centralized service models in existing technologies are solved, enabling decentralized real-time collaborative editing and improving the security and response speed of multi-user collaborative editing.

CN118657120BActive Publication Date: 2025-11-18FUJIAN YIRONG INFORMATION TECH +1
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202410854672.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-28
Publication Date
2025-11-18
Estimated Expiration
2044-06-28

AI Technical Summary

Technical Problem

Existing real-time collaborative editing technologies rely on centralized service models, which suffer from network latency, data tampering, data leakage, and privacy protection issues, making it difficult to guarantee the security and consistency of collaborative editing among multiple users.

Method used

A P2P network framework is constructed using blockchain technology. Document data is stored through a bidirectional hash chain, and an insertion and deletion operation model is adopted. Combined with lazy deletion and insertion conflict handling algorithms, an operation sequence is generated and synchronized to ensure data consistency and security for each user terminal.

Benefits of technology

It enables real-time collaborative editing without relying on a centralized architecture, prevents data tampering, improves editing response speed and security, and ensures the consistency of operations for multiple people in collaborative editing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118657120B_ABST
    Figure CN118657120B_ABST
Patent Text Reader

Abstract

The application relates to a blockchain-based document real-time collaborative editing method and device, which comprises the following steps: constructing a collaborative editing communication network of a blockchain; defining the data structure; defining the data structure; and executing a consistent real-time collaborative editing algorithm on the blockchain.The application has the advantages of realizing multi-person real-time collaborative editing.Compared with the prior art, the application has the following advantages: the collaborative editing technology is combined with the blockchain technology, tamper-proofing is supported, a center is not needed, complex operation conversion is avoided on the basis of ensuring the consistency of document editing operations.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of blockchain document editing, in particular to a blockchain-based document real-time collaborative editing method and device. BACKGROUND

[0002] With the continuous development of the Internet and communication technology in recent years, remote collaborative work plays an increasingly important role in people's lives. Real-time collaborative editing, as an important part of remote collaborative work, has always been a popular research field. As a major user-oriented document editing application, real-time collaborative editing software needs to take into account user editing intentions, operation response time, etc. It usually has three characteristics: real-time, distribution and unconstrained. Real-time requires that the local response time of user operation be very short, and the transmission speed of remote sites be very fast. Distribution requires that users can collaborate through network connections using different network devices in different locations. Unconstrained requires that users can freely join or exit document collaboration. At present, most collaborative editing applications, such as Graph document, Tencent document, Kingsoft document, Google Doc, etc., rely on the central service model of the supplier, and there are problems of network delay, data tampering, data leakage and privacy protection. The contract, agreement and other files edited by multiple people are directly stored in the database of the service provider, without any security guarantee.

[0003] Prior art solution one: the invention patent with publication number CN115238304A, a document collaborative editing method and device, the method comprises: in response to the viewing permission setting request initiated by the first collaborative editing client for the target area in the document, setting the viewing permission of other collaborative editing clients for the target area; receiving the collaborative editing data generated by the first collaborative editing client for the target area; sending the collaborative editing data to other collaborative editing clients with viewing permission for the target area. Solution one only ensures the consistency of the editing object through an operation conversion algorithm, and is mainly based on a centralized architecture, which has the problems of network communication bottleneck and unreliable central node. The synchronization method also has the problem of inconsistent editing intentions, and it is difficult to support tamper-proofing.

[0004] The prior art scheme two: the invention patent with the publication number 115470758A, a multi-person collaborative editing method and device, the method comprises: receiving the operation of a first user for a first DOM element in a first document, positioning the cursor of the first user to the first DOM element, the first DOM element is any one DOM element in the DOM element tree corresponding to the first document;Receiving the operation of a second user for a second DOM element in the first document, wherein the operation for the second DOM element causes the position of the first DOM element in the DOM element tree corresponding to the first document to change;The cursor of the first user is repositioned to the first DOM element. Through the method, the problem of concurrent conflict and cursor synchronization disorder in current multi-person collaborative editing can be solved. Scheme two only designs an operation consistency algorithm that can maintain operation intention, but still mainly uses centralized architecture, has the problems of network communication bottleneck and unreliable central node, and is difficult to support tamper-proofing and other problems. Figure One

[0005] The prior art scheme one and the prior art scheme two both depend on the central service model, and the contract, agreement and other files edited by multiple persons are directly stored in the database of the service provider, so that the security guarantee is low, and there are problems of network delay, data tampering, data leakage and privacy protection. SUMMARY

[0006] In order to solve the above problems, the purpose of the present application is to provide a document real-time collaborative editing method based on a block chain, which realizes support for tamper-proofing, does not need to depend on the center, guarantees the real-time performance and security of editing on the basis of guaranteeing the consistency of document editing operation, avoids complex operation conversion, and improves the editing response speed.

[0007] To achieve the above purpose, the present application adopts the following technical scheme:

[0008] Technical scheme one

[0009] A document real-time collaborative editing method based on a block chain comprises the following steps:

[0010] Constructing a collaborative editing communication network of a block chain: the network is established on the P2P block chain network framework, users dispersed in various places perform local editing operation on the same document through terminals, and through the block chain network, the user simultaneously receives the update operation sequence of other users on the local terminal, and combines the remote operation and the local operation, so that each terminal maintains the same data structure;

[0011] ​Defining the data structure: the data structure contains a doubly linked hash list, all data in the current user document is stored in the doubly linked hash list, each item in the linked list corresponds to a unique PosID, all users; each user maintains the same data structure;

[0012] Defining the user operation model: the user operation model contains two operations: insertion and deletion;

[0013] Executing a consistent real-time collaborative editing algorithm on the blockchain: generating a sequence of operations for local and other remote users, if it is an insertion, creating a new node and specifying the PosID, executing the insert instruction to insert the new node into the doubly linked hash list, and executing the insertion conflict processing algorithm; if it is a deletion, execute the delete instruction; query the position of the new node in the doubly linked hash list, convert the information of the new node into a new remote operation; traverse each operation in the operation sequence, generate a new operation sequence, and synchronize it to other users through the blockchain network.

[0014] More preferably, each item only stores a character, picture, link or other shared object, and the content of each item cannot be modified.

[0015] More preferably, the execution process of the insertion conflict processing algorithm is: obtaining the PosID of the old insertion node, obtaining the PosID of the new insertion node, if the pointer of the old insertion node is the same as the pointer of the new insertion node and the PosID of the new insertion node is greater than the PosID of the old insertion node, the node and the node pointer causal relationship is destroyed, the new node insertion is abandoned, and the next new insertion node is traversed; if the pointer of the new insertion node is less than or equal to the pointer of the old insertion node, the position of the new insertion node is determined as the old insertion node.

[0016] More preferably, the execution of the delete instruction adopts lazy deletion.

[0017] More preferably, the process of executing the insert instruction is: determining the PosID corresponding to the predecessor object and the successor object of the new node to be inserted, and then searching the doubly linked hash list for insertion.

[0018] Based on the same inventive concept, the application also provides a document real-time collaborative editing device based on a blockchain.

[0019] Technical solution two

[0020] The application discloses a blockchain-based real-time collaborative editing device for a document, which comprises a collaborative editing communication network of a blockchain; the network is established on a P2P blockchain network framework, and users distributed in different places perform local editing operations on the same document through terminals; through the blockchain network, the users simultaneously accept update operation sequences of other users on the local terminals, and combine the remote operations and the local operations, so that each terminal maintains the same data structure; a data structure definition module; the data structure comprises a bidirectional hash linked list, all data in a current user document is stored in the bidirectional hash linked list, each item in the linked list corresponds to a unique PosID, and all users; each user maintains the same data structure; a user operation definition module; the module comprises two operations: insertion and deletion; a consistency real-time collaborative editing algorithm execution module; the module generates operation sequences of the local and other remote users, if the operation is insertion, a new node is created and a PosID is specified, an insert instruction is executed to insert the new node into the bidirectional hash linked list, and an insertion conflict processing algorithm is executed; if the operation is deletion, a delete instruction is executed; the position of the new node is inquired from the bidirectional hash linked list, information of the new node is converted into a new remote operation; each operation in the operation sequence is traversed, a new operation sequence is generated, and the new operation sequence is synchronized to other users through the blockchain network.

[0021] More preferably, each item only stores a character, a picture, a link or other shared objects, and the content of each item cannot be modified.

[0022] More preferably, the execution process of the insertion conflict processing algorithm is as follows: the PosID of an old insertion node is obtained, the PosID of a new insertion node is obtained, if the pointer of the old insertion node is the same as the pointer of the new insertion node and the PosID of the new insertion node is greater than the PosID of the old insertion node, the cause-and-effect relationship between the node and the node pointer is destroyed, the new node insertion is abandoned, and the next new insertion node is traversed; if the pointer of the new insertion node is less than or equal to the pointer of the old insertion node, the position of the new insertion node is determined as the old insertion node.

[0023] More preferably, the delete instruction is executed in a lazy deletion manner.

[0024] More preferably, the execution process of the insert instruction is as follows: the predecessor object and the successor object corresponding to the PosID of the new node to be inserted are determined, and then the bidirectional hash linked list is searched for insertion.

[0025] The application has the following beneficial effects:

[0026] This invention proposes a blockchain-based real-time collaborative editing algorithm and device, enabling real-time collaborative editing among multiple users. Compared with existing solutions, it has the following advantages: combining collaborative editing technology with blockchain technology, it achieves tamper-proof support, eliminates the need for a central authority, and avoids complex operation conversions while ensuring consistency in document editing operations. Attached Figure Description

[0027] Figure 1 This is a schematic diagram of the process of the present invention;

[0028] Figure 2 This is the P2P network model of the present invention;

[0029] Figure 3 This is a schematic diagram of the data structure of the present invention. Detailed Implementation

[0030] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments:

[0031] See Figure 1 A blockchain-based real-time collaborative document editing method includes the following steps:

[0032] Building a collaborative editing communication network for blockchain: such as Figure 2 As shown, this network is built on a P2P blockchain network framework. Users located in different locations perform local editing operations on the same document through their terminals. Through the blockchain network, users simultaneously receive update operation sequences from other users on their local terminals, merging remote and local operations to ensure that each terminal maintains the same data structure. Users first obtain network access authorization through a registration server to enter the designated collaborative editing network. After authorization, they obtain unsynchronized operation sequences from remote servers or other user terminals and then merge them locally. Subsequently, after completing a local operation, the user automatically distributes the operation to other users and receives and synchronizes remote operations in real time. Each operation includes two types: insertion and deletion. Ideally, all users hold the same operation sequence and upload these sequences to the blockchain for storage. All editing operation sequences are transmitted through the blockchain, which not only meets the requirements of decentralization but also ensures tamper-proof protection.

[0033] Define the data structure as follows: Figure 3 As shown, the data structure includes a doubly hashed linked list. All data in the current user's document is stored in the doubly hashed linked list. Each item in the list corresponds to a unique PosID. ​​All users maintain the same data structure, as follows: Figure 3As shown, it mainly consists of a doubly hashed linked list, where all data (including strings and images) in the current user's document is stored. The content stored in each item in the list should be indivisible; each item can only store one character (such as Unicode and ASCII characters), image, link, or other shared object. Furthermore, the content of each item is immutable to avoid data loss during concurrent updates. Therefore, if a deletion operation is needed on an item in the list, a lazy deletion scheme can be used, setting its deletion flag to 1. For example, Figure 3 The letter "B" in the list, after being lazy-deleted, still exists in the item it belongs to, but it is not visible in the user's view. The order of the linked list represents the order of the content in the document, such as... Figure 3 The link character "Amn" indicates the reading order of the characters in the document.

[0034] Define a user operation model: This includes two operations: insertion and deletion. The PosIDs of the predecessor and successor objects of the new node to be inserted are determined, and then the insertion is performed by searching the doubly hashed linked list. Specifically, the insert operation represents inserting at the current position. For example, inserting between two atomic objects in a document requires obtaining the sum of these two objects, and then searching the hashed linked list for insertion. Furthermore, the sum and tail of the linked list are used to represent the head and tail; these dummy nodes are only symbolic and do not store any data. Following this method, insertion at any point in the document can be represented using the hashed table insert function. Deleting any item requires specifying its PosID, and then setting the "deleted" field of the node containing that item to 1. Due to the use of a tombstone mechanism (lazy deletion), the deletion operation is very simple and will not conflict with any other operations in a multi-user concurrent scenario. Its disadvantage is that it occupies extra storage space and requires periodic garbage collection.

[0035] A consistent real-time collaborative editing algorithm is executed on the blockchain: An operation sequence is generated between the local user and other remote users. If it's an insertion, a new node is created and its PosID is specified. The insert instruction is executed to insert the new node into the doubly hashed linked list. An insertion conflict resolution algorithm is executed: the PosID of the old inserted node is obtained, and the PosID of the new inserted node is obtained. If the pointers of the old and new inserted nodes are the same and the PosID of the new inserted node is greater than the PosID of the old inserted node, the causal relationship between the node and the node pointer is broken, and the insertion of the new node is abandoned. The next new inserted node is traversed. If the pointer of the new inserted node is less than or equal to the pointer of the old inserted node, the position of the new inserted node is determined to be the old inserted node, and the next new inserted node is traversed. If it's a deletion, a delete instruction is executed. The position of the new node is queried in the doubly hashed linked list, and the information of the new node is converted into a new remote operation. Each operation in the operation sequence is traversed, a new operation sequence is generated, and synchronized to other users through the blockchain network. Specifically: When node A is inserted into the linked list, its original predecessor is... The successor is Due to concurrency, nodes and It was inserted by other users. Several nodes caused a conflict between node A and these nodes. If a forced insertion is attempted, node A will overwrite all the intermediate nodes, resulting in lost updates and inconsistencies in data among users, contradicting their original operational intentions. The consistent real-time collaborative editing algorithm of this invention addresses this by connecting node A with the nodes... Reordering preserves the operational intent, ensuring that the total order of these nodes is consistent across any user terminal, thus enabling integrated local and remote operation processing.

[0036] For example, the operation process of the consistent real-time collaborative editing algorithm is as follows:

[0037] Input: Operation sequences generated locally and by other remote users

[0038] Output: Transformed operation sequence

[0039] step:

[0040] 1: Iterate through each operation :

[0041] 2: If it is an insertion operation:

[0042] 3: Create a new node and specify / / Used as a globally unique ID to define the relative position of the node being operated on in the linked list.

[0043] 4: Executing the insert method will Insert into the hash list HT and execute the insertion collision resolution algorithm.

[0044] 5: Otherwise: Execute the delete method.

[0045] 6: Iterate through each operation again. :

[0046] 7: In the hash chain HT, via Hasℎ( Query node position

[0047] 8: Will Information converted into remote operation

[0048] 9: Change the new operation sequence It is synchronized with other users (distributed via the blockchain network).

[0049] The insertion conflict resolution algorithm operates as follows:

[0050] Input: OA,

[0051] Output: Insert position insertPos

[0052] step:

[0053] / / The insertion operation OA, Merge, and finally return to the insertion position.

[0054] 1: / / New inserted node , It is the PosID of the node to be inserted.

[0055] 2: insertPos = / / Initialize insertion position

[0056] 3: for O in :

[0057] 4:

[0058] / / Simple concurrency between O and OA, comparing PosID

[0059] 5: if and

[0060] 6: break

[0061] / / Jump if the causal relationship between OA and OA.origin is broken; OA.origin is the predecessor pointer.

[0062] 7: if and

[0063] 8: break

[0064] / / Based on transitivity, propagate as far forward as possible to ensure consistency of causality.

[0065] 9: if

[0066] 10: InsertPos =

[0067] 11: continue

[0068] 12: return insertPos.

[0069] The operation of the tombstone algorithm is as follows:

[0070] Input: Delete operation

[0071] Output: None

[0072] step:

[0073] / / Redirect the previous operations The corresponding node is marked as deleted.

[0074] 1: for D in do

[0075] 2: / / Query the nodes to be deleted

[0076] / / Mark to delete tombstone

[0077] 3: = 1 / / Mark Deleted Example 2

[0078] A blockchain-based real-time collaborative document editing device includes: a blockchain collaborative editing communication network: this network is built on a P2P blockchain network framework, allowing users located in different areas to perform local editing operations on the same document through terminals. Through the blockchain network, users simultaneously receive update operation sequences from other users on their local terminals, merging remote and local operations, ensuring that each terminal maintains the same data structure. A data structure definition module: the data structure includes a doubly hashed linked list, where all data in the current user's document is stored. Each item in the list corresponds to a unique PosID, and all users maintain the same data structure. A user operation definition module: this module includes two operations: insertion and deletion. The consistency real-time collaborative editing algorithm execution module generates operation sequences for local users and other remote users. If it is an insertion, it creates a new node and specifies its PosID, executes the insert instruction to insert the new node into the doubly hashed linked list, and executes the insertion collision handling algorithm. If it is a deletion, it executes the delete instruction. It queries the position of the new node in the doubly hashed linked list and converts the information of the new node into a new remote operation. It traverses each operation in the operation sequence, generates a new operation sequence, and synchronizes it with other users through the blockchain network.

[0079] More preferably, the execution process of the insertion conflict handling algorithm is as follows: obtain the PosID of the old insertion node, obtain the PosID of the new insertion node; if the pointer of the old insertion node is the same as the pointer of the new insertion node and the PosID of the new insertion node is greater than the PosID of the old insertion node, then the causal relationship between the node and the node pointer is broken, the insertion of the new node is abandoned, and the next new insertion node is traversed; if the pointer of the new insertion node is less than or equal to the pointer of the old insertion node, then the position of the new insertion node is determined to be the old insertion node.

[0080] Ideally, each item stores only one character, image, link, or other shared object, and the content of each item cannot be modified.

[0081] More preferably, the execution of the delete instruction employs lazy deletion.

[0082] More preferably, the process of executing the insert instruction is as follows: determine the PosID corresponding to the predecessor and successor objects of the new node to be inserted, and then search the doubly hashed linked list for insertion.

[0083] For details not described in Example 2, please refer to the specific steps in Example 1.

[0084] The above description is merely a specific embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent structural transformations made based on the content of the present invention specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of the present invention.

Claims

1. A blockchain-based real-time collaborative document editing method, characterized in that: Includes the following steps: Constructing a collaborative editing communication network based on blockchain: This network is built on a P2P blockchain network framework, where users in different locations can perform local editing operations on the same document through their terminals. Through the blockchain network, users can simultaneously receive update operation sequences from other users on their local terminals, and merge remote and local operations, so that each terminal maintains the same data structure. Define the data structure as follows: The data structure contains a doubly hashed linked list. All data in the current user's document is stored in the doubly hashed linked list. Each item in the list corresponds to a unique PosID. ​​Each item stores only one character, image, or link. The content of each item cannot be modified. Each user maintains the same data structure. Define the data structure as follows: The user's operations include insertion and deletion; A consistent real-time collaborative editing algorithm is executed on the blockchain: It generates operation sequences for local and other remote users. If it's an insertion, a new node is created and its PosID is specified. The `insert` instruction is executed to insert the new node into the doubly hashed linked list. An insertion conflict resolution algorithm is then executed. The algorithm's execution process is as follows: The PosID of the old inserted node is obtained, and the PosID of the new inserted node is obtained. If the pointers of the old and new inserted nodes are the same and the PosID of the new inserted node is greater than the PosID of the old inserted node, the causal relationship between the node and its pointer is broken, and the insertion of the new node is abandoned. The next new inserted node is then traversed. If the pointer of the new inserted node is less than or equal to the pointer of the old inserted node, the position of the new inserted node is determined to be the old inserted node, and the next new inserted node is traversed. If it's a deletion, a `delete` instruction is executed. The position of the new node is queried in the doubly hashed linked list, and the information of the new node is converted into a new remote operation. Each operation in the operation sequence is traversed, a new operation sequence is generated, and synchronized to other users through the blockchain network.

2. The method for real-time collaborative editing of documents based on blockchain according to claim 1, characterized in that: The delete instruction is executed using lazy deletion.

3. The method for real-time collaborative editing of documents based on blockchain according to claim 1, characterized in that: The process of executing the insert instruction is as follows: determine the PosID corresponding to the predecessor and successor objects of the new node to be inserted, and then search the doubly hashed linked list to insert it.

4. A blockchain-based real-time collaborative document editing device, characterized in that: Collaborative editing communication network of blockchain: This network is built on a P2P blockchain network framework, where users in different locations can perform local editing operations on the same document through their terminals. Through the blockchain network, users can simultaneously receive update operation sequences from other users on their local terminals, and merge remote and local operations, so that each terminal maintains the same data structure. Data structure definition module: The data structure contains a doubly hashed linked list. All data in the current user's document is stored in the doubly hashed linked list. Each item in the linked list corresponds to a unique PosID. ​​Each item stores only one character, image, or link. The content of each item cannot be modified. Each user maintains the same data structure. User operation definition module: contains two operations: insertion and deletion; The consistency real-time collaborative editing algorithm execution module generates operation sequences for local and other remote users. If it's an insertion, it creates a new node and assigns a PosID, executes the insert instruction to insert the new node into the doubly hashed linked list, and executes an insertion conflict resolution algorithm. The execution process of this algorithm is as follows: obtain the PosID of the old inserted node, obtain the PosID of the new inserted node; if the pointers of the old and new inserted nodes are the same and the PosID of the new inserted node is greater than the PosID of the old inserted node, the causal relationship between the node and the node pointer is broken, the insertion of the new node is abandoned, and the next new inserted node is traversed; if the pointer of the new inserted node is less than or equal to the pointer of the old inserted node, the position of the new inserted node is determined to be the old inserted node, and the next new inserted node is traversed; if it's a deletion, it executes the delete instruction; it queries the position of the new node in the doubly hashed linked list, converts the information of the new node into a new remote operation; it traverses each operation in the operation sequence, generates a new operation sequence, and synchronizes it to other users through the blockchain network.

5. A real-time collaborative document editing device based on blockchain according to claim 4, characterized in that: The delete instruction is executed using lazy deletion.

6. A real-time collaborative document editing device based on blockchain according to claim 4, characterized in that: The process of executing the insert instruction is as follows: determine the PosID corresponding to the predecessor and successor objects of the new node to be inserted, and then search the doubly hashed linked list to insert it.

Citation Information

Patent Citations

  • Document collaborative editing method and device

    CN115238304A

  • Real-time cooperative editing consistency maintenance method supporting string operation

    CN105955828A

  • Hash values for the bidirecctionally linked blockchain

    CN110520862A