AgriCraft

AgriCraft

30M Downloads

Use Differential Syncing For Custom Files

RlonRyan opened this issue ยท 4 comments

commented

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:

  1. Hash the files already on the client side, and send a packet to the server containing the correct hash.
  2. The server responds with the either a packet saying correct hash or incorrect hash.
  3. 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.
  4. 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.
  5. 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.

commented

This requires implementing hashing functions for all persistent objects defined in AgriCore.

commented

AgriCraft Synchronization:

A simplified synchronization algorithm for transferring sets of files.

Process

  1. The compressed files are loaded into a hash table.
  2. The server caches the manifest for the loaded files.
  3. The client fetches the server manifest.
  4. The client compares the server manifest with the local manifest.
  5. The client deletes local entries that are not on the server manifest or are out-of-date.
  6. The client requests the missing files.
  7. The client checks integrity, and returns to step three if needed.
  8. 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.
commented

Are you willing to work on this for 1.16?

commented

This is something way over my confidence level, so I am assigning you, @RlonRyan ;)