-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathapp_storage.go
More file actions
784 lines (705 loc) · 21.3 KB
/
Copy pathapp_storage.go
File metadata and controls
784 lines (705 loc) · 21.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
// Copyright 2026 HOLOGRAM Project. All rights reserved.
// Storage Management - Unified Data & Storage section backend.
// Enumerates on-disk artifacts, reports sizes, dispatches clears by category/tier.
package main
import (
"fmt"
"log"
"os"
"path/filepath"
"strings"
"time"
wailsRuntime "github.com/wailsapp/wails/v2/pkg/runtime"
)
// === Public types — Wails marshals these to the frontend ===
// StorageCategory describes one clearable artifact.
type StorageCategory struct {
ID string `json:"id"`
Label string `json:"label"`
Description string `json:"description"`
Tier string `json:"tier"` // "cache" | "appdata" | "settings" | "infra"
Color string `json:"color"` // legend swatch hint for the UI
Path string `json:"path"` // absolute filesystem path; "" for non-file-backed
SizeBytes int64 `json:"size_bytes"`
ItemLabel string `json:"item_label"` // "6 apps", "3 filters" — for non-byte categories
LastWrite int64 `json:"last_write"` // unix seconds; 0 if unknown
Recovery string `json:"recovery"` // one-line recovery hint
Clearable bool `json:"clearable"`
BlockedBy string `json:"blocked_by"` // why if !Clearable
InUse bool `json:"in_use"` // service is actively writing
Managed bool `json:"managed"` // false for wallet row
}
// StorageUsage is the full payload returned by GetStorageUsage.
type StorageUsage struct {
BasePath string `json:"base_path"`
TotalBytes int64 `json:"total_bytes"`
Categories []StorageCategory `json:"categories"`
}
// === Category identifiers ===
// Keeping these as constants so the dispatcher and the frontend stay in sync.
const (
StorageGnomonIndex = "gnomon_index"
StorageOfflineCache = "offline_cache"
StoragederodBinary = "derod_binary"
StorageTELAClones = "tela_clones"
StorageSimulatorData = "simulator_data"
StorageContentFilter = "content_filter"
StorageNRSCache = "nrs_cache"
StorageSearchExclusions = "search_exclusions"
StorageWatchedSCs = "watched_scs"
StorageXSWDPermissions = "xswd_permissions"
StorageSettings = "settings"
StorageConsoleLogs = "console_logs"
StorageConnectionLog = "connection_log"
StorageWalletFiles = "wallet_files"
TierCache = "cache"
TierAppData = "appdata"
TierSettings = "settings"
TierInfra = "infra"
// The literal string the user must type to arm a full reset.
resetConfirmToken = "RESET"
)
// === Wails-bound API ===
// GetStorageUsage enumerates every category with size and status.
func (a *App) GetStorageUsage() StorageUsage {
base := getHologramDataDir()
cats := a.collectCategories()
var total int64
for _, c := range cats {
if c.Managed {
total += c.SizeBytes
}
}
return StorageUsage{
BasePath: base,
TotalBytes: total,
Categories: cats,
}
}
// ClearStorageCategory clears a single category by ID.
func (a *App) ClearStorageCategory(id string) map[string]interface{} {
a.logToConsole(fmt.Sprintf("[Storage] Clearing category: %s", id))
freed, err := a.clearOne(id)
if err != nil {
a.logToConsole(fmt.Sprintf("[ERR] Storage clear failed (%s): %v", id, err))
return map[string]interface{}{
"success": false,
"id": id,
"error": err.Error(),
"freed_bytes": int64(0),
}
}
a.emitStorageCleared(id, freed)
return map[string]interface{}{
"success": true,
"id": id,
"freed_bytes": freed,
}
}
// ClearStorageTier clears every clearable category in the given tier.
func (a *App) ClearStorageTier(tier string) map[string]interface{} {
a.logToConsole(fmt.Sprintf("[Storage] Clearing tier: %s", tier))
ids := tierMembers(tier)
if len(ids) == 0 {
return map[string]interface{}{
"success": false,
"tier": tier,
"error": fmt.Sprintf("unknown tier: %s", tier),
}
}
var (
freed int64
cleared []string
skipped []map[string]interface{}
)
for _, id := range ids {
n, err := a.clearOne(id)
if err != nil {
skipped = append(skipped, map[string]interface{}{
"id": id,
"error": err.Error(),
})
continue
}
freed += n
cleared = append(cleared, id)
}
a.emitStorageTierCleared(tier, freed, cleared)
return map[string]interface{}{
"success": true,
"tier": tier,
"freed_bytes": freed,
"cleared": cleared,
"skipped": skipped,
}
}
// ResetHologram wipes every managed category. Requires the literal
// string "RESET" as token — same pattern as the typed-confirm modal.
func (a *App) ResetHologram(confirmToken string) map[string]interface{} {
if strings.TrimSpace(confirmToken) != resetConfirmToken {
return map[string]interface{}{
"success": false,
"error": "Confirmation token mismatch. Type RESET to confirm.",
}
}
a.logToConsole("[Storage] Resetting HOLOGRAM — clearing all managed categories")
var (
freed int64
cleared []string
skipped []map[string]interface{}
)
// Order matters: appdata first (stops services), then cache, settings, infra.
for _, tier := range []string{TierAppData, TierCache, TierSettings, TierInfra} {
for _, id := range tierMembers(tier) {
n, err := a.clearOne(id)
if err != nil {
skipped = append(skipped, map[string]interface{}{
"id": id,
"error": err.Error(),
})
continue
}
freed += n
cleared = append(cleared, id)
}
}
a.logToConsole(fmt.Sprintf("[Storage] Reset complete — %d categories cleared, %d skipped", len(cleared), len(skipped)))
wailsRuntime.EventsEmit(a.ctx, "storage:reset", map[string]interface{}{
"freed_bytes": freed,
"cleared": cleared,
"skipped": skipped,
})
return map[string]interface{}{
"success": true,
"freed_bytes": freed,
"cleared": cleared,
"skipped": skipped,
}
}
// === Category enumeration ===
func (a *App) collectCategories() []StorageCategory {
network := a.getNetworkName()
gnomonRunning := a.gnomonClient != nil && a.gnomonClient.IsRunning()
gnomonPath, _ := gnomonDBDir(network) // A15: single source of truth, matches Gnomon Start/CleanDB (retired the old phantom path)
offlinePath := filepath.Join(getDatashardsDir(), "offline_cache")
derodPath := filepath.Join(getHologramDataDir(), "derod")
telaPath := filepath.Join(getDatashardsDir(), "tela")
contentPath := filepath.Join(getDatashardsDir(), "content_filter")
nrsPath := filepath.Join(getDatashardsDir(), "nrs_cache")
exclusionsPath := filepath.Join(getDatashardsDir(), "search_exclusions.json")
settingsPath := filepath.Join(getDatashardsDir(), "settings", "settings.json")
// Simulator data lives in its own datashards subdir managed by SimulatorManager.
simulatorPath := filepath.Join(getDatashardsDir(), "simulator")
cats := []StorageCategory{
{
ID: StorageGnomonIndex,
Label: "Gnomon Index",
Description: "On-chain SC index built from the daemon.",
Tier: TierAppData,
Color: "cyan",
Path: gnomonPath,
SizeBytes: walkDirSize(gnomonPath),
LastWrite: lastModified(gnomonPath),
Recovery: "Fastsync ≈ 8 min · Full Resync hours to days",
Clearable: !gnomonRunning,
BlockedBy: ifThen(gnomonRunning, "Stop Gnomon before clearing — or use Fastsync to rebuild in place."),
InUse: gnomonRunning,
Managed: true,
},
{
ID: StorageOfflineCache,
Label: "Offline App Cache",
Description: "Locally cached TELA apps for offline browsing.",
Tier: TierCache,
Color: "emerald",
Path: offlinePath,
SizeBytes: walkDirSize(offlinePath),
LastWrite: lastModified(offlinePath),
Recovery: "Re-downloads automatically on next visit",
Clearable: true,
Managed: true,
},
{
ID: StoragederodBinary,
Label: "derod Binary",
Description: "Downloaded DERO node executable.",
Tier: TierInfra,
Color: "violet",
Path: derodPath,
SizeBytes: walkDirSize(derodPath),
LastWrite: lastModified(derodPath),
Recovery: "Re-downloads automatically on next embedded-node start",
Clearable: true,
Managed: true,
},
{
ID: StorageTELAClones,
Label: "TELA App Clones",
Description: "Locally served TELA app folders.",
Tier: TierAppData,
Color: "amber",
Path: telaPath,
SizeBytes: walkDirSize(telaPath),
LastWrite: lastModified(telaPath),
Recovery: "Re-clones from chain on next install or open",
Clearable: true,
Managed: true,
},
{
ID: StorageSimulatorData,
Label: "Simulator Data",
Description: "Local test blockchain and wallet for simulator mode.",
Tier: TierAppData,
Color: "rose",
Path: simulatorPath,
SizeBytes: walkDirSize(simulatorPath),
LastWrite: lastModified(simulatorPath),
Recovery: "Starts fresh on next simulator launch",
Clearable: true,
Managed: true,
},
{
ID: StorageContentFilter,
Label: "Content Filter",
Description: "Safe Browsing rules and decision history.",
Tier: TierCache,
Color: "muted",
Path: contentPath,
SizeBytes: walkDirSize(contentPath),
LastWrite: lastModified(contentPath),
Recovery: "Rebuilds defaults on next launch",
Clearable: true,
Managed: true,
},
{
ID: StorageNRSCache,
Label: "NRS Cache",
Description: "DERO Name Service lookups.",
Tier: TierCache,
Color: "muted",
Path: nrsPath,
SizeBytes: walkDirSize(nrsPath),
LastWrite: lastModified(nrsPath),
Recovery: "Regenerates per lookup",
Clearable: true,
Managed: true,
},
{
ID: StorageSearchExclusions,
Label: "Search Exclusions",
Description: "User-defined Gnomon search filters.",
Tier: TierAppData,
Color: "dim",
Path: exclusionsPath,
SizeBytes: fileSize(exclusionsPath),
ItemLabel: exclusionsCount(),
LastWrite: lastModified(exclusionsPath),
Recovery: "User must re-add filters manually",
Clearable: true,
Managed: true,
},
{
ID: StorageWatchedSCs,
Label: "Watched SCs",
Description: "Smart contracts watched via Time Machine.",
Tier: TierAppData,
Color: "dim",
Path: "",
ItemLabel: watchedSCsCount(a),
Recovery: "User must re-add via Explorer",
Clearable: true,
Managed: true,
},
{
ID: StorageXSWDPermissions,
Label: "XSWD Permissions",
Description: "Connected dApps and granted wallet permissions.",
Tier: TierAppData,
Color: "dim",
Path: "",
ItemLabel: xswdAppCount(),
Recovery: "dApps must re-request access on next visit",
Clearable: true,
Managed: true,
},
{
ID: StorageSettings,
Label: "Settings",
Description: "Persisted preferences (Restore defaults).",
Tier: TierSettings,
Color: "dim",
Path: settingsPath,
SizeBytes: fileSize(settingsPath),
LastWrite: lastModified(settingsPath),
Recovery: "Restores compile-time defaults",
Clearable: true,
Managed: true,
},
{
ID: StorageWalletFiles,
Label: "Wallet Files",
Description: "Wallet files live outside the app directory and are not managed here.",
Tier: "",
Color: "dim",
Path: "",
Clearable: false,
BlockedBy: "Not managed here",
Managed: false,
},
}
return cats
}
// === Dispatch table ===
func (a *App) clearOne(id string) (int64, error) {
switch id {
case StorageGnomonIndex:
return a.clearGnomonIndex()
case StorageOfflineCache:
return a.clearOfflineCache()
case StoragederodBinary:
return a.clearderodBinary()
case StorageTELAClones:
return a.clearTELAClones()
case StorageSimulatorData:
return a.clearSimulatorData()
case StorageContentFilter:
return a.clearContentFilter()
case StorageNRSCache:
return a.clearNRSCache()
case StorageSearchExclusions:
return a.clearSearchExclusions()
case StorageWatchedSCs:
return a.clearWatchedSCs()
case StorageXSWDPermissions:
return a.clearXSWDPermissions()
case StorageSettings:
return a.restoreSettings()
case StorageConsoleLogs:
return 0, a.clearConsoleLogsAdapter()
case StorageConnectionLog:
return 0, a.clearConnectionLogAdapter()
case StorageWalletFiles:
return 0, fmt.Errorf("wallet files are not managed by HOLOGRAM")
default:
return 0, fmt.Errorf("unknown category: %s", id)
}
}
func tierMembers(tier string) []string {
switch tier {
case TierCache:
return []string{
StorageOfflineCache,
StorageContentFilter,
StorageNRSCache,
StorageConsoleLogs,
StorageConnectionLog,
}
case TierAppData:
return []string{
StorageGnomonIndex,
StorageTELAClones,
StorageSimulatorData,
StorageSearchExclusions,
StorageWatchedSCs,
StorageXSWDPermissions,
}
case TierSettings:
return []string{StorageSettings}
case TierInfra:
return []string{StoragederodBinary}
default:
return nil
}
}
// === Per-category clear implementations ===
func (a *App) clearGnomonIndex() (int64, error) {
network := a.getNetworkName()
path, err := gnomonDBDir(network) // A15: target the real Gnomon index (retired the old phantom path)
if err != nil {
return 0, err
}
if a.gnomonClient != nil && a.gnomonClient.IsRunning() {
return 0, fmt.Errorf("Gnomon is running — stop it first")
}
before := walkDirSize(path)
if err := safeRemoveAll(path); err != nil {
return 0, err
}
return before, nil
}
func (a *App) clearOfflineCache() (int64, error) {
path := filepath.Join(getDatashardsDir(), "offline_cache")
before := walkDirSize(path)
if a.offlineCache != nil {
if err := a.offlineCache.ClearCache(); err != nil {
return 0, err
}
return before, nil
}
// No live cache instance — wipe the directory directly.
if err := safeRemoveAll(path); err != nil {
return 0, err
}
return before, nil
}
func (a *App) clearderodBinary() (int64, error) {
path := filepath.Join(getHologramDataDir(), "derod")
before := walkDirSize(path)
if err := safeRemoveAll(path); err != nil {
return 0, err
}
return before, nil
}
func (a *App) clearTELAClones() (int64, error) {
path := filepath.Join(getDatashardsDir(), "tela")
before := walkDirSize(path)
// Stop any TELA servers serving from this directory before wiping it.
if _, err := a.tryShutdownTELAServers(); err != nil {
a.logToConsole(fmt.Sprintf("[Storage] TELA shutdown reported: %v", err))
}
if err := safeRemoveAll(path); err != nil {
return 0, err
}
return before, nil
}
func (a *App) clearSimulatorData() (int64, error) {
path := filepath.Join(getDatashardsDir(), "simulator")
before := walkDirSize(path)
if a.simulatorManager != nil && a.simulatorManager.IsReady() {
a.simulatorManager.StopSimulatorMode()
}
// ResetSimulator handles the wipe via the SimulatorManager when available.
if a.simulatorManager != nil {
_ = a.simulatorManager.ResetSimulator()
return before, nil
}
if err := safeRemoveAll(path); err != nil {
return 0, err
}
return before, nil
}
func (a *App) clearContentFilter() (int64, error) {
path := filepath.Join(getDatashardsDir(), "content_filter")
before := walkDirSize(path)
if err := safeRemoveAll(path); err != nil {
return 0, err
}
return before, nil
}
func (a *App) clearNRSCache() (int64, error) {
path := filepath.Join(getDatashardsDir(), "nrs_cache")
before := walkDirSize(path)
if err := safeRemoveAll(path); err != nil {
return 0, err
}
return before, nil
}
func (a *App) clearSearchExclusions() (int64, error) {
path := filepath.Join(getDatashardsDir(), "search_exclusions.json")
before := fileSize(path)
res := a.ClearSearchExclusions()
if ok, _ := res["success"].(bool); !ok {
if msg, _ := res["error"].(string); msg != "" {
return 0, fmt.Errorf("%s", msg)
}
return 0, fmt.Errorf("ClearSearchExclusions failed")
}
return before, nil
}
func (a *App) clearWatchedSCs() (int64, error) {
// Watched SCs live inside the time-travel datastore. Iterate the current
// list and unwatch each entry — this stays correct whether the indexer
// is live or not and avoids reaching into private storage.
res := a.GetWatchedSmartContracts()
list, _ := res["watched"].([]WatchedSC)
for _, w := range list {
if w.SCID != "" {
a.UnwatchSmartContract(w.SCID)
}
}
return 0, nil
}
func (a *App) clearXSWDPermissions() (int64, error) {
pm := GetPermissionManager()
if pm == nil {
return 0, fmt.Errorf("permission manager not initialized")
}
for _, app := range pm.GetAllApps() {
if app == nil {
continue
}
if err := pm.RevokeAllPermissions(app.Origin); err != nil {
a.logToConsole(fmt.Sprintf("[Storage] Failed to revoke %s: %v", app.Origin, err))
}
}
return 0, nil
}
// restoreSettings deletes the persisted settings file and resets in-memory
// settings to the same defaults app.go installs in NewApp().
func (a *App) restoreSettings() (int64, error) {
path := filepath.Join(getDatashardsDir(), "settings", "settings.json")
before := fileSize(path)
if err := safeRemoveAll(path); err != nil && !os.IsNotExist(err) {
return 0, err
}
a.settings["min_rating"] = 60
a.settings["block_malware"] = true
a.settings["show_nsfw"] = false
a.settings["auto_connect_ws"] = true
a.settings["gnomon_enabled"] = false
a.settings["daemon_endpoint"] = "http://127.0.0.1:10102"
a.settings["network"] = "mainnet"
a.settings["integrated_wallet"] = true
a.settings["allow_github_check"] = true
a.settings["hide_balance"] = false
a.settings["hide_address"] = false
a.settings["avatar_hidden"] = false
a.settings["privacy_mode"] = false
a.settings["signal_dark"] = false
a.settings["active_ring_member_set"] = ""
wailsRuntime.EventsEmit(a.ctx, "settings:restored", nil)
return before, nil
}
func (a *App) clearConsoleLogsAdapter() error {
res := a.ClearConsoleLogs()
if ok, _ := res["success"].(bool); !ok {
if msg, _ := res["error"].(string); msg != "" {
return fmt.Errorf("%s", msg)
}
}
return nil
}
func (a *App) clearConnectionLogAdapter() error {
res := a.ClearConnectionLog()
if ok, _ := res["success"].(bool); !ok {
if msg, _ := res["error"].(string); msg != "" {
return fmt.Errorf("%s", msg)
}
}
return nil
}
func (a *App) tryShutdownTELAServers() (map[string]interface{}, error) {
res := a.ShutdownTELAServers()
if ok, _ := res["success"].(bool); !ok {
if msg, _ := res["error"].(string); msg != "" {
return res, fmt.Errorf("%s", msg)
}
}
return res, nil
}
// === Helpers ===
// walkDirSize sums the bytes of every file under path. Returns 0 if the
// path does not exist or is not a directory. Symlinks are not followed.
func walkDirSize(path string) int64 {
info, err := os.Lstat(path)
if err != nil {
return 0
}
if !info.IsDir() {
return info.Size()
}
var total int64
_ = filepath.WalkDir(path, func(p string, d os.DirEntry, err error) error {
if err != nil {
return nil
}
if d.IsDir() {
return nil
}
fi, err := d.Info()
if err != nil {
return nil
}
total += fi.Size()
return nil
})
return total
}
func fileSize(path string) int64 {
info, err := os.Stat(path)
if err != nil {
return 0
}
if info.IsDir() {
return walkDirSize(path)
}
return info.Size()
}
func lastModified(path string) int64 {
info, err := os.Stat(path)
if err != nil {
return 0
}
return info.ModTime().Unix()
}
// safeRemoveAll only deletes paths that resolve under the HOLOGRAM data
// directory. Prevents misconfiguration or symlink trickery from wiping
// arbitrary parts of the filesystem.
func safeRemoveAll(path string) error {
if path == "" {
return fmt.Errorf("empty path")
}
abs, err := filepath.Abs(path)
if err != nil {
return fmt.Errorf("abs: %w", err)
}
base, err := filepath.Abs(getHologramDataDir())
if err != nil {
return fmt.Errorf("base abs: %w", err)
}
if !strings.HasPrefix(abs+string(filepath.Separator), base+string(filepath.Separator)) {
return fmt.Errorf("refusing to delete outside HOLOGRAM dir: %s", abs)
}
if abs == base {
return fmt.Errorf("refusing to delete HOLOGRAM root: %s", abs)
}
if _, err := os.Stat(abs); os.IsNotExist(err) {
return nil
}
log.Printf("[Storage] safeRemoveAll: %s", abs)
return os.RemoveAll(abs)
}
func ifThen(cond bool, val string) string {
if cond {
return val
}
return ""
}
func exclusionsCount() string {
path := filepath.Join(getDatashardsDir(), "search_exclusions.json")
if _, err := os.Stat(path); err != nil {
return "0 filters"
}
// Counting requires parsing the JSON; defer to the existing helper that
// already does this work so we don't duplicate the schema here.
// search_service.go exposes the list via the wallet helper but it is not
// directly callable — fall back to "set" if the file is present.
return "set"
}
func watchedSCsCount(a *App) string {
res := a.GetWatchedSmartContracts()
list, _ := res["watched"].([]WatchedSC)
return fmt.Sprintf("%d entries", len(list))
}
func xswdAppCount() string {
pm := GetPermissionManager()
if pm == nil {
return "0 apps"
}
return fmt.Sprintf("%d apps", len(pm.GetAllApps()))
}
func (a *App) emitStorageCleared(id string, freed int64) {
wailsRuntime.EventsEmit(a.ctx, "storage:cleared", map[string]interface{}{
"id": id,
"freed_bytes": freed,
"at": time.Now().Unix(),
})
}
func (a *App) emitStorageTierCleared(tier string, freed int64, cleared []string) {
wailsRuntime.EventsEmit(a.ctx, "storage:tier_cleared", map[string]interface{}{
"tier": tier,
"freed_bytes": freed,
"cleared": cleared,
"at": time.Now().Unix(),
})
}