Skip to content

Commit 1aee177

Browse files
author
Pau
committed
fix concurrency issues accessing address cache in explorer
1 parent 3299fb2 commit 1aee177

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

Phantasma.Cryptography/Address.cs

+10-5
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,14 @@ public string Text
6969
{
7070
if (string.IsNullOrEmpty(_text))
7171
{
72-
if (_keyToTextCache.ContainsKey(_bytes))
73-
{
74-
_text = _keyToTextCache[_bytes];
72+
lock (_keyToTextCache) {
73+
if (_keyToTextCache.ContainsKey(_bytes))
74+
{
75+
_text = _keyToTextCache[_bytes];
76+
}
7577
}
76-
else
78+
79+
if (string.IsNullOrEmpty(_text))
7780
{
7881
char prefix;
7982

@@ -85,7 +88,9 @@ public string Text
8588

8689
}
8790
_text = prefix + Base58.Encode(_bytes);
88-
_keyToTextCache[_bytes] = _text;
91+
lock (_keyToTextCache) {
92+
_keyToTextCache[_bytes] = _text;
93+
}
8994
}
9095
}
9196

0 commit comments

Comments
 (0)