mirror of
https://github.com/tim-beatham/smegmesh.git
synced 2025-08-25 20:15:19 +02:00
main - bugfix
- Nodes not being removed when deleted because when node gossips again it is readded. - Keep track of highest vector clock we have removed and used this as a mark for determining if something is stale.
This commit is contained in:
@@ -151,7 +151,7 @@ func (m *TwoPhaseMap[K, D]) GenerateMessage() *TwoPhaseMapState[K] {
|
||||
}
|
||||
}
|
||||
|
||||
func (m *TwoPhaseMapState[K]) Difference(state *TwoPhaseMapState[K]) *TwoPhaseMapState[K] {
|
||||
func (m *TwoPhaseMapState[K]) Difference(highestStale uint64, state *TwoPhaseMapState[K]) *TwoPhaseMapState[K] {
|
||||
mapState := &TwoPhaseMapState[K]{
|
||||
AddContents: make(map[uint64]uint64),
|
||||
RemoveContents: make(map[uint64]uint64),
|
||||
@@ -160,7 +160,7 @@ func (m *TwoPhaseMapState[K]) Difference(state *TwoPhaseMapState[K]) *TwoPhaseMa
|
||||
for key, value := range state.AddContents {
|
||||
otherValue, ok := m.AddContents[key]
|
||||
|
||||
if !ok || otherValue < value {
|
||||
if value > highestStale && (!ok || otherValue < value) {
|
||||
mapState.AddContents[key] = value
|
||||
}
|
||||
}
|
||||
@@ -168,7 +168,7 @@ func (m *TwoPhaseMapState[K]) Difference(state *TwoPhaseMapState[K]) *TwoPhaseMa
|
||||
for key, value := range state.RemoveContents {
|
||||
otherValue, ok := m.RemoveContents[key]
|
||||
|
||||
if !ok || otherValue < value {
|
||||
if value > highestStale && (!ok || otherValue < value) {
|
||||
mapState.RemoveContents[key] = value
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user