A Transparent and Verifiable Way to Sync the AT Protocol's PLC Directory

update mempool

Changed files
+11 -10
bundle
internal
mempool
+3
bundle/manager.go
··· 493 return 0, fmt.Errorf("failed to create new mempool: %w", err) 494 } 495 496 m.mempool = newMempool 497 498 // ✨ Update DID index if enabled and track timing 499 var indexUpdateDuration time.Duration
··· 493 return 0, fmt.Errorf("failed to create new mempool: %w", err) 494 } 495 496 + oldMempool := m.mempool 497 m.mempool = newMempool 498 + 499 + oldMempool.Clear() 500 501 // ✨ Update DID index if enabled and track timing 502 var indexUpdateDuration time.Duration
+8 -10
internal/mempool/mempool.go
··· 199 // Remove taken operations 200 m.operations = m.operations[n:] 201 202 - // Adjust lastSavedLen to account for removed operations 203 - if m.lastSavedLen > 0 { 204 - if m.lastSavedLen > n { 205 - m.lastSavedLen -= n // Some saved ops remain 206 - } else { 207 - m.lastSavedLen = 0 // All saved ops were taken 208 - } 209 - } 210 211 - // ✨ Mark dirty since state changed 212 - m.dirty = true 213 214 return result, nil 215 }
··· 199 // Remove taken operations 200 m.operations = m.operations[n:] 201 202 + // ✨ FIX: ALWAYS reset tracking after Take 203 + // Take() means we're consuming these ops for a bundle 204 + // Any remaining ops are "new" and unsaved 205 + m.lastSavedLen = 0 206 + m.lastSaveTime = time.Now() 207 208 + // Mark dirty only if ops remain 209 + m.dirty = len(m.operations) > 0 210 + m.validated = false 211 212 return result, nil 213 }