BackupService constructor Null safety
Creates a new BackupService
Saves the public key in the initialization.
Implementation
BackupService(this._l0storage, Database database, this._key, this._getBlock)
: _repository = BackupRepository(database) {
String keyBackupPath = '${Bytes.base64UrlEncode(_key.address)}/public.key';
BackupModel? keyBackup = _repository.getByPath(keyBackupPath);
if (keyBackup == null) {
keyBackup = BackupModel(path: keyBackupPath);
_repository.save(keyBackup);
}
if (keyBackup.timestamp == null) {
Uint8List obj = base64.decode(_key.privateKey.public.encode());
_l0storage.write(keyBackupPath, obj);
keyBackup.timestamp = DateTime.now();
_repository.update(keyBackup);
}
_pending();
}