[DEPRECATED] Go implementation of plcbundle

index mutex protection

+11
+5
bundle/did_index.go
··· 44 44 config *DIDIndexConfig 45 45 logger Logger 46 46 verbose bool 47 + 48 + indexMu sync.RWMutex 47 49 } 48 50 49 51 // mmapShard represents a memory-mapped shard file ··· 124 126 125 127 // GetDIDLocations returns all bundle+position locations for a DID 126 128 func (dim *DIDIndexManager) GetDIDLocations(did string) ([]OpLocation, error) { 129 + dim.indexMu.RLock() 130 + defer dim.indexMu.RUnlock() 131 + 127 132 // Validate and extract identifier 128 133 identifier, err := extractDIDIdentifier(did) 129 134 if err != nil {
+6
bundle/did_index_builder.go
··· 41 41 42 42 // BuildIndexFromScratch builds index with controlled memory usage 43 43 func (dim *DIDIndexManager) BuildIndexFromScratch(ctx context.Context, mgr *Manager, progressCallback func(current, total int)) error { 44 + dim.indexMu.RLock() 45 + defer dim.indexMu.RUnlock() 46 + 44 47 dim.logger.Printf("Building DID index from scratch (memory-efficient mode)...") 45 48 46 49 bundles := mgr.index.GetBundles() ··· 224 227 225 228 // UpdateIndexForBundle adds operations from a new bundle (incremental + ATOMIC) 226 229 func (dim *DIDIndexManager) UpdateIndexForBundle(ctx context.Context, bundle *Bundle) error { 230 + dim.indexMu.RLock() 231 + defer dim.indexMu.RUnlock() 232 + 227 233 // Group operations by shard 228 234 shardOps := make(map[uint8]map[string][]OpLocation) 229 235