Skip to content

Commit 053b0ff

Browse files
committed
clear profile version when peer is disconnected
1 parent ddc5f53 commit 053b0ff

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

src/DCLPulse/Peers/Simulation/IdentityBoard.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public void Set(PeerIndex id, string walletId)
2727
public bool TryGetPeerIndexByWallet(string walletId, out PeerIndex peerIndex) =>
2828
peerIdsByWallets.TryGetValue(walletId, out peerIndex);
2929

30-
public void Clear(PeerIndex id)
30+
public void Remove(PeerIndex id)
3131
{
3232
string? walletId = GetWalletIdByPeerIndex(id);
3333

src/DCLPulse/Peers/Simulation/PeerSimulation.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ public void SimulateTick(Dictionary<PeerIndex, PeerState> peers, uint tickCounte
113113
{
114114
snapshotBoard.ClearActive(observerId);
115115
spatialGrid.Remove(observerId);
116-
identityBoard.Clear(observerId);
116+
identityBoard.Remove(observerId);
117+
profileBoard.Remove(observerId);
117118
observerViews.Remove(observerId);
118119
peersToBeRemoved.Add(observerId);
119120
logger.LogInformation("Peer {Peer} removed after disconnected", observerId);

src/DCLPulse/Peers/Simulation/ProfileBoard.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ public void Set(PeerIndex id, int version)
1717
public int Get(PeerIndex id) =>
1818
Volatile.Read(ref versions[(int)id.Value]);
1919

20-
public void Clear(PeerIndex id) =>
20+
public void Remove(PeerIndex id)
21+
{
2122
Volatile.Write(ref versions[(int)id.Value], 0);
23+
announcements.TryRemove(id, out _);
24+
}
2225

2326
public bool HasBeenRecentlyAnnounced(PeerIndex id) =>
2427
announcements.GetValueOrDefault(id, false);

src/DCLPulseTests/IdentityBoardTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public void ConcurrentSetAndClear_ReadersNeverSeeTornValues()
8888
{
8989
var id = new PeerIndex((uint)i);
9090
board.Set(id, expectedWallets[i]);
91-
board.Clear(id);
91+
board.Remove(id);
9292
board.Set(id, expectedWallets[i]);
9393
}
9494
}

0 commit comments

Comments
 (0)