Merge branch 'krille/bootstrap-logs' into 'main'

refactor: Add verbose logs and refactor something

See merge request famedly/famedlysdk!601
This commit is contained in:
Krille Fear 2021-01-05 13:56:20 +00:00
commit 7fe183d527
1 changed files with 20 additions and 11 deletions

View File

@ -456,21 +456,29 @@ class Bootstrap {
// aaaand set the SSSS secrets
final futures = <Future<void>>[];
if (masterKey != null) {
futures.add(client.onSync.stream.firstWhere((syncUpdate) =>
client.userDeviceKeys.containsKey(client.userID) &&
client.userDeviceKeys[client.userID].masterKey != null &&
client.userDeviceKeys[client.userID].masterKey.ed25519Key ==
masterKey.publicKey));
futures.add(
client.onSync.stream
.firstWhere((syncUpdate) =>
client.userDeviceKeys.containsKey(client.userID) &&
client.userDeviceKeys[client.userID].masterKey != null &&
client.userDeviceKeys[client.userID].masterKey.ed25519Key ==
masterKey.publicKey)
.then((_) => Logs().v('New Master Key was created')),
);
}
for (final entry in secretsToStore.entries) {
futures.add(client.onSync.stream.firstWhere((syncUpdate) => syncUpdate
.accountData
.any((accountData) => accountData.type == entry.key)));
futures.add(
client.onSync.stream
.firstWhere((syncUpdate) => syncUpdate.accountData
.any((accountData) => accountData.type == entry.key))
.then((_) =>
Logs().v('New Key with type ${entry.key} was created')),
);
await newSsssKey.store(entry.key, entry.value);
}
for (final f in futures) {
await f;
}
Logs().v(
'Wait for MasterKey and ${secretsToStore.entries.length} keys to be created');
await Future.wait<void>(futures);
final keysToSign = <SignableKey>[];
if (masterKey != null) {
if (client.userDeviceKeys[client.userID].masterKey.ed25519Key !=
@ -558,6 +566,7 @@ class Bootstrap {
}
set state(BootstrapState newState) {
Logs().v('BootstrapState', newState);
if (state != BootstrapState.error) {
_state = newState;
}