Skip to content

Commit

Permalink
[registry] fix outdated reads bug
Browse files Browse the repository at this point in the history
  • Loading branch information
redsolver committed Sep 1, 2023
1 parent 31928ef commit 08c4bda
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/service/registry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,11 @@ class RegistryService {
}

final streams = <Multihash, StreamController<SignedRegistryEntry>>{};
final subs = <Multihash>{};

Future<SignedRegistryEntry?> get(Uint8List pk) async {
final key = Multihash(pk);
if (streams.containsKey(key)) {
if (subs.contains(key)) {
node.logger.verbose('[registry] get (subbed) $key');
final res = getFromDB(pk);
if (res != null) {
Expand All @@ -124,6 +125,7 @@ class RegistryService {
return getFromDB(pk);
} else {
sendRegistryRequest(pk);
subs.add(key);
streams[key] = StreamController<SignedRegistryEntry>.broadcast();
if (getFromDB(pk) == null) {
node.logger.verbose('[registry] get (clean) $key');
Expand Down

0 comments on commit 08c4bda

Please sign in to comment.