feat: use libp2p as network
Abstracted the Network Service
- netflux is still usable
- libp2p has been added as a usable network solution
Additional features were added :
- Function to leave/join the network in the UI
Emulate going offline (no connection to previously connected peers)
- Move the cryptography functions away from the network services
Light refactoring was made to ensure that the cryptography process wouldn't need to be redefined every time a network solution was added.
The cryptography process related to the current environment is mostly defined in the handleCryptographyProcess
function, back in the cryptoService
class.
A new class was created, where generic function used across the solutions are defined. This class is called networkSolutionServiceFunctions
.
Additionnaly, some light refactoring was done to make the code more easier to understand. Comments were also added.
- Text added by other peers while offline wasn't retreived when joining the network again
The problem originates from the way the restartSyncInterval()
function would be called in any encryption type used. This function calls the function sync
at a regular interval.
This function will then call, under a specific condition, the muteCore.synchronize()
function (the function that handles the retreiving of added data while offline). This condition was that the cryptoState
was valued at ready
. Only, this variable could never be ready in an environement where no encryption was used.
The sync function was modified to account for the cryptoState
value but only in an encrypted environment. Otherwise, synchronization will happen.