+7
-12
cmd/plcbundle/commands/did.go
+7
-12
cmd/plcbundle/commands/did.go
···
165
165
166
166
func newDIDResolveCommand() *cobra.Command {
167
167
var (
168
-
verbose bool
169
-
showTiming bool
170
-
raw bool
168
+
verbose bool
169
+
raw bool
171
170
)
172
171
173
172
cmd := &cobra.Command{
···
185
184
Example: ` # Resolve DID
186
185
plcbundle did resolve did:plc:524tuhdhh3m7li5gycdn6boe
187
186
188
-
# Show timing breakdown
189
-
plcbundle did resolve did:plc:524tuhdhh3m7li5gycdn6boe --timing
187
+
# Show timings and other details
188
+
plcbundle did resolve did:plc:524tuhdhh3m7li5gycdn6boe --verbose
190
189
191
190
# Get raw PLC state (not W3C format)
192
191
plcbundle did resolve did:plc:524tuhdhh3m7li5gycdn6boe --raw
···
218
217
219
218
// Show resolution timing if it was a handle
220
219
if input != did {
221
-
if showTiming {
220
+
if verbose {
222
221
fmt.Fprintf(os.Stderr, "Handle resolution: %s → %s (%s)\n",
223
222
input, did, handleResolveTime)
224
223
} else {
···
226
225
}
227
226
}
228
227
229
-
if showTiming {
228
+
if verbose {
230
229
fmt.Fprintf(os.Stderr, "Resolving DID: %s\n", did)
231
-
}
232
-
233
-
if verbose {
234
230
mgr.GetDIDIndex().SetVerbose(true)
235
231
}
236
232
···
240
236
}
241
237
242
238
// Display timing if requested
243
-
if showTiming {
239
+
if verbose {
244
240
if handleResolveTime > 0 {
245
241
fmt.Fprintf(os.Stderr, "Handle: %s | ", handleResolveTime)
246
242
}
···
264
260
}
265
261
266
262
cmd.Flags().BoolVarP(&verbose, "verbose", "v", false, "Verbose debug output")
267
-
cmd.Flags().BoolVar(&showTiming, "timing", false, "Show timing breakdown")
268
263
cmd.Flags().BoolVar(&raw, "raw", false, "Output raw PLC state (not W3C document)")
269
264
270
265
return cmd
+1
internal/didindex/bundle.go
+1
internal/didindex/bundle.go
···
12
12
type BundleProvider interface {
13
13
LoadBundleForDIDIndex(ctx context.Context, bundleNumber int) (*BundleData, error)
14
14
LoadOperation(ctx context.Context, bundleNumber int, position int) (*plcclient.PLCOperation, error)
15
+
LoadOperations(ctx context.Context, bundleNumber int, positions []int) (map[int]*plcclient.PLCOperation, error)
15
16
GetBundleIndex() BundleIndexProvider
16
17
}
17
18
+12
-12
internal/didindex/lookup.go
+12
-12
internal/didindex/lookup.go
···
143
143
144
144
var results []OpLocationWithOperation
145
145
for bundleNum, locs := range bundleMap {
146
-
bundle, err := provider.LoadBundleForDIDIndex(ctx, int(bundleNum))
146
+
positions := make([]int, len(locs))
147
+
for i, l := range locs {
148
+
positions[i] = l.PositionInt()
149
+
}
150
+
opsMap, err := provider.LoadOperations(ctx, int(bundleNum), positions)
147
151
if err != nil {
148
152
dim.logger.Printf("Warning: failed to load bundle %d: %v", bundleNum, err)
149
153
continue
150
154
}
151
-
152
-
for _, loc := range locs {
153
-
if loc.PositionInt() >= len(bundle.Operations) {
154
-
continue
155
+
for i, l := range locs {
156
+
if op, ok := opsMap[positions[i]]; ok {
157
+
results = append(results, OpLocationWithOperation{
158
+
Operation: *op,
159
+
Bundle: l.BundleInt(),
160
+
Position: l.PositionInt(),
161
+
})
155
162
}
156
-
157
-
op := bundle.Operations[loc.Position()]
158
-
results = append(results, OpLocationWithOperation{
159
-
Operation: op,
160
-
Bundle: loc.BundleInt(),
161
-
Position: loc.PositionInt(),
162
-
})
163
163
}
164
164
}
165
165