Use Differential Syncing For Custom Files
RlonRyan opened this issue ยท 4 comments
Currently the custom file system syncs the entire directory, regardless of what the client already has saved. This is likely a significant waste of bandwith. An optimal solution would instead be to use a differential sync for the files, in that only the files that are different would be synced. A simple algorithm to do this is as follows:
- Hash the files already on the client side, and send a packet to the server containing the correct hash.
- The server responds with the either a packet saying correct hash or incorrect hash.
- The client responds to the correct/incorrect message.
a. If the client receives the correct hash message, the syncing stops, and the connection to the server is allowed to continue.
b. If the client receives the incorrect hash message, it responds by sending a complete manifest of the files present, their type, and their hash code. - The server compares the client manifest to the server manifest, and sends the different files to the client marked with the file number and the total file number.
- When the client receives the final file, the process returns to step 1, as to ensure transmission integrity.
Note: This method may suffer the Two Generals Problem, which will need to be addressed in the implementation of the algorithm.
This requires implementing hashing functions for all persistent objects defined in AgriCore.
AgriCraft Synchronization:
A simplified synchronization algorithm for transferring sets of files.
Process
- The compressed files are loaded into a hash table.
- The server caches the manifest for the loaded files.
- The client fetches the server manifest.
- The client compares the server manifest with the local manifest.
- The client deletes local entries that are not on the server manifest or are out-of-date.
- The client requests the missing files.
- The client checks integrity, and returns to step three if needed.
- The client finishes connection.
Required Classes:
- MessageManifest
- Holds the manifest for transmission to the client.
- MessageRequest
- Requests the server for a given file.
- MessageFile
- Contains a requested file for transmission to client.
This is something way over my confidence level, so I am assigning you, @RlonRyan ;)